org.glassfish.deployment.common
Class DeploymentContextImpl

java.lang.Object
  extended by org.glassfish.deployment.common.DeploymentContextImpl
All Implemented Interfaces:
ApplicationContext, DeploymentContext, ExecutionContext, ExtendedDeploymentContext, org.jvnet.hk2.component.PreDestroy

public class DeploymentContextImpl
extends Object
implements ExtendedDeploymentContext, org.jvnet.hk2.component.PreDestroy

Author:
dochez

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.glassfish.internal.deployment.ExtendedDeploymentContext
ExtendedDeploymentContext.Phase
 
Field Summary
 
Fields inherited from interface org.glassfish.internal.deployment.ExtendedDeploymentContext
IS_TEMP_CLASSLOADER, TRACKER
 
Constructor Summary
DeploymentContextImpl(ActionReport actionReport, Logger logger, ReadableArchive source, OpsParams params, ServerEnvironment env)
           
DeploymentContextImpl(Deployment.DeploymentContextBuilder builder, ServerEnvironment env)
          Creates a new instance of DeploymentContext
 
Method Summary
 void addModuleMetaData(Object metaData)
           
 void addTransformer(ClassFileTransformer transformer)
          Add a new ClassFileTransformer to the context
 void addTransientAppMetaData(String metaDataKey, Object metaData)
           
 void clean()
           
 void createApplicationClassLoader(ClassLoaderHierarchy clh, ArchiveHandler handler)
           
 void createDeploymentClassLoader(ClassLoaderHierarchy clh, ArchiveHandler handler)
           
 ActionReport getActionReport()
          Gets the action report for this context
 File getAppInternalDir()
           
 List<URI> getAppLibs()
           
 Properties getAppProps()
          Returns the application level properties that will be persisted as a key value pair at then end of deployment.
 ArchiveHandler getArchiveHandler()
           
 ClassLoader getClassLoader()
          Returns the class loader associated to this deployment request.
 ClassLoader getClassLoader(boolean sharable)
           
<U extends OpsParams>
U
getCommandParameters(Class<U> commandParametersType)
           
 ClassLoader getFinalClassLoader()
          Returns the class loader associated to this deployment request.
 Logger getLogger()
           
 Map<String,ArchiveHandler> getModuleArchiveHandlers()
          Gets the archive handlers for modules
 Map<String,ExtendedDeploymentContext> getModuleDeploymentContexts()
          Gets the deployment context for modules
 Collection<Object> getModuleMetadata()
           
<T> T
getModuleMetaData(Class<T> metadataType)
           
 Properties getModuleProps()
          Returns the module level properties that will be persisted as a key value pair at then end of deployment.
 Map<String,Properties> getModulePropsMap()
          Gets the module properties for modules
 String getModuleUri()
          Gets the module uri for this module context
 ReadableArchive getOriginalSource()
           
 ExtendedDeploymentContext getParentContext()
          Gets the parent context of the module
 ExtendedDeploymentContext.Phase getPhase()
           
 File getScratchDir(String subDirName)
          Returns a scratch directory that can be used to store things in.
 ReadableArchive getSource()
           
 File getSourceDir()
          
 List<ClassFileTransformer> getTransformers()
          Returns the list of transformers registered to this context.
 Map<String,Object> getTransientAppMetadata()
           
<T> T
getTransientAppMetaData(String key, Class<T> metadataType)
           
 void postDeployClean(boolean isFinalClean)
           
 void preDestroy()
           
 void prepareScratchDirs()
          Prepare the scratch directories, creating the directories if they do not exist
 void setArchiveHandler(ArchiveHandler archiveHandler)
           
 void setClassLoader(ClassLoader cloader)
           
 void setModulePropsMap(Map<String,Properties> modulePropsMap)
          Sets the module properties for modules
 void setModuleUri(String moduleUri)
          Sets the module uri for this module context
 void setParentContext(ExtendedDeploymentContext parentContext)
          Sets the parent context for the module
 void setPhase(ExtendedDeploymentContext.Phase newPhase)
           
 void setSource(ReadableArchive source)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DeploymentContextImpl

public DeploymentContextImpl(Deployment.DeploymentContextBuilder builder,
                             ServerEnvironment env)
Creates a new instance of DeploymentContext


DeploymentContextImpl

public DeploymentContextImpl(ActionReport actionReport,
                             Logger logger,
                             ReadableArchive source,
                             OpsParams params,
                             ServerEnvironment env)
Method Detail

getPhase

public ExtendedDeploymentContext.Phase getPhase()
Specified by:
getPhase in interface ExtendedDeploymentContext

setPhase

public void setPhase(ExtendedDeploymentContext.Phase newPhase)
Specified by:
setPhase in interface ExtendedDeploymentContext

getSource

public ReadableArchive getSource()
Specified by:
getSource in interface DeploymentContext

setSource

public void setSource(ReadableArchive source)
Specified by:
setSource in interface ExtendedDeploymentContext

getCommandParameters

public <U extends OpsParams> U getCommandParameters(Class<U> commandParametersType)
Specified by:
getCommandParameters in interface DeploymentContext

getLogger

public Logger getLogger()
Specified by:
getLogger in interface ExecutionContext

preDestroy

public void preDestroy()
Specified by:
preDestroy in interface org.jvnet.hk2.component.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 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 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 ExtendedDeploymentContext

createDeploymentClassLoader

public void createDeploymentClassLoader(ClassLoaderHierarchy clh,
                                        ArchiveHandler handler)
                                 throws URISyntaxException,
                                        MalformedURLException
Specified by:
createDeploymentClassLoader in interface ExtendedDeploymentContext
Throws:
URISyntaxException
MalformedURLException

createApplicationClassLoader

public void createApplicationClassLoader(ClassLoaderHierarchy clh,
                                         ArchiveHandler handler)
                                  throws URISyntaxException,
                                         MalformedURLException
Specified by:
createApplicationClassLoader in interface 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 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 DeploymentContext

addModuleMetaData

public void addModuleMetaData(Object metaData)
Specified by:
addModuleMetaData in interface DeploymentContext

getModuleMetaData

public <T> T getModuleMetaData(Class<T> metadataType)
Specified by:
getModuleMetaData in interface DeploymentContext

getModuleMetadata

public Collection<Object> getModuleMetadata()
Specified by:
getModuleMetadata in interface DeploymentContext

getTransientAppMetadata

public Map<String,Object> getTransientAppMetadata()
Specified by:
getTransientAppMetadata in interface DeploymentContext

addTransientAppMetaData

public void addTransientAppMetaData(String metaDataKey,
                                    Object metaData)
Specified by:
addTransientAppMetaData in interface DeploymentContext

getTransientAppMetaData

public <T> T getTransientAppMetaData(String key,
                                     Class<T> metadataType)
Specified by:
getTransientAppMetaData in interface 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 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 ApplicationContext
Returns:
the module's properties.

addTransformer

public void addTransformer(ClassFileTransformer transformer)
Add a new ClassFileTransformer to the context

Specified by:
addTransformer in interface 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 ExtendedDeploymentContext
Returns:
the transformers list

getAppLibs

public List<URI> getAppLibs()
                     throws URISyntaxException
Specified by:
getAppLibs in interface DeploymentContext
Throws:
URISyntaxException

clean

public void clean()
Specified by:
clean in interface ExtendedDeploymentContext

getArchiveHandler

public ArchiveHandler getArchiveHandler()
Specified by:
getArchiveHandler in interface DeploymentContext

setArchiveHandler

public void setArchiveHandler(ArchiveHandler archiveHandler)
Specified by:
setArchiveHandler in interface ExtendedDeploymentContext

getOriginalSource

public ReadableArchive getOriginalSource()
Specified by:
getOriginalSource in interface DeploymentContext

getModulePropsMap

public Map<String,Properties> getModulePropsMap()
Gets the module properties for modules

Specified by:
getModulePropsMap in interface 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 ExtendedDeploymentContext
Parameters:
modulePropsMap -

setParentContext

public void setParentContext(ExtendedDeploymentContext parentContext)
Sets the parent context for the module

Specified by:
setParentContext in interface ExtendedDeploymentContext
Parameters:
parentContext -

getParentContext

public ExtendedDeploymentContext getParentContext()
Gets the parent context of the module

Specified by:
getParentContext in interface ExtendedDeploymentContext
Returns:
the parent context

getModuleUri

public String getModuleUri()
Gets the module uri for this module context

Specified by:
getModuleUri in interface ExtendedDeploymentContext
Returns:
the module uri

setModuleUri

public void setModuleUri(String moduleUri)
Sets the module uri for this module context

Specified by:
setModuleUri in interface ExtendedDeploymentContext
Parameters:
moduleUri -

getModuleArchiveHandlers

public Map<String,ArchiveHandler> getModuleArchiveHandlers()
Gets the archive handlers for modules

Specified by:
getModuleArchiveHandlers in interface DeploymentContext
Returns:
a map containing module archive handlers

getModuleDeploymentContexts

public Map<String,ExtendedDeploymentContext> getModuleDeploymentContexts()
Gets the deployment context for modules

Specified by:
getModuleDeploymentContexts in interface ExtendedDeploymentContext
Returns:
a map containing module deployment contexts

getActionReport

public ActionReport getActionReport()
Gets the action report for this context

Specified by:
getActionReport in interface DeploymentContext
Returns:
an action report

getAppInternalDir

public File getAppInternalDir()
Specified by:
getAppInternalDir in interface ExtendedDeploymentContext

postDeployClean

public void postDeployClean(boolean isFinalClean)
Specified by:
postDeployClean in interface ExtendedDeploymentContext

prepareScratchDirs

public void prepareScratchDirs()
                        throws IOException
Prepare the scratch directories, creating the directories if they do not exist

Specified by:
prepareScratchDirs in interface ExtendedDeploymentContext
Throws:
IOException


Copyright © 2012 GlassFish Community. All Rights Reserved.