public class ProxyEngineSelector extends ServerSessionFrameListener.Adapter
ProxyEngineSelector
is the main entry point for push stream events of a jetty SPDY proxy. It receives the
push stream frames from the clients, checks if there's an appropriate ProxyEngineSelector.ProxyServerInfo
for the given target
host and forwards the push to a ProxyEngine
for the protocol defined in ProxyEngineSelector.ProxyServerInfo
.
If no ProxyEngineSelector.ProxyServerInfo
can be found for the given target host or no ProxyEngine
can be found for
the given protocol, it resets the client stream.
This class also provides configuration for the proxy rules.
Modifier and Type | Class and Description |
---|---|
static class |
ProxyEngineSelector.ProxyServerInfo |
ServerSessionFrameListener.Adapter
Constructor and Description |
---|
ProxyEngineSelector() |
Modifier and Type | Method and Description |
---|---|
ProxyEngine |
getProxyEngine(String protocol) |
Map<String,ProxyEngine> |
getProxyEngines() |
protected ProxyEngineSelector.ProxyServerInfo |
getProxyServerInfo(String host) |
Map<String,ProxyEngineSelector.ProxyServerInfo> |
getProxyServerInfos() |
void |
onGoAway(Session session,
GoAwayResultInfo goAwayResultInfo)
Callback invoked when the other peer signals that it is closing the connection.
|
void |
onPing(Session clientSession,
PingResultInfo pingResultInfo)
Callback invoked when a ping request has completed its round-trip.
|
StreamFrameListener |
onSyn(Stream clientStream,
SynInfo clientSynInfo)
Callback invoked when a request to create a stream has been received.
|
void |
putProxyEngine(String protocol,
ProxyEngine proxyEngine) |
void |
putProxyServerInfo(String host,
ProxyEngineSelector.ProxyServerInfo proxyServerInfo) |
void |
setProxyEngines(Map<String,ProxyEngine> proxyEngines) |
void |
setProxyServerInfos(Map<String,ProxyEngineSelector.ProxyServerInfo> proxyServerInfos) |
onConnect
onFailure, onRst, onSettings
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
onFailure, onRst, onSettings
protected final Logger LOG
public final StreamFrameListener onSyn(Stream clientStream, SynInfo clientSynInfo)
SessionFrameListener
Callback invoked when a request to create a stream has been received.
Application code should implement this method and reply to the stream creation, eventually sending data:
public StreamFrameListener onSyn(Stream stream, SynInfo synInfo) { // Do something with the metadata contained in synInfo if (stream.isHalfClosed()) // The other peer will not send data { stream.reply(new ReplyInfo(false)); stream.data(new StringDataInfo("foo", true)); return null; // Not interested in further stream events } ... }
Alternatively, if the stream creation requires reading data sent from the other peer:
public StreamFrameListener onSyn(Stream stream, SynInfo synInfo) { // Do something with the metadata contained in synInfo if (!stream.isHalfClosed()) // The other peer will send data { stream.reply(new ReplyInfo(true)); return new Stream.FrameListener.Adapter() // Interested in stream events { public void onData(Stream stream, DataInfo dataInfo) { // Do something with the incoming data in dataInfo } }; } ... }
onSyn
in interface SessionFrameListener
onSyn
in class SessionFrameListener.Adapter
clientStream
- the stream just createdclientSynInfo
- the metadata sent on stream creationpublic void onPing(Session clientSession, PingResultInfo pingResultInfo)
SessionFrameListener
Callback invoked when a ping request has completed its round-trip.
onPing
in interface SessionFrameListener
onPing
in class SessionFrameListener.Adapter
clientSession
- the sessionpingResultInfo
- the metadata receivedpublic void onGoAway(Session session, GoAwayResultInfo goAwayResultInfo)
SessionFrameListener
Callback invoked when the other peer signals that it is closing the connection.
onGoAway
in interface SessionFrameListener
onGoAway
in class SessionFrameListener.Adapter
session
- the sessiongoAwayResultInfo
- the metadata sentpublic Map<String,ProxyEngine> getProxyEngines()
public void setProxyEngines(Map<String,ProxyEngine> proxyEngines)
public ProxyEngine getProxyEngine(String protocol)
public void putProxyEngine(String protocol, ProxyEngine proxyEngine)
public Map<String,ProxyEngineSelector.ProxyServerInfo> getProxyServerInfos()
protected ProxyEngineSelector.ProxyServerInfo getProxyServerInfo(String host)
public void setProxyServerInfos(Map<String,ProxyEngineSelector.ProxyServerInfo> proxyServerInfos)
public void putProxyServerInfo(String host, ProxyEngineSelector.ProxyServerInfo proxyServerInfo)
Copyright © 1995-2014 Mort Bay Consulting. All Rights Reserved.