Interface ServletService

  • All Superinterfaces:
    ADEPT2Service
    All Known Implementing Classes:
    EmbeddedServletService

    public interface ServletService
    extends ADEPT2Service
    A ServletService provides the means to publish a servlet at runtime. The servlet has to be created by the caller.
    • Method Detail

      • getBaseURL

        URL getBaseURL()
        Gets the base URL (without any context information) of the underlying servlet container. This URL (or rather this URL with the corresponding servlet contexts) has to be reachable via browser.
        Returns:
        The base URL (without any context information) of the underlying servlet container.
      • deployWebApp

        URL deployWebApp​(String hierarchicalContext,
                         DynamicServlet servlet,
                         Map<String,​Object> contextAttrs)
                  throws ServletDeploymentException
        Deploys the designated servlet via this service with the designated hierarchical context having the designated servlet context attributes. Usually the base URL appended by the hierarchical context will be the actual URL of the servlet.
        This will use "/" as URL pattern.

        Note that in case of an embedded servlet service, that is this service running within a servlet context, deploying service has to take place before the surrounding servlet context has been initialised.

        Parameters:
        hierarchicalContext - The hierarchical context of the servlet. This corresponds to the file or directory name when deploying in the file system (no trailing "/").
        servlet - The servlet which to deploy dynamically. Make sure that the servlet name is set appropriately since this is required for undeploying.
        contextAttrs - The attributes added to the servlet context when deploying the servlet. Make sure that the keys are unique! In case of an embedded servlet service, all servlets will have the very same context. This may be null.
        Returns:
        The URL of the designated servlet, that is the base URL of the servlet container appended by the name of the web application. This URL does not contain a URL pattern specified in the servlet mapping except for the default pattern ("/").
        Throws:
        ServletDeploymentException - If there are problems deploying the designated servlet, a ServletDeploymentException having no cause will be thrown, otherwise the causing exception will be wrapped (mostly problems with URL-encoding or servlet container configuration.
      • deployWebApp

        @Deprecated
        URL deployWebApp​(String hierarchicalContext,
                         Class<?> baseClass,
                         DynamicServlet servlet,
                         Map<String,​String> initParams,
                         Map<String,​Object> contextAttrs,
                         String urlMapping)
                  throws ServletDeploymentException
        Deploys the designated servlet via this service with the designated hierarchical context having the designated servlet context attributes. Usually the base URL appended by the hierarchical context will be the actual URL of the servlet.
        This will use "/" as URL pattern.

        Note that in case of an embedded servlet service, that is this service running within a servlet context, deploying service has to take place before the surrounding servlet context has been initialised.

        Implementations providing deployWebApp(String, Class, DynamicServlet, Map, Map, String, boolean) should provide an implementation of this method forwarding to deployWebApp(String, Class, DynamicServlet, Map, Map, String, boolean) with no asynchronous support (false as value for the last parameter).

        Parameters:
        hierarchicalContext - The hierarchical context of the servlet. This corresponds to the file or directory name when deploying in the file system (no trailing "/").
        baseClass - The class with which to load resources. This allows to have a WEB-INF-directory which is not at the top-level. It is expected to be besides this class. If this is null, the usual behaviour applies which is a top-level WEB-INF-directory.
        servlet - The servlet which to deploy dynamically. Make sure that the servlet name is set appropriately since this is required for undeploying.
        initParams - The init parameters of the servlet. This may be null.
        contextAttrs - The attributes added to the servlet context when deploying the servlet. Make sure that the keys are unique! In case of an embedded servlet service, all servlets will have the very same context. This may be null.
        urlMapping - The mapping for the designated servlet. This corresponds to URL-pattern in the deployment descriptor. If this is null, the default mapping "/" will be used.
        Returns:
        The URL of the designated servlet, that is the base URL of the servlet container appended by the name of the web application. This URL does not contain a URL pattern specified in the servlet mapping except for the default pattern ("/").
        Throws:
        ServletDeploymentException - If there are problems deploying the designated servlet, a ServletDeploymentException having no cause will be thrown, otherwise the causing exception will be wrapped (mostly problems with URL-encoding or servlet container configuration.
      • deployWebApp

        default URL deployWebApp​(String hierarchicalContext,
                                 Class<?> baseClass,
                                 DynamicServlet servlet,
                                 Map<String,​String> initParams,
                                 Map<String,​Object> contextAttrs,
                                 String urlMapping,
                                 boolean asyncSupported)
                          throws ServletDeploymentException
        Deploys the designated servlet via this service with the designated hierarchical context having the designated servlet context attributes. Usually the base URL appended by the hierarchical context will be the actual URL of the servlet.
        This will use "/" as URL pattern.

        Note that in case of an embedded servlet service, that is this service running within a servlet context, deploying service has to take place before the surrounding servlet context has been initialised.

        Parameters:
        hierarchicalContext - The hierarchical context of the servlet. This corresponds to the file or directory name when deploying in the file system (no trailing "/").
        baseClass - The class with which to load resources. This allows to have a WEB-INF-directory which is not at the top-level. It is expected to be besides this class. If this is null, the usual behaviour applies which is a top-level WEB-INF-directory.
        servlet - The servlet which to deploy dynamically. Make sure that the servlet name is set appropriately since this is required for undeploying.
        initParams - The init parameters of the servlet. This may be null.
        contextAttrs - The attributes added to the servlet context when deploying the servlet. Make sure that the keys are unique! In case of an embedded servlet service, all servlets will have the very same context. This may be null.
        urlMapping - The mapping for the designated servlet. This corresponds to URL-pattern in the deployment descriptor. If this is null, the default mapping "/" will be used.
        asyncSupported - Whether the designated servlet supports asynchronous operation.
        Returns:
        The URL of the designated servlet, that is the base URL of the servlet container appended by the name of the web application. This URL does not contain a URL pattern specified in the servlet mapping except for the default pattern ("/").
        Throws:
        ServletDeploymentException - If there are problems deploying the designated servlet, a ServletDeploymentException having no cause will be thrown, otherwise the causing exception will be wrapped (mostly problems with URL-encoding or servlet container configuration.
        See Also:
        Registration.Dynamic.setAsyncSupported(boolean)
      • undeployWebApp

        void undeployWebApp​(String hierarchicalContext,
                            String servletName)
                     throws ServletDeploymentException
        Undeploys the designated servlet deployed with the designated hierarchical context and servlet name. Note that undeploying may not work, for instance in case of an embedded servlet service.
        Parameters:
        hierarchicalContext - The hierarchical context with which the servlet has been deployed.
        servletName - The name of the servlet which to undeploy.
        Throws:
        ServletDeploymentException - If there are problems undeploying the designated web application, a ServletDeploymentException will be thrown. If this is due to undeploying a non existing web application, it will have no cause, problems when stopping the servlet will have the appropriate cause.