Class JettyPlugin


  • @Plugin(name="Jetty",
            description="Jetty plugin.",
            testedVersions={"6.1.26","7.6.14","8.1.14","9.1.2"},
            expectedVersions={"4x","5x","6x","7x","8x","9x"})
    public class JettyPlugin
    extends Object
    Jetty servlet container support.

    Plugin

    • Configure webapp classloader before first servlet is loaded
    • webappDir configuration property
    • extraClasspath configuration property (handled by WatchResourcesPlugin)
    • watchResources configuration property (handled by WatchResourcesPlugin)
    Author:
    Jiri Bubnik
    • Constructor Detail

      • JettyPlugin

        public JettyPlugin()
    • Method Detail

      • patchWebXmlConfiguration

        @OnClassLoadEvent(classNameRegexp="org.eclipse.jetty.webapp.WebXmlConfiguration")
        public static void patchWebXmlConfiguration​(org.hotswap.agent.javassist.CtClass ctClass)
                                             throws org.hotswap.agent.javassist.NotFoundException,
                                                    org.hotswap.agent.javassist.CannotCompileException,
                                                    ClassNotFoundException
        Plugin initialization step needs to be fine tuned. It can be intialized only AFTER the classloader already knows about hotswap-agent.properties file (i.e. after webapp basic path is added to the classloader), but BEFORE first servlet is initialized. WebXmlConfiguration seems to be good place which should work in most setups. The plugin is intialized before web.xml file is processed - basic paths should be known, but nothing is processed yet. Application classloader is processed during plugin initialization. It means that other plugins triggered on plugin init should fire as well - for jetty is important core watchResources plugin, which will handle extraClassPath and watchResources configuration properties (jetty fortunately depends only on basic URLClassLoader behaviour which is handled by that plugin).
        Throws:
        org.hotswap.agent.javassist.NotFoundException
        org.hotswap.agent.javassist.CannotCompileException
        ClassNotFoundException
      • patchWebXmlConfiguration6x

        @OnClassLoadEvent(classNameRegexp="org.mortbay.jetty.webapp.WebXmlConfiguration")
        public static void patchWebXmlConfiguration6x​(org.hotswap.agent.javassist.CtClass ctClass)
                                               throws org.hotswap.agent.javassist.NotFoundException,
                                                      org.hotswap.agent.javassist.CannotCompileException,
                                                      ClassNotFoundException
        Throws:
        org.hotswap.agent.javassist.NotFoundException
        org.hotswap.agent.javassist.CannotCompileException
        ClassNotFoundException
      • patchContextHandler6x

        @OnClassLoadEvent(classNameRegexp="(org.mortbay.jetty.webapp.WebAppContext)|(org.eclipse.jetty.webapp.WebAppContext)")
        public static void patchContextHandler6x​(org.hotswap.agent.javassist.CtClass ctClass)
                                          throws org.hotswap.agent.javassist.NotFoundException,
                                                 org.hotswap.agent.javassist.CannotCompileException,
                                                 ClassNotFoundException
        Before app context is stopped, clean the classloader (and associated plugin instance).
        Throws:
        org.hotswap.agent.javassist.NotFoundException
        org.hotswap.agent.javassist.CannotCompileException
        ClassNotFoundException
      • init

        public void init​(Object contextHandler)
        Actual plugin initialization write plugin info and handle webappDir property. If the webappDir property is set, call:
              contextHandler.setBaseResource(new ResourceCollection(
                  new FileResource(webappDir),
                  contextHandler.getBaseResource()
              ));
        
        Parameters:
        contextHandler - instance of ContextHandler - main jetty class for webapp.