Class DeploymentContextImpl

  • All Implemented Interfaces:
    org.glassfish.api.deployment.ApplicationContext, org.glassfish.api.deployment.DeploymentContext, org.glassfish.api.ExecutionContext, org.glassfish.hk2.api.PreDestroy, org.glassfish.internal.deployment.ExtendedDeploymentContext

    public class DeploymentContextImpl
    extends Object
    implements org.glassfish.internal.deployment.ExtendedDeploymentContext, org.glassfish.hk2.api.PreDestroy
    Author:
    dochez
    • Field Detail

      • deplLogger

        public static final Logger deplLogger
    • Constructor Detail

      • DeploymentContextImpl

        public DeploymentContextImpl​(org.glassfish.internal.deployment.Deployment.DeploymentContextBuilder builder,
                                     org.glassfish.api.admin.ServerEnvironment env)
        Creates a new instance of DeploymentContext
      • DeploymentContextImpl

        public DeploymentContextImpl​(org.glassfish.api.ActionReport actionReport,
                                     Logger logger,
                                     org.glassfish.api.deployment.archive.ReadableArchive source,
                                     org.glassfish.api.deployment.OpsParams params,
                                     org.glassfish.api.admin.ServerEnvironment env)
      • DeploymentContextImpl

        public DeploymentContextImpl​(org.glassfish.api.ActionReport actionReport,
                                     org.glassfish.api.deployment.archive.ReadableArchive source,
                                     org.glassfish.api.deployment.OpsParams params,
                                     org.glassfish.api.admin.ServerEnvironment env)
    • Method Detail

      • getPhase

        public org.glassfish.internal.deployment.ExtendedDeploymentContext.Phase getPhase()
        Specified by:
        getPhase in interface org.glassfish.internal.deployment.ExtendedDeploymentContext
      • setPhase

        public void setPhase​(org.glassfish.internal.deployment.ExtendedDeploymentContext.Phase newPhase)
        Specified by:
        setPhase in interface org.glassfish.internal.deployment.ExtendedDeploymentContext
      • getSource

        public org.glassfish.api.deployment.archive.ReadableArchive getSource()
        Specified by:
        getSource in interface org.glassfish.api.deployment.DeploymentContext
      • setSource

        public void setSource​(org.glassfish.api.deployment.archive.ReadableArchive source)
        Specified by:
        setSource in interface org.glassfish.internal.deployment.ExtendedDeploymentContext
      • getCommandParameters

        public <U extends org.glassfish.api.deployment.OpsParams> U getCommandParameters​(Class<U> commandParametersType)
        Specified by:
        getCommandParameters in interface org.glassfish.api.deployment.DeploymentContext
      • getLogger

        public Logger getLogger()
        Specified by:
        getLogger in interface org.glassfish.api.ExecutionContext
      • preDestroy

        public void preDestroy()
        Specified by:
        preDestroy in interface org.glassfish.hk2.api.PreDestroy
      • getFinalClassLoader

        public ClassLoader getFinalClassLoader()
        Returns the class loader associated to this deployment request. ClassLoader instances are usually obtained by the getClassLoader API on the associated ArchiveHandler for the archive type being deployed.

        This can return null and the container should allocate a ClassLoader while loading the application.

        Specified by:
        getFinalClassLoader in interface org.glassfish.api.deployment.DeploymentContext
        Returns:
        a class loader capable of loading classes and resources from the source
      • getClassLoader

        public ClassLoader getClassLoader()
        Returns the class loader associated to this deployment request. ClassLoader instances are usually obtained by the getClassLoader API on the associated ArchiveHandler for the archive type being deployed.

        This can return null and the container should allocate a ClassLoader while loading the application.

        Specified by:
        getClassLoader in interface org.glassfish.api.deployment.ApplicationContext
        Returns:
        a class loader capable of loading classes and resources from the source
      • setClassLoader

        public void setClassLoader​(ClassLoader cloader)
        Specified by:
        setClassLoader in interface org.glassfish.internal.deployment.ExtendedDeploymentContext
      • createDeploymentClassLoader

        public void createDeploymentClassLoader​(org.glassfish.internal.api.ClassLoaderHierarchy clh,
                                                org.glassfish.api.deployment.archive.ArchiveHandler handler)
                                         throws URISyntaxException,
                                                MalformedURLException
        Specified by:
        createDeploymentClassLoader in interface org.glassfish.internal.deployment.ExtendedDeploymentContext
        Throws:
        URISyntaxException
        MalformedURLException
      • createApplicationClassLoader

        public void createApplicationClassLoader​(org.glassfish.internal.api.ClassLoaderHierarchy clh,
                                                 org.glassfish.api.deployment.archive.ArchiveHandler handler)
                                          throws URISyntaxException,
                                                 MalformedURLException
        Specified by:
        createApplicationClassLoader in interface org.glassfish.internal.deployment.ExtendedDeploymentContext
        Throws:
        URISyntaxException
        MalformedURLException
      • getClassLoader

        public ClassLoader getClassLoader​(boolean sharable)
      • getScratchDir

        public File getScratchDir​(String subDirName)
        Returns a scratch directory that can be used to store things in. The scratch directory will be persisted accross server restart but not accross redeployment of the same application
        Specified by:
        getScratchDir in interface org.glassfish.api.deployment.DeploymentContext
        Parameters:
        subDirName - the sub directory name of the scratch dir
        Returns:
        the scratch directory for this application based on passed in subDirName. Returns the root scratch dir if the passed in value is null.
      • getSourceDir

        public File getSourceDir()
        Specified by:
        getSourceDir in interface org.glassfish.api.deployment.DeploymentContext
      • addModuleMetaData

        public void addModuleMetaData​(Object metaData)
        Specified by:
        addModuleMetaData in interface org.glassfish.api.deployment.DeploymentContext
      • getModuleMetaData

        public <T> T getModuleMetaData​(Class<T> metadataType)
        Specified by:
        getModuleMetaData in interface org.glassfish.api.deployment.DeploymentContext
      • getModuleMetadata

        public Collection<Object> getModuleMetadata()
        Specified by:
        getModuleMetadata in interface org.glassfish.api.deployment.DeploymentContext
      • getTransientAppMetadata

        public Map<String,​Object> getTransientAppMetadata()
        Specified by:
        getTransientAppMetadata in interface org.glassfish.api.deployment.DeploymentContext
      • addTransientAppMetaData

        public void addTransientAppMetaData​(String metaDataKey,
                                            Object metaData)
        Specified by:
        addTransientAppMetaData in interface org.glassfish.api.deployment.DeploymentContext
      • getTransientAppMetaData

        public <T> T getTransientAppMetaData​(String key,
                                             Class<T> metadataType)
        Specified by:
        getTransientAppMetaData in interface org.glassfish.api.deployment.DeploymentContext
      • getAppProps

        public Properties getAppProps()
        Returns the application level properties that will be persisted as a key value pair at then end of deployment. That allows individual Deployers implementation to store some information at the application level that should be available upon server restart. Application level propertries are shared by all the modules.
        Specified by:
        getAppProps in interface org.glassfish.api.deployment.ApplicationContext
        Returns:
        the application's properties.
      • getModuleProps

        public Properties getModuleProps()
        Returns the module level properties that will be persisted as a key value pair at then end of deployment. That allows individual Deployers implementation to store some information at the module level that should be available upon server restart. Module level properties are only visible to the current module.
        Specified by:
        getModuleProps in interface org.glassfish.api.deployment.ApplicationContext
        Returns:
        the module's properties.
      • addTransformer

        public void addTransformer​(ClassFileTransformer transformer)
        Add a new ClassFileTransformer to the context
        Specified by:
        addTransformer in interface org.glassfish.api.deployment.DeploymentContext
        Parameters:
        transformer - the new class file transformer to register to the new application class loader
        Throws:
        UnsupportedOperationException - if the class loader we use does not support the registration of a ClassFileTransformer. In such case, the deployer should either fail deployment or revert to a mode without the byteocode enhancement feature.
      • getTransformers

        public List<ClassFileTransformer> getTransformers()
        Returns the list of transformers registered to this context.
        Specified by:
        getTransformers in interface org.glassfish.internal.deployment.ExtendedDeploymentContext
        Returns:
        the transformers list
      • clean

        public void clean()
        Specified by:
        clean in interface org.glassfish.internal.deployment.ExtendedDeploymentContext
      • getArchiveHandler

        public org.glassfish.api.deployment.archive.ArchiveHandler getArchiveHandler()
        Specified by:
        getArchiveHandler in interface org.glassfish.api.deployment.DeploymentContext
      • setArchiveHandler

        public void setArchiveHandler​(org.glassfish.api.deployment.archive.ArchiveHandler archiveHandler)
        Specified by:
        setArchiveHandler in interface org.glassfish.internal.deployment.ExtendedDeploymentContext
      • getOriginalSource

        public org.glassfish.api.deployment.archive.ReadableArchive getOriginalSource()
        Specified by:
        getOriginalSource in interface org.glassfish.api.deployment.DeploymentContext
      • getModulePropsMap

        public Map<String,​Properties> getModulePropsMap()
        Gets the module properties for modules
        Specified by:
        getModulePropsMap in interface org.glassfish.api.deployment.DeploymentContext
        Returns:
        a map containing module properties
      • setModulePropsMap

        public void setModulePropsMap​(Map<String,​Properties> modulePropsMap)
        Sets the module properties for modules
        Specified by:
        setModulePropsMap in interface org.glassfish.internal.deployment.ExtendedDeploymentContext
        Parameters:
        modulePropsMap -
      • setParentContext

        public void setParentContext​(org.glassfish.internal.deployment.ExtendedDeploymentContext parentContext)
        Sets the parent context for the module
        Specified by:
        setParentContext in interface org.glassfish.internal.deployment.ExtendedDeploymentContext
        Parameters:
        parentContext -
      • getParentContext

        public org.glassfish.internal.deployment.ExtendedDeploymentContext getParentContext()
        Gets the parent context of the module
        Specified by:
        getParentContext in interface org.glassfish.internal.deployment.ExtendedDeploymentContext
        Returns:
        the parent context
      • getModuleUri

        public String getModuleUri()
        Gets the module uri for this module context
        Specified by:
        getModuleUri in interface org.glassfish.internal.deployment.ExtendedDeploymentContext
        Returns:
        the module uri
      • setModuleUri

        public void setModuleUri​(String moduleUri)
        Sets the module uri for this module context
        Specified by:
        setModuleUri in interface org.glassfish.internal.deployment.ExtendedDeploymentContext
        Parameters:
        moduleUri -
      • getModuleArchiveHandlers

        public Map<String,​org.glassfish.api.deployment.archive.ArchiveHandler> getModuleArchiveHandlers()
        Gets the archive handlers for modules
        Specified by:
        getModuleArchiveHandlers in interface org.glassfish.api.deployment.DeploymentContext
        Returns:
        a map containing module archive handlers
      • getModuleDeploymentContexts

        public Map<String,​org.glassfish.internal.deployment.ExtendedDeploymentContext> getModuleDeploymentContexts()
        Gets the deployment context for modules
        Specified by:
        getModuleDeploymentContexts in interface org.glassfish.internal.deployment.ExtendedDeploymentContext
        Returns:
        a map containing module deployment contexts
      • getActionReport

        public org.glassfish.api.ActionReport getActionReport()
        Gets the action report for this context
        Specified by:
        getActionReport in interface org.glassfish.api.deployment.DeploymentContext
        Returns:
        an action report
      • getAppInternalDir

        public File getAppInternalDir()
        Specified by:
        getAppInternalDir in interface org.glassfish.internal.deployment.ExtendedDeploymentContext
      • getAppAltDDDir

        public File getAppAltDDDir()
        Specified by:
        getAppAltDDDir in interface org.glassfish.internal.deployment.ExtendedDeploymentContext
      • setTenant

        public void setTenant​(String tenant,
                              String appName)
        Specified by:
        setTenant in interface org.glassfish.internal.deployment.ExtendedDeploymentContext
      • getTenant

        public String getTenant()
        Specified by:
        getTenant in interface org.glassfish.internal.deployment.ExtendedDeploymentContext
      • getTenantDir

        public File getTenantDir()
        Specified by:
        getTenantDir in interface org.glassfish.internal.deployment.ExtendedDeploymentContext
      • postDeployClean

        public void postDeployClean​(boolean isFinalClean)
        Specified by:
        postDeployClean in interface org.glassfish.internal.deployment.ExtendedDeploymentContext
      • prepareScratchDirs

        public void prepareScratchDirs()
                                throws IOException
        Prepare the scratch directories, creating the directories if they do not exist
        Specified by:
        prepareScratchDirs in interface org.glassfish.internal.deployment.ExtendedDeploymentContext
        Throws:
        IOException