Package org.glassfish.deployment.client
Class AbstractDeploymentFacility
- java.lang.Object
-
- org.glassfish.deployment.client.AbstractDeploymentFacility
-
- All Implemented Interfaces:
DeploymentFacility
,TargetOwner
- Direct Known Subclasses:
RemoteDeploymentFacility
public abstract class AbstractDeploymentFacility extends Object implements DeploymentFacility, TargetOwner
Provides common behavior for the local and remote deployment facilities.Code that needs an instance of a remote deployment facility use the
DeploymentFacilityFactory
.- Author:
- tjquinn, David Matejcek
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
AbstractDeploymentFacility.DFCommandRunner
Defines behavior implemented in the local or remote deployment facility for actually executing the requested command.
-
Field Summary
Fields Modifier and Type Field Description static Logger
deplLogger
Shared deployment logger: "javax.enterprise.system.tools.deployment.client"-
Fields inherited from interface org.glassfish.deployment.client.DeploymentFacility
STUBS_JARFILENAME
-
-
Constructor Summary
Constructors Constructor Description AbstractDeploymentFacility()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description javax.enterprise.deploy.spi.TargetModuleID[]
_listAppRefs(String[] targets)
list all application refs that are present in the provided list of targetsjavax.enterprise.deploy.spi.TargetModuleID[]
_listAppRefs(String[] targets, String state)
list all application refs that are present in the provided list of targets with the specified statejavax.enterprise.deploy.spi.TargetModuleID[]
_listAppRefs(String[] targets, String state, String type)
list all application refs that are present in the provided list of targets with the specified state and specified typejavax.enterprise.deploy.spi.TargetModuleID[]
_listAppRefs(javax.enterprise.deploy.spi.Target[] targets, String state, String type)
list all application refs that are present in the provided list of targets with the specified state and specified typeprotected DFProgressObject
changeState(javax.enterprise.deploy.spi.Target[] targets, String moduleID, String commandName, String action)
Changes the state of an application.boolean
connect(ServerConnectionIdentifier targetDAS)
Connects the deployment facility to the DAS.DFProgressObject
createAppRef(javax.enterprise.deploy.spi.Target[] targets, String moduleID, Map options)
Add an application ref on the selected targetsjavax.enterprise.deploy.spi.Target
createTarget(String name)
Creates a singleTarget
with the given name.javax.enterprise.deploy.spi.Target[]
createTargets(String[] targets)
Creates an array of Target objects corresponding to the list of target names.DFProgressObject
deleteAppRef(javax.enterprise.deploy.spi.Target[] targets, String moduleID, Map options)
remove the application ref for the provided list of targets.DFProgressObject
deploy(javax.enterprise.deploy.spi.Target[] targets, URI source, URI deploymentPlan, Map origOptions)
Initiates a deployment operation on the server, using a source archive abstraction and an optional deployment plan if the server specific information is not embedded in the source archive.DFProgressObject
deploy(javax.enterprise.deploy.spi.Target[] targets, ReadableArchive source, ReadableArchive deploymentPlan, Map deploymentOptions)
DFProgressObject
disable(javax.enterprise.deploy.spi.Target[] targets, String moduleID)
Disables an app on the specified targets.boolean
disconnect()
Disconnects the deployment facility from the DAS.protected abstract boolean
doConnect()
Performs any local- or remote-specific work related to connecting to the DAS.protected abstract boolean
doDisconnect()
Performs any local- or remote-specific work to end the connection to the DAS.String
downloadFile(File location, String moduleID, String moduleURI)
Downloads a particular file from the server repository.DFProgressObject
enable(javax.enterprise.deploy.spi.Target[] targets, String moduleID)
Enables an app on the specified targets.String
exportClientStubs(String appName, String destDir)
Exports the Client stub jars to the given location.void
getClientStubs(String location, String moduleID)
Downloads the client stubs from the server repository.String
getContextRoot(String moduleName)
Get context root for the moduleprotected abstract AbstractDeploymentFacility.DFCommandRunner
getDFCommandRunner(String commandName, DFDeploymentProperties commandOptions, String[] operands)
Returns a command runner for the concrete implementation.HostAndPort
getHostAndPort(String target)
get the host and port informationHostAndPort
getHostAndPort(String target, boolean securityEnabled)
get the host and port information with security enabled attributeHostAndPort
getHostAndPort(String target, String moduleId, boolean securityEnabled)
get the host and port information with the specified module id and security enabled attributejavax.enterprise.deploy.shared.ModuleType
getModuleType(String moduleName)
Get module type for the moduleList<String>
getSubModuleInfoForJ2EEApplication(String appName)
Get sub module info for earprotected ServerConnectionIdentifier
getTargetDAS()
HostAndPort
getVirtualServerHostAndPort(String target, String virtualServer, boolean securityEnabled)
get the host and port information with the specified virtual server and security enabled attributeString
getWebURL(javax.enterprise.deploy.spi.TargetModuleID tmid)
Returns the Web URL for the specified module on theTarget
implied by the TargetModuleID.boolean
isConnected()
Reports whether the deployment facility is connected.javax.enterprise.deploy.spi.TargetModuleID[]
listAppRefs(String[] targets)
list all application refs that are present in the provided list of targetsjavax.enterprise.deploy.spi.Target[]
listReferencedTargets(String appName)
list the referenced targets for applicationjavax.enterprise.deploy.spi.Target[]
listTargets()
list all targetsvoid
setWebURL(javax.enterprise.deploy.spi.TargetModuleID tmid, String webURL)
Sets the Web URL for the specified module on theTarget
implied by the TargetModuleID.DFProgressObject
undeploy(javax.enterprise.deploy.spi.Target[] targets, String moduleID)
Undeploys an application from specified targets.DFProgressObject
undeploy(javax.enterprise.deploy.spi.Target[] origTargets, String moduleID, Map origOptions)
Undeploys an application from specified targets.DFDeploymentStatus
waitFor(DFProgressObject po)
Convenient method to wait for the operation monitored by the progress object to complete, returning the final operation status.
-
-
-
Field Detail
-
deplLogger
public static final Logger deplLogger
Shared deployment logger: "javax.enterprise.system.tools.deployment.client"
-
-
Method Detail
-
getDFCommandRunner
protected abstract AbstractDeploymentFacility.DFCommandRunner getDFCommandRunner(String commandName, DFDeploymentProperties commandOptions, String[] operands) throws CommandException
Returns a command runner for the concrete implementation.- Parameters:
commandName
-commandOptions
-operands
-- Returns:
AbstractDeploymentFacility.DFCommandRunner
- Throws:
CommandException
-
changeState
protected DFProgressObject changeState(javax.enterprise.deploy.spi.Target[] targets, String moduleID, String commandName, String action)
Changes the state of an application.Used for enable and disable.
- Parameters:
targets
- targets on which the change should occurmoduleID
- name of the module affectedcommandName
- enable or disableaction
- name enabling or disabling- Returns:
- DFProgressObject the caller can use to monitor progress and query final status
-
doConnect
protected abstract boolean doConnect()
Performs any local- or remote-specific work related to connecting to the DAS.- Returns:
- true if the connection was made successfully; false otherwise
-
connect
public boolean connect(ServerConnectionIdentifier targetDAS)
Connects the deployment facility to the DAS.- Specified by:
connect
in interfaceDeploymentFacility
- Parameters:
targetDAS
- the DAS to contact- Returns:
- true if the connection was made successfully; false otherwise
-
doDisconnect
protected abstract boolean doDisconnect()
Performs any local- or remote-specific work to end the connection to the DAS.- Returns:
- true if the disconnection succeeded; false otherwise
-
disconnect
public boolean disconnect()
Disconnects the deployment facility from the DAS.- Specified by:
disconnect
in interfaceDeploymentFacility
- Returns:
- true if the disconnection was successful; false otherwise
-
createAppRef
public DFProgressObject createAppRef(javax.enterprise.deploy.spi.Target[] targets, String moduleID, Map options)
Description copied from interface:DeploymentFacility
Add an application ref on the selected targets- Specified by:
createAppRef
in interfaceDeploymentFacility
-
deleteAppRef
public DFProgressObject deleteAppRef(javax.enterprise.deploy.spi.Target[] targets, String moduleID, Map options)
Description copied from interface:DeploymentFacility
remove the application ref for the provided list of targets.- Specified by:
deleteAppRef
in interfaceDeploymentFacility
-
createTarget
public javax.enterprise.deploy.spi.Target createTarget(String name)
Description copied from interface:TargetOwner
Creates a singleTarget
with the given name.- Specified by:
createTarget
in interfaceTargetOwner
- Parameters:
name
- the name of the Target to be returned- Returns:
- a new Target
-
createTargets
public javax.enterprise.deploy.spi.Target[] createTargets(String[] targets)
Description copied from interface:DeploymentFacility
Creates an array of Target objects corresponding to the list of target names.- Specified by:
createTargets
in interfaceDeploymentFacility
- Specified by:
createTargets
in interfaceTargetOwner
- Parameters:
targets
- the names of the targets of interest- Returns:
- an array of Target objects for the selected target names
-
deploy
public DFProgressObject deploy(javax.enterprise.deploy.spi.Target[] targets, ReadableArchive source, ReadableArchive deploymentPlan, Map deploymentOptions) throws IOException
- Specified by:
deploy
in interfaceDeploymentFacility
- Throws:
IOException
-
deploy
public DFProgressObject deploy(javax.enterprise.deploy.spi.Target[] targets, URI source, URI deploymentPlan, Map origOptions)
Description copied from interface:DeploymentFacility
Initiates a deployment operation on the server, using a source archive abstraction and an optional deployment plan if the server specific information is not embedded in the source archive. The deploymentOptions is a key-value pair map of deployment options for this operation.Once the deployment is successful, the TargetModuleID objects representing where the application now resides are available using the
ProgressObject.getResultTargetModuleIDs()
method.- Specified by:
deploy
in interfaceDeploymentFacility
- Parameters:
targets
- the Target objects to which to deploy the application - an empty array indicates a request to deploy to the default serversource
- URI to the Java EE module abstraction (with or without the server specific artifacts).deploymentPlan
- URI to the optional deployment plan if the source archive is portable.origOptions
- deployment options- Returns:
- a DFProgressObject to receive deployment events and status
-
disable
public DFProgressObject disable(javax.enterprise.deploy.spi.Target[] targets, String moduleID)
Disables an app on the specified targets.- Specified by:
disable
in interfaceDeploymentFacility
- Parameters:
targets
- the targets on which to disable the appmoduleID
- the app- Returns:
- DFProgressObject for monitoring progress and querying status
-
downloadFile
public String downloadFile(File location, String moduleID, String moduleURI) throws IOException
Description copied from interface:DeploymentFacility
Downloads a particular file from the server repository. The filePath is a relative path from the root directory of the deployed component identified with the moduleID parameter. The resulting downloaded file should be placed in the location directory keeping the relative path constraint.- Specified by:
downloadFile
in interfaceDeploymentFacility
- Parameters:
location
- is the root directory where to place the downloaded filemoduleID
- is the moduleID of the deployed component to download the file frommoduleURI
- is the relative path to the file in the repository or STUBS_JARFILENAME to download the appclient jar file.- Returns:
- the downloaded local file absolute path.
- Throws:
IOException
-
enable
public DFProgressObject enable(javax.enterprise.deploy.spi.Target[] targets, String moduleID)
Enables an app on the specified targets.- Specified by:
enable
in interfaceDeploymentFacility
- Parameters:
targets
- the targets on which to enable the appmoduleID
- the app- Returns:
- DFProgressObject for monitoring progress and querying status
-
isConnected
public boolean isConnected()
Reports whether the deployment facility is connected.- Specified by:
isConnected
in interfaceDeploymentFacility
- Returns:
- true if connected, false otherwise
-
getSubModuleInfoForJ2EEApplication
public List<String> getSubModuleInfoForJ2EEApplication(String appName) throws IOException
Description copied from interface:DeploymentFacility
Get sub module info for ear- Specified by:
getSubModuleInfoForJ2EEApplication
in interfaceDeploymentFacility
- Throws:
IOException
-
getContextRoot
public String getContextRoot(String moduleName) throws IOException
Description copied from interface:DeploymentFacility
Get context root for the module- Specified by:
getContextRoot
in interfaceDeploymentFacility
- Throws:
IOException
-
getModuleType
public javax.enterprise.deploy.shared.ModuleType getModuleType(String moduleName) throws IOException
Description copied from interface:DeploymentFacility
Get module type for the module- Specified by:
getModuleType
in interfaceDeploymentFacility
- Throws:
IOException
-
listTargets
public javax.enterprise.deploy.spi.Target[] listTargets() throws IOException
Description copied from interface:DeploymentFacility
list all targets- Specified by:
listTargets
in interfaceDeploymentFacility
- Throws:
IOException
-
listReferencedTargets
public javax.enterprise.deploy.spi.Target[] listReferencedTargets(String appName) throws IOException
Description copied from interface:DeploymentFacility
list the referenced targets for application- Specified by:
listReferencedTargets
in interfaceDeploymentFacility
- Throws:
IOException
-
getClientStubs
public void getClientStubs(String location, String moduleID) throws IOException
Description copied from interface:DeploymentFacility
Downloads the client stubs from the server repository.- Specified by:
getClientStubs
in interfaceDeploymentFacility
- Parameters:
location
- is the root path where to place the downloaded stubsmoduleID
- is the moduleID of the deployed component to download the stubs for- Throws:
IOException
-
getHostAndPort
public HostAndPort getHostAndPort(String target) throws IOException
Description copied from interface:DeploymentFacility
get the host and port information- Specified by:
getHostAndPort
in interfaceDeploymentFacility
- Throws:
IOException
-
getHostAndPort
public HostAndPort getHostAndPort(String target, boolean securityEnabled) throws IOException
Description copied from interface:DeploymentFacility
get the host and port information with security enabled attribute- Specified by:
getHostAndPort
in interfaceDeploymentFacility
- Throws:
IOException
-
getVirtualServerHostAndPort
public HostAndPort getVirtualServerHostAndPort(String target, String virtualServer, boolean securityEnabled) throws IOException
Description copied from interface:DeploymentFacility
get the host and port information with the specified virtual server and security enabled attribute- Specified by:
getVirtualServerHostAndPort
in interfaceDeploymentFacility
- Throws:
IOException
-
getHostAndPort
public HostAndPort getHostAndPort(String target, String moduleId, boolean securityEnabled) throws IOException
Description copied from interface:DeploymentFacility
get the host and port information with the specified module id and security enabled attribute- Specified by:
getHostAndPort
in interfaceDeploymentFacility
- Throws:
IOException
-
listAppRefs
public javax.enterprise.deploy.spi.TargetModuleID[] listAppRefs(String[] targets) throws IOException
Description copied from interface:DeploymentFacility
list all application refs that are present in the provided list of targets- Specified by:
listAppRefs
in interfaceDeploymentFacility
- Throws:
IOException
-
_listAppRefs
public javax.enterprise.deploy.spi.TargetModuleID[] _listAppRefs(String[] targets) throws IOException
Description copied from interface:DeploymentFacility
list all application refs that are present in the provided list of targets- Specified by:
_listAppRefs
in interfaceDeploymentFacility
- Throws:
IOException
-
_listAppRefs
public javax.enterprise.deploy.spi.TargetModuleID[] _listAppRefs(String[] targets, String state) throws IOException
Description copied from interface:DeploymentFacility
list all application refs that are present in the provided list of targets with the specified state- Specified by:
_listAppRefs
in interfaceDeploymentFacility
- Throws:
IOException
-
_listAppRefs
public javax.enterprise.deploy.spi.TargetModuleID[] _listAppRefs(String[] targets, String state, String type) throws IOException
Description copied from interface:DeploymentFacility
list all application refs that are present in the provided list of targets with the specified state and specified type- Specified by:
_listAppRefs
in interfaceDeploymentFacility
- Throws:
IOException
-
_listAppRefs
public javax.enterprise.deploy.spi.TargetModuleID[] _listAppRefs(javax.enterprise.deploy.spi.Target[] targets, String state, String type) throws IOException
Description copied from interface:DeploymentFacility
list all application refs that are present in the provided list of targets with the specified state and specified type- Specified by:
_listAppRefs
in interfaceDeploymentFacility
- Throws:
IOException
-
undeploy
public DFProgressObject undeploy(javax.enterprise.deploy.spi.Target[] targets, String moduleID)
Undeploys an application from specified targets.- Specified by:
undeploy
in interfaceDeploymentFacility
- Parameters:
targets
- the targets from which to undeploy the appmoduleID
- the app- Returns:
- DFProgressObject for monitoring progress and querying status
-
undeploy
public DFProgressObject undeploy(javax.enterprise.deploy.spi.Target[] origTargets, String moduleID, Map origOptions)
Undeploys an application from specified targets.- Specified by:
undeploy
in interfaceDeploymentFacility
- Parameters:
origTargets
- the targets from which to undeploy the appmoduleID
- the apporigOptions
- options to control the undeployment- Returns:
- DFProgressObject for monitoring progress and querying status
-
exportClientStubs
public String exportClientStubs(String appName, String destDir) throws IOException
Exports the Client stub jars to the given location.- Specified by:
exportClientStubs
in interfaceTargetOwner
- Parameters:
appName
- The name of the application or module.destDir
- The directory into which the stub jar file should be exported.- Returns:
- the absolute location to the main jar file.
- Throws:
IOException
-
waitFor
public DFDeploymentStatus waitFor(DFProgressObject po)
Convenient method to wait for the operation monitored by the progress object to complete, returning the final operation status.- Specified by:
waitFor
in interfaceDeploymentFacility
- Parameters:
po
- DFProgressObject for the operation of interestt- Returns:
- DFDeploymentStatus final status for the operation
-
getWebURL
public String getWebURL(javax.enterprise.deploy.spi.TargetModuleID tmid)
Description copied from interface:TargetOwner
Returns the Web URL for the specified module on theTarget
implied by the TargetModuleID.- Specified by:
getWebURL
in interfaceTargetOwner
- Returns:
- web url
-
setWebURL
public void setWebURL(javax.enterprise.deploy.spi.TargetModuleID tmid, String webURL)
Description copied from interface:TargetOwner
Sets the Web URL for the specified module on theTarget
implied by the TargetModuleID. represents a Web module or submodule on a Target.- Specified by:
setWebURL
in interfaceTargetOwner
-
getTargetDAS
protected ServerConnectionIdentifier getTargetDAS()
-
-