org.glassfish.deployment.client
Class AbstractDeploymentFacility

java.lang.Object
  extended by 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

Nested Class Summary
static interface AbstractDeploymentFacility.DFCommandRunner
          Defines behavior implemented in the local or remote deployment facility for actually executing the requested command.
 
Field Summary
protected static LocalStringManagerImpl localStrings
           
 
Fields inherited from interface org.glassfish.deployment.client.DeploymentFacility
STUBS_JARFILENAME
 
Constructor Summary
AbstractDeploymentFacility()
           
 
Method Summary
 TargetModuleID[] _listAppRefs(String[] targets)
          list all application refs that are present in the provided list of targets
 TargetModuleID[] _listAppRefs(String[] targets, String state)
          list all application refs that are present in the provided list of targets with the specified state
 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 type
 TargetModuleID[] _listAppRefs(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 type
protected  DFProgressObject changeAppRef(Target[] targets, String moduleID, String commandName, String action, Map options)
           
protected  DFProgressObject changeState(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(Target[] targets, String moduleID, Map options)
          Add an application ref on the selected targets
 Target createTarget(String name)
          Creates a single Target with the given name.
 Target[] createTargets(String[] targets)
          Creates an array of Target objects corresponding to the list of target names.
protected  String createTargetsParam(Target[] targets)
           
 DFProgressObject deleteAppRef(Target[] targets, String moduleID, Map options)
          remove the application ref for the provided list of targets.
 DFProgressObject deploy(Target[] targets, ReadableArchive source, ReadableArchive deploymentPlan, Map deploymentOptions)
           
 DFProgressObject deploy(Target[] targets, URI source, URI deploymentPlan, Map deploymentOptions)
          Deploys the application (with optional deployment plan) to the specified targets with the indicated options.
 DFProgressObject disable(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(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 module
protected abstract  AbstractDeploymentFacility.DFCommandRunner getDFCommandRunner(String commandName, Map<String,Object> commandOptions, String[] operands)
          Returns a command runner for the concrete implementation.
 HostAndPort getHostAndPort(String target)
          get the host and port information
 HostAndPort getHostAndPort(String target, boolean securityEnabled)
          get the host and port information with security enabled attribute
 HostAndPort getHostAndPort(String target, String moduleId, boolean securityEnabled)
          get the host and port information with the specified module id and security enabled attribute
 ModuleType getModuleType(String moduleName)
          Get module type for the module
 List<String> getSubModuleInfoForJ2EEApplication(String appName)
          Get sub module info for ear
protected  ServerConnectionIdentifier getTargetDAS()
           
 HostAndPort getVirtualServerHostAndPort(String target, String virtualServer, boolean securityEnabled)
          get the host and port information with the specified virtual server and security enabled attribute
 String getWebURL(TargetModuleID tmid)
          Returns the Web URL for the specified module on the Target implied by the TargetModuleID.
 boolean isConnected()
          Reports whether the deployment facility is connected.
 TargetModuleID[] listAppRefs(String[] targets)
          list all application refs that are present in the provided list of targets
 Target[] listReferencedTargets(String appName)
          list the referenced targets for application
 Target[] listTargets()
          list all targets
 void setWebURL(TargetModuleID tmid, String webURL)
          Sets the Web URL for the specified module on the Target implied by the TargetModuleID.
 DFProgressObject undeploy(Target[] targets, String moduleID)
          Undeploys an application from specified targets.
 DFProgressObject undeploy(Target[] targets, String moduleID, Map undeploymentOptions)
          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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

localStrings

protected static final LocalStringManagerImpl localStrings
Constructor Detail

AbstractDeploymentFacility

public AbstractDeploymentFacility()
Method Detail

getDFCommandRunner

protected abstract AbstractDeploymentFacility.DFCommandRunner getDFCommandRunner(String commandName,
                                                                                 Map<String,Object> commandOptions,
                                                                                 String[] operands)
                                                                          throws CommandException
Returns a command runner for the concrete implementation.

Parameters:
commandName -
commandOptions -
operands -
Returns:
Throws:
com.sun.enterprise.cli.framework.CommandException
CommandException

changeState

protected DFProgressObject changeState(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 occur
moduleID - name of the module affected
commandName - enable or disable
action - 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 interface DeploymentFacility
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 interface DeploymentFacility
Returns:
true if the disconnection was successful; false otherwise

createAppRef

public DFProgressObject createAppRef(Target[] targets,
                                     String moduleID,
                                     Map options)
Description copied from interface: DeploymentFacility
Add an application ref on the selected targets

Specified by:
createAppRef in interface DeploymentFacility

deleteAppRef

public DFProgressObject deleteAppRef(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 interface DeploymentFacility

changeAppRef

protected DFProgressObject changeAppRef(Target[] targets,
                                        String moduleID,
                                        String commandName,
                                        String action,
                                        Map options)

createTarget

public Target createTarget(String name)
Description copied from interface: TargetOwner
Creates a single Target with the given name.

Specified by:
createTarget in interface TargetOwner
Parameters:
name - the name of the Target to be returned
Returns:
a new Target

createTargets

public 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 interface DeploymentFacility
Specified by:
createTargets in interface TargetOwner
Parameters:
targets - the names of the targets of interest
Returns:
an array of Target objects for the selected target names

createTargetsParam

protected String createTargetsParam(Target[] targets)

deploy

public DFProgressObject deploy(Target[] targets,
                               ReadableArchive source,
                               ReadableArchive deploymentPlan,
                               Map deploymentOptions)
                        throws IOException
Specified by:
deploy in interface DeploymentFacility
Throws:
IOException

deploy

public DFProgressObject deploy(Target[] targets,
                               URI source,
                               URI deploymentPlan,
                               Map deploymentOptions)
Deploys the application (with optional deployment plan) to the specified targets with the indicated options.

Specified by:
deploy in interface DeploymentFacility
Parameters:
targets - targets to which to deploy the application
source - the app
deploymentPlan - the deployment plan (null if not specified)
deploymentOptions - options to be applied to the deployment
Returns:
DFProgressObject the caller can use to monitor progress and query status

disable

public DFProgressObject disable(Target[] targets,
                                String moduleID)
Disables an app on the specified targets.

Specified by:
disable in interface DeploymentFacility
Parameters:
targets - the targets on which to disable the app
moduleID - 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 interface DeploymentFacility
Parameters:
location - is the root directory where to place the downloaded file
moduleID - is the moduleID of the deployed component to download the file from
moduleURI - 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(Target[] targets,
                               String moduleID)
Enables an app on the specified targets.

Specified by:
enable in interface DeploymentFacility
Parameters:
targets - the targets on which to enable the app
moduleID - 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 interface DeploymentFacility
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 interface DeploymentFacility
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 interface DeploymentFacility
Throws:
IOException

getModuleType

public ModuleType getModuleType(String moduleName)
                         throws IOException
Description copied from interface: DeploymentFacility
Get module type for the module

Specified by:
getModuleType in interface DeploymentFacility
Throws:
IOException

listTargets

public Target[] listTargets()
                     throws IOException
Description copied from interface: DeploymentFacility
list all targets

Specified by:
listTargets in interface DeploymentFacility
Throws:
IOException

listReferencedTargets

public Target[] listReferencedTargets(String appName)
                               throws IOException
Description copied from interface: DeploymentFacility
list the referenced targets for application

Specified by:
listReferencedTargets in interface DeploymentFacility
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 interface DeploymentFacility
Parameters:
location - is the root path where to place the downloaded stubs
moduleID - 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 interface DeploymentFacility
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 interface DeploymentFacility
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 interface DeploymentFacility
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 interface DeploymentFacility
Throws:
IOException

listAppRefs

public 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 interface DeploymentFacility
Throws:
IOException

_listAppRefs

public 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 interface DeploymentFacility
Throws:
IOException

_listAppRefs

public 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 interface DeploymentFacility
Throws:
IOException

_listAppRefs

public 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 interface DeploymentFacility
Throws:
IOException

_listAppRefs

public TargetModuleID[] _listAppRefs(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 interface DeploymentFacility
Throws:
IOException

undeploy

public DFProgressObject undeploy(Target[] targets,
                                 String moduleID)
Undeploys an application from specified targets.

Specified by:
undeploy in interface DeploymentFacility
Parameters:
targets - the targets from which to undeploy the app
moduleID - the app
Returns:
DFProgressObject for monitoring progress and querying status

undeploy

public DFProgressObject undeploy(Target[] targets,
                                 String moduleID,
                                 Map undeploymentOptions)
Undeploys an application from specified targets.

Specified by:
undeploy in interface DeploymentFacility
Parameters:
targets - the targets from which to undeploy the app
moduleID - the app
undeploymentOptions - 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 interface TargetOwner
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 interface DeploymentFacility
Parameters:
po - DFProgressObject for the operation of interestt
Returns:
DFDeploymentStatus final status for the operation

getWebURL

public String getWebURL(TargetModuleID tmid)
Description copied from interface: TargetOwner
Returns the Web URL for the specified module on the Target implied by the TargetModuleID.

Specified by:
getWebURL in interface TargetOwner
Returns:
web url

setWebURL

public void setWebURL(TargetModuleID tmid,
                      String webURL)
Description copied from interface: TargetOwner
Sets the Web URL for the specified module on the Target implied by the TargetModuleID. represents a Web module or submodule on a Target.

Specified by:
setWebURL in interface TargetOwner

getTargetDAS

protected ServerConnectionIdentifier getTargetDAS()


Copyright © 2012. All Rights Reserved.