Package psiprobe

Class AbstractTomcatContainer

  • All Implemented Interfaces:
    TomcatContainer

    public abstract class AbstractTomcatContainer
    extends Object
    implements TomcatContainer
    Abstraction layer to implement some functionality, which is common between different container adapters.
    • Field Detail

      • logger

        protected final org.slf4j.Logger logger
        The logger.
      • host

        protected org.apache.catalina.Host host
        The host.
      • connectors

        protected org.apache.catalina.connector.Connector[] connectors
        The connectors.
      • deployerOName

        protected ObjectName deployerOName
        The deployer o name.
      • mbeanServer

        protected MBeanServer mbeanServer
        The mbean server.
    • Constructor Detail

      • AbstractTomcatContainer

        public AbstractTomcatContainer()
    • Method Detail

      • setWrapper

        public void setWrapper​(org.apache.catalina.Wrapper wrapper)
        Description copied from interface: TomcatContainer
        Sets the wrapper.
        Specified by:
        setWrapper in interface TomcatContainer
        Parameters:
        wrapper - the new wrapper
      • getAppBase

        public File getAppBase()
        Description copied from interface: TomcatContainer
        This method always returns absolute path, no matter what Tomcat is up to.
        Specified by:
        getAppBase in interface TomcatContainer
        Returns:
        absolute path to applications base (normally "webapps")
      • findConnectors

        public List<org.apache.catalina.connector.Connector> findConnectors()
        Description copied from interface: TomcatContainer
        Find connectors.
        Specified by:
        findConnectors in interface TomcatContainer
        Returns:
        all connectors
      • installContext

        public boolean installContext​(String contextName)
                               throws Exception
        Description copied from interface: TomcatContainer
        Deploys a context, assuming an context descriptor file exists on the server already.
        Specified by:
        installContext in interface TomcatContainer
        Parameters:
        contextName - the context path, which should match the filename
        Returns:
        true if deployment was successful
        Throws:
        Exception - if deployment fails spectacularly
      • stop

        public void stop​(String name)
                  throws Exception
        Description copied from interface: TomcatContainer
        Stops the context with the given name.
        Specified by:
        stop in interface TomcatContainer
        Parameters:
        name - the name of the context to stop
        Throws:
        Exception - if stopping the context fails spectacularly
      • start

        public void start​(String name)
                   throws Exception
        Description copied from interface: TomcatContainer
        Starts the context with the given name.
        Specified by:
        start in interface TomcatContainer
        Parameters:
        name - the name of the context to start
        Throws:
        Exception - if starting the context fails spectacularly
      • removeInternal

        private void removeInternal​(String name)
                             throws Exception
        Removes the internal.
        Parameters:
        name - the name
        Throws:
        Exception - the exception
      • installWar

        public void installWar​(String name,
                               URL url)
                        throws Exception
        Description copied from interface: TomcatContainer
        Installs .war file at the given context name.
        Specified by:
        installWar in interface TomcatContainer
        Parameters:
        name - the name of the context
        url - pointer to .war file to be deployed
        Throws:
        Exception - if installing the .war fails spectacularly
      • installContextInternal

        private void installContextInternal​(String name)
                                     throws Exception
        Install context internal.
        Parameters:
        name - the name
        Throws:
        Exception - the exception
      • findContext

        public org.apache.catalina.Context findContext​(String name)
        Description copied from interface: TomcatContainer
        Finds a context based on its path.
        Specified by:
        findContext in interface TomcatContainer
        Parameters:
        name - the context path
        Returns:
        the context deployed to that path
      • formatContextName

        public String formatContextName​(String name)
        Description copied from interface: TomcatContainer
        Formats a context name to a path that the container will recognize. Usually this means prepending a / character, although there is special behavior for the root context.
        Specified by:
        formatContextName in interface TomcatContainer
        Parameters:
        name - the context name
        Returns:
        the context name formatted as the container expects
      • formatContextFilename

        public String formatContextFilename​(String contextName)
        Description copied from interface: TomcatContainer
        Formats a context name so that it can be used as a step for the context descriptor .xml or deployed .war file. Usually this means stripping a leading / character, although there is special behavior for the root context.
        Specified by:
        formatContextFilename in interface TomcatContainer
        Parameters:
        contextName - the context name
        Returns:
        the filename stem for this context
      • discardWorkDir

        public void discardWorkDir​(org.apache.catalina.Context context)
        Description copied from interface: TomcatContainer
        Deletes the "work" directory of the given context.
        Specified by:
        discardWorkDir in interface TomcatContainer
        Parameters:
        context - the context
      • getServletFileNameForJsp

        public String getServletFileNameForJsp​(org.apache.catalina.Context context,
                                               String jspName)
        Description copied from interface: TomcatContainer
        Returns the JSP servlet filename for the given JSP file.
        Specified by:
        getServletFileNameForJsp in interface TomcatContainer
        Parameters:
        context - the context
        jspName - the JSP filename
        Returns:
        the name of the JSP servlet
      • recompileJsps

        public void recompileJsps​(org.apache.catalina.Context context,
                                  Summary summary,
                                  List<String> names)
        Description copied from interface: TomcatContainer
        Compiles a list of JSPs. Names of JSP files are expected to be relative to the webapp root. The method updates summary with compilation details.
        Specified by:
        recompileJsps in interface TomcatContainer
        Parameters:
        context - the context
        summary - the summary in which the output is stored
        names - the list of JSPs to compile
      • listContextJsps

        public void listContextJsps​(org.apache.catalina.Context context,
                                    Summary summary,
                                    boolean compile)
        Description copied from interface: TomcatContainer
        Lists and optionally compiles all JSPs for the given context. Compilation details are added to the summary.
        Specified by:
        listContextJsps in interface TomcatContainer
        Parameters:
        context - the context
        summary - the summary in which the output is stored
        compile - whether to compile all of the JSPs or not
      • getAvailable

        public boolean getAvailable​(org.apache.catalina.Context context)
        Description copied from interface: TomcatContainer
        Gets the available.
        Specified by:
        getAvailable in interface TomcatContainer
        Parameters:
        context - the context
        Returns:
        the available
      • getConfigFile

        public File getConfigFile​(org.apache.catalina.Context context)
        Description copied from interface: TomcatContainer
        Returns the context descriptor filename for the given context.
        Specified by:
        getConfigFile in interface TomcatContainer
        Parameters:
        context - the context
        Returns:
        the context descriptor filename, or null
      • bindToContext

        public void bindToContext​(org.apache.catalina.Context context)
                           throws NamingException
        Description copied from interface: TomcatContainer
        Binds a naming context to the current thread's classloader.
        Specified by:
        bindToContext in interface TomcatContainer
        Parameters:
        context - the catalina context
        Throws:
        NamingException - if binding the classloader fails
      • unbindFromContext

        public void unbindFromContext​(org.apache.catalina.Context context)
                               throws NamingException
        Description copied from interface: TomcatContainer
        Unbinds a naming context from the current thread's classloader.
        Specified by:
        unbindFromContext in interface TomcatContainer
        Parameters:
        context - the catalina context
        Throws:
        NamingException - if unbinding the classloader fails
      • registerGlobalResourceAccess

        protected void registerGlobalResourceAccess​(org.apache.tomcat.util.descriptor.web.ContextResourceLink resourceLink)
        Register access to global resources.
        Parameters:
        resourceLink - the resource link
      • changeContextBinding

        private void changeContextBinding​(org.apache.catalina.Context context,
                                          boolean bind)
                                   throws NamingException
        Change context binding.
        Parameters:
        context - the context
        bind - the bind
        Throws:
        NamingException - the naming exception
      • compileItem

        protected void compileItem​(String jspName,
                                   org.apache.jasper.Options opt,
                                   org.apache.catalina.Context ctx,
                                   org.apache.jasper.compiler.JspRuntimeContext jrctx,
                                   Summary summary,
                                   URLClassLoader classLoader,
                                   int level,
                                   boolean compile)
        Lists and optionally compiles a directory recursively.
        Parameters:
        jspName - name of JSP file or directory to be listed and compiled.
        opt - the JSP compiler options
        ctx - the context
        jrctx - the runtime context used to create the compilation context
        summary - the summary in which the output is stored
        classLoader - the classloader used by the compiler
        level - the depth in the tree at which the item was encountered
        compile - whether or not to compile the item or just to check whether it's out of date
      • findContextInternal

        protected org.apache.catalina.Context findContextInternal​(String name)
        Find context internal.
        Parameters:
        name - the context name
        Returns:
        the context
      • checkChanges

        protected void checkChanges​(String name)
                             throws Exception
        Check changes.
        Parameters:
        name - the name
        Throws:
        Exception - the exception
      • getNamingToken

        protected abstract Object getNamingToken​(org.apache.catalina.Context context)
        Returns the security token required to bind to a naming context.
        Parameters:
        context - the catalina context
        Returns:
        the security token for use with ContextBindings
      • createJspCompilationContext

        protected abstract org.apache.jasper.JspCompilationContext createJspCompilationContext​(String name,
                                                                                               org.apache.jasper.Options opt,
                                                                                               javax.servlet.ServletContext sctx,
                                                                                               org.apache.jasper.compiler.JspRuntimeContext jrctx,
                                                                                               ClassLoader classLoader)
        Creates the jsp compilation context.
        Parameters:
        name - the name
        opt - the opt
        sctx - the sctx
        jrctx - the jrctx
        classLoader - the class loader
        Returns:
        the jsp compilation context
      • createValve

        protected abstract org.apache.catalina.Valve createValve()
        Creates the valve.
        Returns:
        the valve
      • addFilterMapping

        protected void addFilterMapping​(String filterName,
                                        String dispatcherMap,
                                        String filterClass,
                                        String[] types,
                                        List<FilterMapping> results,
                                        AbstractTomcatContainer.FilterMapType filterMapType)
        Adds the filter mapping.
        Parameters:
        filterName - the filter name
        dispatcherMap - the dispatcher map
        filterClass - the filter class
        types - the types as urls or servlet name
        results - the results
        filterMapType - the filter map type