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":

	<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 Classes
    Modifier and Type
    Class
    Description
    protected class 
    The Class SCServerCallback.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static org.serviceconnector.net.res.SCMPSessionCompositeRegistry
    The composite registry.
    protected boolean
    The registered.
    protected org.serviceconnector.net.req.SCRequester
    The requester.
    protected String
    The service name.

    Fields inherited from class jakarta.servlet.http.HttpServlet

    LEGACY_DO_HEAD
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Check registration with default operation timeout.
    void
    checkRegistration(int operationTimeoutSeconds)
    Check registration.
    void
     
    protected void
    doGet(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)
     
    protected void
    doPost(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)
     
    void
    init(jakarta.servlet.ServletConfig config)
     

    Methods inherited from class jakarta.servlet.http.HttpServlet

    doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service

    Methods inherited from class jakarta.servlet.GenericServlet

    getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • compositeRegistry

      protected static org.serviceconnector.net.res.SCMPSessionCompositeRegistry compositeRegistry
      The composite registry.
    • registered

      protected boolean registered
      The registered.
    • requester

      protected org.serviceconnector.net.req.SCRequester requester
      The requester.
    • serviceName

      protected String serviceName
      The service name.
  • Constructor Details

    • SCBaseServlet

      protected SCBaseServlet(String urlPath)
      See Also:
      • HttpServlet()
  • Method Details

    • init

      public void init(jakarta.servlet.ServletConfig config) throws jakarta.servlet.ServletException
      Specified by:
      init in interface jakarta.servlet.Servlet
      Overrides:
      init in class jakarta.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:
      doGet in class jakarta.servlet.http.HttpServlet
      Throws:
      jakarta.servlet.ServletException
      IOException
      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:
      doPost in class jakarta.servlet.http.HttpServlet
      Throws:
      jakarta.servlet.ServletException
      IOException
      See Also:
      • HttpServlet.doPost(HttpServletRequest request, HttpServletResponse response)
    • checkRegistration

      public void checkRegistration() throws org.serviceconnector.api.SCServiceException
      Check 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:
      destroy in interface jakarta.servlet.Servlet
      Overrides:
      destroy in class jakarta.servlet.GenericServlet