Class GenericSniffer

java.lang.Object
org.glassfish.internal.deployment.GenericSniffer
All Implemented Interfaces:
org.glassfish.api.container.Sniffer

public abstract class GenericSniffer extends Object implements org.glassfish.api.container.Sniffer
Generic implementation of the Sniffer service that can be programmatically instantiated
Author:
Jerome Dochez, Sanjeeb Sahoo
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected org.glassfish.hk2.api.ServiceLocator
     
    protected com.sun.enterprise.module.ModulesRegistry
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    GenericSniffer(String containerName, String appStigma, String urlPattern)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    equals(Object other)
     
    getAnnotationNames(org.glassfish.api.deployment.DeploymentContext context)
    Returns the list of annotation names that this sniffer is interested in.
    Class<? extends Annotation>[]
    Returns the list of annotations types that this sniffer is interested in.
    protected String[]
     
    protected List<String>
    Returns a list of paths within an archive that represents deployment configuration files.
    getDeploymentConfigurations(org.glassfish.api.deployment.archive.ReadableArchive location)
    Returns a map of deployment configurations composed by reading from a list of paths in the readable archive.
     
    Returns the container name associated with this sniffer.
    Returns the pattern to apply against the request URL If the pattern matches the URL, the service method of the associated container will be invoked
    boolean
    handles(org.glassfish.api.deployment.archive.ReadableArchive location)
    Returns true if the passed file or directory is recognized by this instance.
    boolean
    handles(org.glassfish.api.deployment.DeploymentContext context)
    Returns true if the passed file or directory is recognized by this composite sniffer.
    int
     
    boolean
     
    boolean
     
    com.sun.enterprise.module.HK2Module[]
    setup(String containerHome, Logger logger)
    Sets up the container libraries so that any imported bundle from the connector jar file will now be known to the module subsystem This method returns a ModuleDefinition for the module containing the core implementation of the container.
    void
    Tears down a container, remove all imported libraries from the module subsystem.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.glassfish.api.container.Sniffer

    getContainersNames, supportsArchiveType
  • Field Details

    • modulesRegistry

      @Inject protected com.sun.enterprise.module.ModulesRegistry modulesRegistry
    • habitat

      @Inject protected org.glassfish.hk2.api.ServiceLocator habitat
  • Constructor Details

    • GenericSniffer

      public GenericSniffer(String containerName, String appStigma, String urlPattern)
  • Method Details

    • handles

      public boolean handles(org.glassfish.api.deployment.DeploymentContext context)
      Returns true if the passed file or directory is recognized by this composite sniffer.
      Specified by:
      handles in interface org.glassfish.api.container.Sniffer
      Parameters:
      context - deployment context
      Returns:
      true if the location is recognized by this sniffer
    • getAnnotationNames

      public String[] getAnnotationNames(org.glassfish.api.deployment.DeploymentContext context)
      Returns the list of annotation names that this sniffer is interested in. If an application bundle contains at least one class annotated with one of the returned annotations, the deployment process will not call the handles method but will invoke the containers deployers as if the handles method had been called and returned true.
      Specified by:
      getAnnotationNames in interface org.glassfish.api.container.Sniffer
      Parameters:
      context - deployment context
      Returns:
      list of annotations this sniffer is interested in or an empty array
    • handles

      public boolean handles(org.glassfish.api.deployment.archive.ReadableArchive location)
      Returns true if the passed file or directory is recognized by this instance.
      Specified by:
      handles in interface org.glassfish.api.container.Sniffer
      Parameters:
      location - the file or directory to explore
      Returns:
      true if this sniffer handles this application type
    • getURLPatterns

      public String[] getURLPatterns()
      Returns the pattern to apply against the request URL If the pattern matches the URL, the service method of the associated container will be invoked
      Specified by:
      getURLPatterns in interface org.glassfish.api.container.Sniffer
      Returns:
      pattern instance
    • getModuleType

      public String getModuleType()
      Returns the container name associated with this sniffer.

      WARNING: This is different from ArchiveType!

      Specified by:
      getModuleType in interface org.glassfish.api.container.Sniffer
      Returns:
      the container name
    • setup

      public com.sun.enterprise.module.HK2Module[] setup(String containerHome, Logger logger) throws IOException
      Sets up the container libraries so that any imported bundle from the connector jar file will now be known to the module subsystem This method returns a ModuleDefinition for the module containing the core implementation of the container. That means that this module will be locked as long as there is at least one module loaded in the associated container.
      Specified by:
      setup in interface org.glassfish.api.container.Sniffer
      Parameters:
      containerHome - is where the container implementation resides (Not used anymore)
      logger - the logger to use
      Returns:
      the module definition of the core container implementation.
      Throws:
      IOException - exception if something goes sour
    • getContainerModuleNames

      protected String[] getContainerModuleNames()
    • tearDown

      public void tearDown()
      Tears down a container, remove all imported libraries from the module subsystem.
      Specified by:
      tearDown in interface org.glassfish.api.container.Sniffer
    • getAnnotationTypes

      public Class<? extends Annotation>[] getAnnotationTypes()
      Returns the list of annotations types that this sniffer is interested in. If an application bundle contains at least one class annotated with one of the returned annotations, the deployment process will not call the handles method but will invoke the containers deployers as if the handles method had been called and returned true.
      Specified by:
      getAnnotationTypes in interface org.glassfish.api.container.Sniffer
      Returns:
      list of annotations this sniffer is interested in.
    • isUserVisible

      public boolean isUserVisible()
      Specified by:
      isUserVisible in interface org.glassfish.api.container.Sniffer
      Returns:
      false
    • isJakartaEE

      public boolean isJakartaEE()
      Specified by:
      isJakartaEE in interface org.glassfish.api.container.Sniffer
      Returns:
      false
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getDeploymentConfigurations

      public Map<String,String> getDeploymentConfigurations(org.glassfish.api.deployment.archive.ReadableArchive location) throws IOException
      Returns a map of deployment configurations composed by reading from a list of paths in the readable archive. (For Jakarta EE applications the deployment configurations correspond to the deployment descriptors.) The getDeploymentConfigurationPaths() method returns this list of paths which might exist in archives that this sniffer handles.

      In each returned map entry the key is a path and the value is the contents of the archive entry at that path. This method creates a map entry only if the path exists in the readable archive.

      Sniffers for applications that do not store their configurations as deployment descriptors at predictable paths within an archive are free to override this implementation to return whatever information is appropriate to that application type. A key usage of the returned Map is in the application type's GUI plug-in (if desired) to allow users to customize the deployment configuration after the application has been deployed. The concrete Sniffer implementation and the GUI plug-in must agree on the conventions for storing deployment configuration inforation in the Map.

      Specified by:
      getDeploymentConfigurations in interface org.glassfish.api.container.Sniffer
      Parameters:
      location - the readable archive for the application of interest
      Returns:
      a map from path names to the contents of the archive entries at those paths
      Throws:
      IOException - in case of errors retrieving an entry or reading the archive contents at an entry
    • getDeploymentConfigurationPaths

      protected List<String> getDeploymentConfigurationPaths()
      Returns a list of paths within an archive that represents deployment configuration files.

      Sniffers that recognize Jakarta EE applications typically override this default implementation to return a list of the deployment descriptors that might appear in the type of Jakarta EE application which the sniffer recognizes. For example, the WebSniffer implementation of this method returns WEB-INF/web.xml, WEB-INF/glassfish-web.xml and WEB-INF/sun-web.xml.

      Returns:
      list of paths in the archive where deployment configuration archive entries might exist
    • getIncompatibleSnifferTypes

      public String[] getIncompatibleSnifferTypes()
      Specified by:
      getIncompatibleSnifferTypes in interface org.glassfish.api.container.Sniffer
      Returns:
      the set of the sniffers that should not co-exist for the same module. For example, ejb and appclient sniffers should not be returned in the sniffer list for a certain module. This method will be used to validate and filter the retrieved sniffer lists for a certain module