@Named public class ServerSession extends java.lang.Object implements ContextAware
ServerSession serverSession = tideContext.set(new ServerSession("/myapp", "localhost", 8080));
| Modifier and Type | Class and Description |
|---|---|
static class |
ServerSession.DefaultStatus |
static interface |
ServerSession.ServiceFactory
Internal SPI to define how remoting/messaging elements are created
|
static interface |
ServerSession.Status
Status notified of network related events
|
static interface |
ServerSession.TransportExceptionListener |
static interface |
ServerSession.TransportIOListener |
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
CONTEXT_FAULT |
static java.lang.String |
CONTEXT_RESULT |
static java.lang.String |
LOGIN |
static java.lang.String |
LOGOUT |
protected java.util.Map<java.lang.String,org.granite.client.messaging.RemoteService> |
remoteServices |
static java.lang.String |
SERVER_TIME_TAG |
static java.lang.String |
SESSION_EXP_TAG |
static java.lang.String |
SESSION_EXPIRED |
static java.lang.String |
SESSION_ID_TAG |
protected java.util.Map<java.lang.String,org.granite.client.messaging.TopicAgent> |
topicAgents |
| Constructor and Description |
|---|
ServerSession() |
ServerSession(org.granite.client.messaging.ServerApp serverApp)
Create a server session for the specified server app
|
ServerSession(java.lang.String contextRoot,
boolean secure,
java.lang.String serverName,
int serverPort)
Create a server session for the specified context root and server
|
ServerSession(java.lang.String contextRoot,
java.lang.String serverName,
int serverPort)
Create a server session for the specified context root and server
|
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(ServerSession.TransportExceptionListener listener) |
void |
addListener(ServerSession.TransportIOListener listener) |
void |
addRemoteAliasPackage(java.lang.String packageName)
Add a package name to scan for remote aliases
|
void |
afterLogin()
Called by
Identity after login has succeeded |
void |
checkWaitForLogout()
Notify the framework that it should wait for a async operation before effectively logging out.
|
java.lang.Object |
convert(java.lang.Object value,
java.lang.reflect.Type expectedType) |
org.granite.client.messaging.ClientAliasRegistry |
getAliasRegistry()
Return the current alias registry for this session
|
org.granite.client.messaging.Consumer |
getConsumer(java.lang.String destination,
java.lang.String topic)
Build a consumer for the default channel type and destination
|
org.granite.client.messaging.Consumer |
getConsumer(java.lang.String destination,
java.lang.String topic,
java.lang.String channelType)
Build a consumer for the specified channel type and destination
|
org.granite.util.ContentType |
getContentType()
Serialization type (default is JMF)
|
Context |
getContext()
Current Tide context
|
org.granite.client.messaging.channel.MessagingChannel |
getMessagingChannel(java.lang.String channelType)
Return a messaging channel for the specified type
|
org.granite.client.messaging.transport.Transport |
getMessagingTransport()
Current messaging transport
|
org.granite.client.messaging.Producer |
getProducer(java.lang.String destination,
java.lang.String topic)
Build a producer for the default channel type and destination
|
org.granite.client.messaging.Producer |
getProducer(java.lang.String destination,
java.lang.String topic,
java.lang.String channelType)
Build a producer for the specified channel type and destination
|
org.granite.client.messaging.RemoteService |
getRemoteService()
Returns remote service for the internal destination
Should generally not be used except for very advanced use, use
Component instead |
org.granite.client.messaging.RemoteService |
getRemoteService(java.lang.String destination)
Returns a remote service for the specified destination
Should generally not be used except for very advanced use, use
Component instead |
org.granite.client.messaging.transport.Transport |
getRemotingTransport()
Current remoting transport
|
java.lang.String |
getSessionId()
Current remote session id
|
ServerSession.Status |
getStatus()
Status implementation
|
boolean |
isLogoutInProgress()
Is logging out ?
|
void |
login(java.lang.String username,
java.lang.String password)
Implementation of login
Should not be called directly, called by
Identity.login(java.lang.String, java.lang.String, org.granite.client.tide.server.TideResponder<java.lang.String>) |
void |
login(java.lang.String username,
java.lang.String password,
java.nio.charset.Charset charset)
Implementation of login using a specific charset for username/password encoding
Should not be called directly, called by
Identity.login(java.lang.String, java.lang.String, org.granite.client.tide.server.TideResponder<java.lang.String>) |
void |
logout(java.util.Observer logoutObserver)
Implementation of logout
Should not be called directly, called by
Identity.logout() |
void |
notifyExceptionListeners(org.granite.client.messaging.transport.TransportException e) |
void |
notifyIOListeners(boolean busy) |
void |
onFaultEvent(org.granite.client.messaging.events.FaultEvent event,
org.granite.client.messaging.messages.responses.FaultMessage emsg)
Callback called when a remoting fault is received
|
void |
onIssueEvent(org.granite.client.messaging.events.IssueEvent event)
Callback called when a remoting failure is received
|
void |
onResultEvent(org.granite.client.messaging.events.Event event)
Callback called when a remoting response is received
|
void |
removeConsumer(org.granite.client.messaging.Consumer consumer)
Detach a consumer from the session
|
void |
removeListener(ServerSession.TransportExceptionListener listener) |
void |
removeListener(ServerSession.TransportIOListener listener) |
void |
removeProducer(org.granite.client.messaging.Producer producer)
Detach a producer from the session
|
void |
sessionExpired()
Called by
Identity after session has expired |
void |
setChannelFactoryClass(java.lang.Class<? extends org.granite.client.messaging.channel.ChannelFactory> channelFactoryClass)
Set a custom channel factory class
|
void |
setContentType(org.granite.util.ContentType contentType)
Set the serialization type
|
void |
setContext(Context context)
Set the Tide context for this server session
(internal method, should be set by the context itself)
|
void |
setDefaultChannelBuilder(org.granite.client.messaging.channel.ChannelBuilder channelBuilder)
Set the default channel builder
|
void |
setDefaultChannelType(java.lang.String channelType)
Set the default channel type for messaging
|
void |
setDefaultTimeToLive(long timeToLive)
Set default time to live on all channels
|
void |
setLogoutTimeout(long timeout) |
void |
setMessagingTransport(java.lang.String channelType,
org.granite.client.messaging.transport.Transport transport)
Set the messaging transport for the specified channel type
|
void |
setMessagingTransport(org.granite.client.messaging.transport.Transport transport)
Set the default messaging transport
|
void |
setPlatformContext(java.lang.Object platformContext)
Set the platform context for this server session
|
void |
setRemoteAliasPackages(java.util.Set<java.lang.String> packageNames)
Reset all package names to scan for remote aliases
|
void |
setRemotingTransport(org.granite.client.messaging.transport.Transport transport)
Set the remoting transport
|
void |
setServerApp(org.granite.client.messaging.ServerApp serverApp)
Set the server app for this server session
|
void |
setServiceFactory(ServerSession.ServiceFactory serviceFactory)
Set a custom service factory to create producer/consumers and remote services
|
void |
setStatus(ServerSession.Status status)
Set an implementation of the Status interface to be notified of server related information
|
void |
start()
Configure and start the server session
|
void |
stop()
Stop the server session and cleanup resources
|
void |
tryLogout()
Called after all remote operations on a component are finished.
|
public static final java.lang.String SERVER_TIME_TAG
public static final java.lang.String SESSION_ID_TAG
public static final java.lang.String SESSION_EXP_TAG
public static final java.lang.String CONTEXT_RESULT
public static final java.lang.String CONTEXT_FAULT
public static final java.lang.String LOGIN
public static final java.lang.String LOGOUT
public static final java.lang.String SESSION_EXPIRED
protected java.util.Map<java.lang.String,org.granite.client.messaging.RemoteService> remoteServices
protected java.util.Map<java.lang.String,org.granite.client.messaging.TopicAgent> topicAgents
public ServerSession()
throws java.lang.Exception
java.lang.Exceptionpublic ServerSession(java.lang.String contextRoot,
java.lang.String serverName,
int serverPort)
contextRoot - context rootserverName - server host nameserverPort - server portjava.lang.Exceptionpublic ServerSession(java.lang.String contextRoot,
boolean secure,
java.lang.String serverName,
int serverPort)
contextRoot - context rootsecure - server app is secured (https/wss/...)serverName - server host nameserverPort - server portjava.lang.Exceptionpublic ServerSession(org.granite.client.messaging.ServerApp serverApp)
serverApp - server application definitionpublic org.granite.util.ContentType getContentType()
public void setContentType(org.granite.util.ContentType contentType)
contentType - serialization typepublic void setDefaultChannelBuilder(org.granite.client.messaging.channel.ChannelBuilder channelBuilder)
channelBuilder - channel builderpublic void setDefaultChannelType(java.lang.String channelType)
channelType - channel typepublic void setChannelFactoryClass(java.lang.Class<? extends org.granite.client.messaging.channel.ChannelFactory> channelFactoryClass)
channelFactoryClass - channel factory classpublic void setServerApp(org.granite.client.messaging.ServerApp serverApp)
serverApp - server application definitionpublic void setLogoutTimeout(long timeout)
public void setContext(Context context)
setContext in interface ContextAwarecontext - Tide contextContextAwarepublic Context getContext()
public void setPlatformContext(java.lang.Object platformContext)
platformContext - public void setStatus(ServerSession.Status status)
status - statuspublic ServerSession.Status getStatus()
public void setRemotingTransport(org.granite.client.messaging.transport.Transport transport)
transport - remoting transportpublic void setMessagingTransport(org.granite.client.messaging.transport.Transport transport)
transport - messaging transportpublic void setMessagingTransport(java.lang.String channelType,
org.granite.client.messaging.transport.Transport transport)
channelType - channel typepublic void addRemoteAliasPackage(java.lang.String packageName)
packageName - package namepublic void setRemoteAliasPackages(java.util.Set<java.lang.String> packageNames)
packageNames - package namespublic org.granite.client.messaging.ClientAliasRegistry getAliasRegistry()
public java.lang.Object convert(java.lang.Object value,
java.lang.reflect.Type expectedType)
public void start()
public void stop()
public void setServiceFactory(ServerSession.ServiceFactory serviceFactory)
serviceFactory - service factorypublic org.granite.client.messaging.RemoteService getRemoteService()
Component insteadpublic org.granite.client.messaging.RemoteService getRemoteService(java.lang.String destination)
Component insteaddestination - destination namepublic org.granite.client.messaging.channel.MessagingChannel getMessagingChannel(java.lang.String channelType)
channelType - channel typeChannelTypepublic org.granite.client.messaging.Consumer getConsumer(java.lang.String destination,
java.lang.String topic,
java.lang.String channelType)
destination - destination nametopic - subtopicchannelType - channel typepublic org.granite.client.messaging.Consumer getConsumer(java.lang.String destination,
java.lang.String topic)
destination - destination nametopic - subtopicpublic void removeConsumer(org.granite.client.messaging.Consumer consumer)
consumer - consumerjava.lang.IllegalArgumentException - when the consumer has not been created from the sessionpublic org.granite.client.messaging.Producer getProducer(java.lang.String destination,
java.lang.String topic,
java.lang.String channelType)
destination - destination nametopic - subtopicchannelType - channel typepublic org.granite.client.messaging.Producer getProducer(java.lang.String destination,
java.lang.String topic)
destination - destination nametopic - subtopicpublic void removeProducer(org.granite.client.messaging.Producer producer)
producer - producerjava.lang.IllegalArgumentException - when the producer has not been created from the sessionpublic java.lang.String getSessionId()
public boolean isLogoutInProgress()
public void onResultEvent(org.granite.client.messaging.events.Event event)
event - eventpublic void onFaultEvent(org.granite.client.messaging.events.FaultEvent event,
org.granite.client.messaging.messages.responses.FaultMessage emsg)
event - fault eventemsg - fault messagepublic void onIssueEvent(org.granite.client.messaging.events.IssueEvent event)
event - failure eventpublic org.granite.client.messaging.transport.Transport getRemotingTransport()
public org.granite.client.messaging.transport.Transport getMessagingTransport()
public void login(java.lang.String username,
java.lang.String password)
Identity.login(java.lang.String, java.lang.String, org.granite.client.tide.server.TideResponder<java.lang.String>)username - user namepassword - passwordpublic void login(java.lang.String username,
java.lang.String password,
java.nio.charset.Charset charset)
Identity.login(java.lang.String, java.lang.String, org.granite.client.tide.server.TideResponder<java.lang.String>)username - user namepassword - passwordcharset - charset used for encodingpublic void afterLogin()
Identity after login has succeededpublic void sessionExpired()
Identity after session has expiredpublic void logout(java.util.Observer logoutObserver)
Identity.logout()logoutObserver - observer that will be notified of logout resultpublic void checkWaitForLogout()
public void tryLogout()
public void setDefaultTimeToLive(long timeToLive)
timeToLive - time to live in millisecondspublic void addListener(ServerSession.TransportIOListener listener)
public void removeListener(ServerSession.TransportIOListener listener)
public void addListener(ServerSession.TransportExceptionListener listener)
public void removeListener(ServerSession.TransportExceptionListener listener)
public void notifyIOListeners(boolean busy)
public void notifyExceptionListeners(org.granite.client.messaging.transport.TransportException e)