Package org.serviceconnector.web
Class SCBaseServlet
java.lang.Object
jakarta.servlet.GenericServlet
jakarta.servlet.http.HttpServlet
org.serviceconnector.web.SCBaseServlet
- All Implemented Interfaces:
jakarta.servlet.Servlet,jakarta.servlet.ServletConfig,Serializable
- Direct Known Subclasses:
SCBasePublishServlet,SCBaseSessionServlet
public abstract class SCBaseServlet
extends jakarta.servlet.http.HttpServlet
The Class SCBaseServlet. Base servlet for service implementations. SCBaseServlet is implemented by SCBaseSessionServlet and SCBasePublishServlet. User of servlet API must extend
SCBaseSessionServlet or SCBasePublishServlet depending on kind of service he likes to implement.
Communication between server and SC starts with registering the server for specific service on the SC. This initial steps are done by SCBaseServlet in startup phase. Settings like keep alive interval or max number of connections are extracted from the web.xml. After successful register the interfaces ISCSessionServerCallback/ISCPublishServerCallback implemented by the base classes get informed about client actions (create session, execute, subscribe, abort session).
One servlet serves one service (defined in web.xml) at the time. However two servlets may serve the same service. Looks like two different servers for an SC instance.
Deregister of the service is done by the SCBaseServlet and happens automatically when servlet gets destroyed.
Required parameters in web.xml, example for service "session-1":
Communication between server and SC starts with registering the server for specific service on the SC. This initial steps are done by SCBaseServlet in startup phase. Settings like keep alive interval or max number of connections are extracted from the web.xml. After successful register the interfaces ISCSessionServerCallback/ISCPublishServerCallback implemented by the base classes get informed about client actions (create session, execute, subscribe, abort session).
One servlet serves one service (defined in web.xml) at the time. However two servlets may serve the same service. Looks like two different servers for an SC instance.
Deregister of the service is done by the SCBaseServlet and happens automatically when servlet gets destroyed.
Required parameters in web.xml, example for service "session-1":
<context-param>
<param-name>scPort</param-name>
<param-value>7000</param-value>
</context-param>
<context-param>
<param-name>scHost</param-name>
<param-value>localhost</param-value>
</context-param>
<context-param>
<param-name>toSCKeepAliveIntervalSeconds</param-name>
<param-value>10</param-value>
</context-param>
<context-param>
<param-name>keepAliveTimeoutSeconds</param-name>
<param-value>10</param-value>
</context-param>
<context-param>
<param-name>checkRegistrationIntervalSeconds</param-name>
<param-value>300</param-value>
</context-param>
<context-param>
<param-name>tomcatPort</param-name>
<param-value>8080</param-value>
</context-param>
Example of a servlet service definition:
<servlet>
<description>Demo servlet for session service</description>
<display-name>DemoSCSessionServlet</display-name>
<servlet-name>DemoSCSessionServlet</servlet-name>
<servlet-class>org.serviceconnector.web.example.DemoSCSessionServlet</servlet-class>
<init-param>
<param-name>serviceName</param-name>
<param-value>session-1</param-value>
</init-param>
<init-param>
<param-name>maxConnections</param-name>
<param-value>100</param-value>
</init-param>
<init-param>
<param-name>maxSessions</param-name>
<param-value>100</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>DemoSCSessionServlet</servlet-name>
<url-pattern>/DemoSCSessionServlet</url-pattern>
</servlet-mapping>
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classThe Class SCServerCallback. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static org.serviceconnector.net.res.SCMPSessionCompositeRegistryThe composite registry.protected booleanThe registered.protected org.serviceconnector.net.req.SCRequesterThe requester.protected StringThe service name.Fields inherited from class jakarta.servlet.http.HttpServlet
LEGACY_DO_HEAD -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCheck registration with default operation timeout.voidcheckRegistration(int operationTimeoutSeconds) Check registration.voiddestroy()protected voiddoGet(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) protected voiddoPost(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) voidinit(jakarta.servlet.ServletConfig config) Methods inherited from class jakarta.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, serviceMethods inherited from class jakarta.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
-
Field Details
-
compositeRegistry
protected static org.serviceconnector.net.res.SCMPSessionCompositeRegistry compositeRegistryThe composite registry. -
registered
protected boolean registeredThe registered. -
requester
protected org.serviceconnector.net.req.SCRequester requesterThe requester. -
serviceName
The service name.
-
-
Constructor Details
-
SCBaseServlet
- See Also:
-
HttpServlet()
-
-
Method Details
-
init
public void init(jakarta.servlet.ServletConfig config) throws jakarta.servlet.ServletException - Specified by:
initin interfacejakarta.servlet.Servlet- Overrides:
initin classjakarta.servlet.http.HttpServlet- Throws:
jakarta.servlet.ServletException
-
doGet
protected void doGet(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws jakarta.servlet.ServletException, IOException - Overrides:
doGetin classjakarta.servlet.http.HttpServlet- Throws:
jakarta.servlet.ServletExceptionIOException- See Also:
-
HttpServlet.doGet(HttpServletRequest request, HttpServletResponse response)
-
doPost
protected void doPost(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws jakarta.servlet.ServletException, IOException - Overrides:
doPostin classjakarta.servlet.http.HttpServlet- Throws:
jakarta.servlet.ServletExceptionIOException- See Also:
-
HttpServlet.doPost(HttpServletRequest request, HttpServletResponse response)
-
checkRegistration
public void checkRegistration() throws org.serviceconnector.api.SCServiceExceptionCheck registration with default operation timeout. This message can be sent from the registered server to SC in order to check its registration.- Throws:
org.serviceconnector.api.SCServiceException- server is not registered for a service
check registration failed
error message received from SC
-
checkRegistration
public void checkRegistration(int operationTimeoutSeconds) throws org.serviceconnector.api.SCServiceException Check registration. This message can be sent from the registered server to SC in order to check its registration.- Parameters:
operationTimeoutSeconds- the allowed time in seconds to complete the operation- Throws:
org.serviceconnector.api.SCServiceException- server is not registered for a service
check registration failed
error message received from SC
-
destroy
public void destroy()- Specified by:
destroyin interfacejakarta.servlet.Servlet- Overrides:
destroyin classjakarta.servlet.GenericServlet
-