org.glassfish.deployment.common
Class DeploymentUtils

java.lang.Object
  extended by org.glassfish.deployment.common.DeploymentUtils

public class DeploymentUtils
extends Object

Utility methods for deployment.


Field Summary
static String DAS_TARGET_NAME
           
static String DEPLOYMENT_PROPERTY_JAVA_WEB_START_ENABLED
           
static String DOMAIN_TARGET_NAME
           
 
Constructor Summary
DeploymentUtils()
           
 
Method Summary
static ArchiveType carType()
           
static long checksum(File directory)
          Computes the checksum of the URIs of files contained in a directory.
static Artifacts downloadableArtifacts(Application app)
          Returns the downloadable artifacts object derived from the properties saved with the specified Application
static Artifacts downloadableArtifacts(DeploymentContext dc)
          Returns the downloadable artifacts object from the specified deployment context, creating it there if it does not already exist.
static ArchiveType earType()
           
static ArchiveType ejbType()
           
static Artifacts generatedArtifacts(Application app)
          Returns the generated artifacts object derived from the properties saved with the specified Application
static Artifacts generatedArtifacts(DeploymentContext dc)
          Returns the generated artifacts object from the specified deployment context, creating it there if it does not already exist.
static String getDefaultEEName(String pathName)
           
static String getEmbeddedModulePath(String appRootPath, String moduleUri)
          This method returns the file path of an embedded module.
static List<URI> getExternalLibraries(ReadableArchive archive)
           
static List<URL> getManifestLibraries(DeploymentContext context)
           
static List<URL> getManifestLibraries(DeploymentContext context, Manifest manifest)
           
static List<URL> getManifestLibraries(ReadableArchive archive)
           
static List<URL> getModuleLibraryJars(DeploymentContext context)
           
static ArchiveType getModuleType(String moduleType)
          Utility method to retrieve a ArchiveType from a stringified module type.
static String getRelativeEmbeddedModulePath(String appRootPath, String moduleUri)
          This method returns the relative file path of an embedded module to the application root.
static boolean hasResourcesXML(ReadableArchive archive)
           
static boolean isArchiveOfType(ArchiveHandler ah, ArchiveType moduleType)
          Return true the current module (aka archive) being deployed is of given module type, else false.
static boolean isCAR(ReadableArchive archive)
          check whether the archive is an appclient archive
static boolean isDASTarget(String targetName)
           
static boolean isDomainTarget(String targetName)
           
static boolean isEAR(ReadableArchive archive)
          check whether the archive is a .ear
static boolean isEjbJar(ReadableArchive archive, org.jvnet.hk2.component.Habitat habitat)
          check whether the archive is an ejb archive
static boolean isRAR(ReadableArchive archive)
          check whether the archive is a .rar
static boolean isRAR(ReadableArchive archive, org.jvnet.hk2.component.Habitat habitat)
          check whether the archive is a .rar, it also scans annotations
static boolean isWebArchive(ReadableArchive archive)
           
static FileArchive openAsFileArchive(File dir, ArchiveFactory archiveFactory)
          Opens the specified file as an archive, using the provided archive factory.
static String propertiesValue(Properties props, char sep)
           
static ArchiveType rarType()
           
static String relativizeWithinDomainIfPossible(URI absURI)
           
static boolean useV2Compatibility(DeploymentContext context)
           
static void validateApplicationName(String name)
           
static ArchiveType warType()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEPLOYMENT_PROPERTY_JAVA_WEB_START_ENABLED

public static final String DEPLOYMENT_PROPERTY_JAVA_WEB_START_ENABLED
See Also:
Constant Field Values

DAS_TARGET_NAME

public static final String DAS_TARGET_NAME
See Also:
Constant Field Values

DOMAIN_TARGET_NAME

public static final String DOMAIN_TARGET_NAME
See Also:
Constant Field Values
Constructor Detail

DeploymentUtils

public DeploymentUtils()
Method Detail

earType

public static ArchiveType earType()

ejbType

public static ArchiveType ejbType()

carType

public static ArchiveType carType()

warType

public static ArchiveType warType()

rarType

public static ArchiveType rarType()

getModuleType

public static ArchiveType getModuleType(String moduleType)
Utility method to retrieve a ArchiveType from a stringified module type. Since ArchiveType is an extensible abstraction and implementations are plugged in via HK2 service registry, this method returns null if HK2 service registry is not setup. If null is passed to this method, it returns null instead of returning an arbitrary ArchiveType or throwing an exception.

Parameters:
moduleType - String equivalent of the module type being looked up. null is allowed.
Returns:
the corresponding ArchiveType, null if no such module type exists or HK2 Service registry is not set up

isDASTarget

public static boolean isDASTarget(String targetName)

isDomainTarget

public static boolean isDomainTarget(String targetName)

checksum

public static long checksum(File directory)
Computes the checksum of the URIs of files contained in a directory.

Parameters:
directory - the directory for which to compute a checksum
Returns:
checksum calculated from URIs of files in the directory

downloadableArtifacts

public static Artifacts downloadableArtifacts(DeploymentContext dc)
Returns the downloadable artifacts object from the specified deployment context, creating it there if it does not already exist.

Parameters:
dc - the deployment context from which to fetch the downloadable Artifacts object
Returns:

downloadableArtifacts

public static Artifacts downloadableArtifacts(Application app)
Returns the downloadable artifacts object derived from the properties saved with the specified Application

Parameters:
app - the Application config object with (possibly) properties describing downloadable artifacts
Returns:

generatedArtifacts

public static Artifacts generatedArtifacts(DeploymentContext dc)
Returns the generated artifacts object from the specified deployment context, creating it there if it does not already exist.

Parameters:
app -
Returns:

generatedArtifacts

public static Artifacts generatedArtifacts(Application app)
Returns the generated artifacts object derived from the properties saved with the specified Application

Parameters:
app - the Application config object with (possibly) properties describing generated artifacts
Returns:

isWebArchive

public static boolean isWebArchive(ReadableArchive archive)

getDefaultEEName

public static String getDefaultEEName(String pathName)
Parameters:
pathName -
Returns:
the default value of the EE name. The default name is the pathname with any filename extension (.jar, .war, .rar) removed, but with any directory names included.

hasResourcesXML

public static boolean hasResourcesXML(ReadableArchive archive)

isRAR

public static boolean isRAR(ReadableArchive archive)
check whether the archive is a .rar

Parameters:
archive - archive to be tested
Returns:
status of .rar or not

isRAR

public static boolean isRAR(ReadableArchive archive,
                            org.jvnet.hk2.component.Habitat habitat)
check whether the archive is a .rar, it also scans annotations

Parameters:
archive - archive to be tested
habitat -
Returns:
status of .rar or not

isCAR

public static boolean isCAR(ReadableArchive archive)
check whether the archive is an appclient archive

Parameters:
archive - archive to be tested
Returns:
whether the archive is an appclient archive or not

isEjbJar

public static boolean isEjbJar(ReadableArchive archive,
                               org.jvnet.hk2.component.Habitat habitat)
check whether the archive is an ejb archive

Parameters:
archive - archive to be tested
habitat -
Returns:
whether the archive is an ejb archive or not

isEAR

public static boolean isEAR(ReadableArchive archive)
check whether the archive is a .ear

Parameters:
archive - archive to be tested
Returns:
status of .ear or not

isArchiveOfType

public static boolean isArchiveOfType(ArchiveHandler ah,
                                      ArchiveType moduleType)
Return true the current module (aka archive) being deployed is of given module type, else false.

Parameters:
ah - current archive
moduleType -
Returns:
true if the current module being deployed is of given module type, else false.

getRelativeEmbeddedModulePath

public static String getRelativeEmbeddedModulePath(String appRootPath,
                                                   String moduleUri)
This method returns the relative file path of an embedded module to the application root. For example, if the module is expanded/located at $domain_dir/applications/j2ee-apps/foo/fooEJB_jar, this method will return fooEJB_jar

Parameters:
appRootPath - The path of the application root which contains the module e.g. $domain_dir/applications/j2ee-apps/foo
moduleUri - The module uri e.g. fooEJB.jar
Returns:
The relative file path of the module to the application root

getEmbeddedModulePath

public static String getEmbeddedModulePath(String appRootPath,
                                           String moduleUri)
This method returns the file path of an embedded module. For example, if the module is expanded/located at $domain_dir/applications/j2ee-apps/foo/fooEJB_jar, this method will return $domain_dir/applications/j2ee-apps/foo/fooEJB_jar

Parameters:
appRootPath - The path of the application root which contains the module e.g. $domain_dir/applications/j2ee-apps/foo
moduleUri - The module uri e.g. fooEJB.jar
Returns:
The file path of the module

useV2Compatibility

public static boolean useV2Compatibility(DeploymentContext context)

relativizeWithinDomainIfPossible

public static String relativizeWithinDomainIfPossible(URI absURI)
                                               throws URISyntaxException
Throws:
URISyntaxException

validateApplicationName

public static void validateApplicationName(String name)

propertiesValue

public static String propertiesValue(Properties props,
                                     char sep)

getManifestLibraries

public static List<URL> getManifestLibraries(DeploymentContext context)
                                      throws IOException
Throws:
IOException

getManifestLibraries

public static List<URL> getManifestLibraries(DeploymentContext context,
                                             Manifest manifest)
                                      throws IOException
Throws:
IOException

getManifestLibraries

public static List<URL> getManifestLibraries(ReadableArchive archive)
                                      throws IOException
Throws:
IOException

getExternalLibraries

public static List<URI> getExternalLibraries(ReadableArchive archive)

getModuleLibraryJars

public static List<URL> getModuleLibraryJars(DeploymentContext context)
                                      throws Exception
Throws:
Exception

openAsFileArchive

public static FileArchive openAsFileArchive(File dir,
                                            ArchiveFactory archiveFactory)
                                     throws IOException
Opens the specified file as an archive, using the provided archive factory.

Parameters:
dir - directory to be opened as an archive
archiveFactory - ArchiveFactory to use to create the archive object
Returns:
FileArchive opened for the directory
Throws:
IOException


Copyright © 2012. All Rights Reserved.