Package org.activecomponents.webservice
Class AbstractWebSocketServer
- java.lang.Object
- 
- org.activecomponents.webservice.AbstractWebSocketServer
 
- 
 public abstract class AbstractWebSocketServer extends java.lang.ObjectThe abstract websocket server handles websocket requests from clients like browsers. Is the base class for specific impls like nano or jetty.
- 
- 
Field SummaryFields Modifier and Type Field Description protected IExternalAccessagentThe platform.protected BasicTypeConverterbasicconvertersThe basic type converters.protected java.util.Map<java.lang.String,IFuture<?>>incallsThe ongoing future calls from client.protected MultiCollection<java.lang.String,java.lang.String>mappingsThe interface -> impl file mappings.protected java.util.Map<java.lang.String,Future<?>>outcallsThe ongoing future calls to the client.protected java.util.Map<java.lang.String,java.util.Map<java.lang.Integer,java.lang.String>>partialsThe partial messages.protected java.util.Map<ClassInfo,MethodInfo[]>serviceinfosThe methodinfos per service interface.
 - 
Constructor SummaryConstructors Constructor Description AbstractWebSocketServer(IExternalAccess agent)Creates the server.
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidcleanSessionComponents(java.lang.Object session)Cleanup the (created) session platform components.protected java.lang.ObjectconvertToObject(java.lang.String val, java.lang.Class<?> type)Convert json to object representation.protected java.lang.StringconvertToString(java.lang.Object val)Convert an object to the json string representation.protected IFuture<java.lang.String>findModelName(java.lang.String typename)Find the component model name for a type/interface name.protected IFuture<MultiCollection<java.lang.String,java.lang.String>>getMappings()Generate a map of service interfaces and components.protected java.util.Set<java.lang.String>getMethodNames(MethodInfo[] mis)Get the method names.protected IFuture<IExternalAccess>getOrCreateSessionComponent(java.lang.String key, java.lang.Object session, java.lang.String filename, boolean create)Get or create a session component under the given key.IExternalAccessgetPlatform()Get the platform.abstract java.util.Map<java.lang.String,java.lang.Object>getSessionProperties(java.lang.Object ws)Get the properties belonging to a web socket session.protected IFuture<java.lang.String>handlePartialMessage(java.lang.Object session, PartialMessage msg)Handle a partial mesage.protected IFuture<java.lang.String>handlePullResultMessage(java.lang.Object session, PullResultMessage prm)Handle a pull result method.protected IFuture<java.lang.String>handleResultMessage(java.lang.Object session, ResultMessage rm)Handle a result message from a call to the client.protected IFuture<java.lang.String>handleSearchServiceMessage(java.lang.Object session, ServiceSearchMessage ssc)Handle a search service method.protected IFuture<java.lang.String>handleServiceInvocationMessage(java.lang.Object session, ServiceInvocationMessage sim)Handle a service invocation method.protected IFuture<java.lang.String>handleServiceProvideMessage(java.lang.Object session, ServiceProvideMessage spm)Handle a provide service method.protected IFuture<java.lang.String>handleServiceUnprovideMessage(java.lang.Object session, ServiceUnprovideMessage sum)Handle a provide service method.protected IFuture<java.lang.String>handleTerminateInvocationMessage(java.lang.Object session, ServiceTerminateInvocationMessage stim)Handle a terminate invocation method.voidonClose(java.lang.Object session)Called on close of a sessionvoidonMessage(java.lang.Object session, java.lang.String txt)protected IFuture<java.lang.String>sendException(java.lang.Exception ex, java.lang.String callid, java.lang.Object session)Send an exception message back to the client.protected IFuture<java.lang.String>sendMessage(BaseMessage message, java.lang.Object session)Send an message back to the client.protected IFuture<java.lang.String>sendResult(java.lang.Object res, java.lang.String callid, java.lang.Object session, boolean finished)Send a result message back to the client.abstract voidsendWebSocketData(java.lang.Object session, java.lang.String data)Abstract send message method.
 
- 
- 
- 
Field Detail- 
agentprotected IExternalAccess agent The platform.
 - 
incallsprotected java.util.Map<java.lang.String,IFuture<?>> incalls The ongoing future calls from client.
 - 
outcallsprotected java.util.Map<java.lang.String,Future<?>> outcalls The ongoing future calls to the client.
 - 
partialsprotected java.util.Map<java.lang.String,java.util.Map<java.lang.Integer,java.lang.String>> partials The partial messages. todo: cleanup per timeout
 - 
basicconvertersprotected BasicTypeConverter basicconverters The basic type converters.
 - 
mappingsprotected MultiCollection<java.lang.String,java.lang.String> mappings The interface -> impl file mappings.
 - 
serviceinfosprotected java.util.Map<ClassInfo,MethodInfo[]> serviceinfos The methodinfos per service interface.
 
- 
 - 
Constructor Detail- 
AbstractWebSocketServerpublic AbstractWebSocketServer(IExternalAccess agent) Creates the server.
 
- 
 - 
Method Detail- 
getPlatformpublic IExternalAccess getPlatform() Get the platform.- Returns:
- The platform.
 
 - 
handleSearchServiceMessageprotected IFuture<java.lang.String> handleSearchServiceMessage(java.lang.Object session, ServiceSearchMessage ssc) Handle a search service method.- Parameters:
- session- The session.
 
 - 
handleServiceInvocationMessageprotected IFuture<java.lang.String> handleServiceInvocationMessage(java.lang.Object session, ServiceInvocationMessage sim) Handle a service invocation method.- Parameters:
- session- The session.
- sim- The message.
 
 - 
findModelNameprotected IFuture<java.lang.String> findModelName(java.lang.String typename) Find the component model name for a type/interface name.- Parameters:
- typename- The service type name.
- Returns:
- The model name.
 
 - 
getMappingsprotected IFuture<MultiCollection<java.lang.String,java.lang.String>> getMappings() Generate a map of service interfaces and components. Helps to find a component that implements a service interface.
 - 
handleServiceProvideMessageprotected IFuture<java.lang.String> handleServiceProvideMessage(java.lang.Object session, ServiceProvideMessage spm) Handle a provide service method. Create or get the minimal agent that publishes the service using a proxy.- Parameters:
- session- The session of the provider.
- sim- The message.
 
 - 
handleServiceUnprovideMessageprotected IFuture<java.lang.String> handleServiceUnprovideMessage(java.lang.Object session, ServiceUnprovideMessage sum) Handle a provide service method. Create or get the minimal agent that publishes the service using a proxy.- Parameters:
- session- The session of the provider.
- sim- The message.
 
 - 
handleTerminateInvocationMessageprotected IFuture<java.lang.String> handleTerminateInvocationMessage(java.lang.Object session, ServiceTerminateInvocationMessage stim) Handle a terminate invocation method.- Parameters:
- session- The session.
- sim- The message.
 
 - 
handleResultMessageprotected IFuture<java.lang.String> handleResultMessage(java.lang.Object session, ResultMessage rm) Handle a result message from a call to the client.- Parameters:
- session- The session.
- rm- The message.
 
 - 
handlePullResultMessageprotected IFuture<java.lang.String> handlePullResultMessage(java.lang.Object session, PullResultMessage prm) Handle a pull result method.- Parameters:
- session- The session.
- prm- The message.
 
 - 
sendResultprotected IFuture<java.lang.String> sendResult(java.lang.Object res, java.lang.String callid, java.lang.Object session, boolean finished) Send a result message back to the client.
 - 
getMethodNamesprotected java.util.Set<java.lang.String> getMethodNames(MethodInfo[] mis) Get the method names.- Parameters:
- mis- The method infos.
- Returns:
- The method names.
 
 - 
sendExceptionprotected IFuture<java.lang.String> sendException(java.lang.Exception ex, java.lang.String callid, java.lang.Object session) Send an exception message back to the client.
 - 
sendMessageprotected IFuture<java.lang.String> sendMessage(BaseMessage message, java.lang.Object session) Send an message back to the client.
 - 
convertToStringprotected java.lang.String convertToString(java.lang.Object val) Convert an object to the json string representation.- Parameters:
- val- The value.
- Returns:
- The string representation.
 
 - 
convertToObjectprotected java.lang.Object convertToObject(java.lang.String val, java.lang.Class<?> type)Convert json to object representation.- Parameters:
- val- The json value.
- Returns:
- The object.
 
 - 
getOrCreateSessionComponentprotected IFuture<IExternalAccess> getOrCreateSessionComponent(java.lang.String key, java.lang.Object session, java.lang.String filename, boolean create) Get or create a session component under the given key. // todo: create session component on other than gateway platform?!
 - 
handlePartialMessageprotected IFuture<java.lang.String> handlePartialMessage(java.lang.Object session, PartialMessage msg) Handle a partial mesage.
 - 
cleanSessionComponentspublic void cleanSessionComponents(java.lang.Object session) Cleanup the (created) session platform components.- Parameters:
- session- The session.
 
 - 
onMessagepublic void onMessage(java.lang.Object session, java.lang.String txt)- Parameters:
- session-
- txt-
 
 - 
onClosepublic void onClose(java.lang.Object session) Called on close of a session- Parameters:
- session- The session.
 
 - 
sendWebSocketDatapublic abstract void sendWebSocketData(java.lang.Object session, java.lang.String data)Abstract send message method. Must be implemented by concrete web socket impl.- Parameters:
- session- The web socket session.
- data- The data to send.
 
 - 
getSessionPropertiespublic abstract java.util.Map<java.lang.String,java.lang.Object> getSessionProperties(java.lang.Object ws) Get the properties belonging to a web socket session.- Parameters:
- session- The session.
- Returns:
- The properties.
 
 
- 
 
-