Methods Summary |
---|
public java.util.Set | createReferences(java.lang.String[] targets, java.util.Map refOptions)Associate the specified targets with the deployed application by
creating {@link DeployedItemRefConfig} configuration within the targets.
Call only after deployment has finished, and call it only once.
if ( targets == null || targets.length == 0 )
{
throw new IllegalArgumentException();
}
if ( mListener == null || ! mListener.isCompleted() )
{
throw new IllegalStateException();
}
final DeploymentStatus status = mListener.getDeploymentStatus();
if ( status == null || status.getStageStatus() == STATUS_CODE_FAILURE )
{
throw new IllegalStateException();
}
if ( mDidAssociate )
{
throw new IllegalStateException();
}
// OK, go ahead
final Map<String,Serializable> additionalStatus = status.getAdditionalStatus();
final String moduleID = (String)additionalStatus.get( MODULE_ID_KEY );
final Set<DeployedItemRefConfig> refs = new HashSet<DeployedItemRefConfig>();
final Set<DeployedItemRefConfigCR> proxies = getTargetProxies( getDomainRoot(), targets );
for( final DeployedItemRefConfigCR cr : proxies )
{
final DeployedItemRefConfig ref =
cr.createDeployedItemRefConfig( moduleID, refOptions );
refs.add( ref );
}
return refs;
|
public void | deploy(java.io.File archive, java.util.Map deployOptions)Deploy the archive.
Subsequent progress and status should be obtained
from the listener returned from {@link #getDeployNotificationListener}.
For most errors, an Exception is not thrown; the returned
DeploymentStatus should be checked for errors using
{@link DeploymentStatus#getStageStatus}, verifing that
{@link DeploymentStatus#STATUS_CODE_SUCCESS} was received.
If no targets are specified, then the app is deployed, but not
associated with any server or cluster.
if ( archive == null )
{
throw new IllegalArgumentException();
}
final Object uploadID = Misc.uploadFile(
getDomainRoot().getUploadDownloadMgr(),
archive );
final Object deployID = mDeploymentMgr.initDeploy( );
mListener = new DeployNotificationListener( mDeploymentMgr, deployID );
try
{
final String archiveName = archive.getName();
final Map<String,String> actualOptions = new HashMap<String,String>();
if ( deployOptions != null )
{
actualOptions.putAll( deployOptions );
}
if ( ! actualOptions.containsKey( DEPLOY_OPTION_NAME_KEY ) )
{
final String appName = getDefaultAppName( archiveName );
actualOptions.put( DEPLOY_OPTION_NAME_KEY, appName );
}
mDeploymentMgr.startDeploy( deployID, uploadID, null, actualOptions );
}
finally
{
// remove right away; not all failures notify the listener
mListener.cleanup();
}
|
public com.sun.appserv.management.deploy.DeploymentStatus | deploy(java.io.File archive, java.util.Map deployOptions, java.lang.String[] targets, java.util.Map refOptions)Deploy the archive and associate it with all specified targets.
Calls {@link #deploy},
{@link #waitTillDone}, and
{@link #createReferences}.
deploy( archive, deployOptions );
final DeploymentStatus status = waitTillDone( 50 );
if ( targets != null && targets.length != 0 )
{
createReferences( targets, refOptions );
}
return status;
|
public com.sun.appserv.management.deploy.DeploymentStatus | deploy(java.io.File archive, java.lang.String[] targets)Perform default deployment. Calls deploy( archive, null, targets, null );
return deploy( archive, null, targets, null );
|
public static final java.lang.String | getDefaultAppName(java.lang.String archiveName)
String result = archiveName;
final int idx = archiveName.lastIndexOf( "." );
if ( idx > 1 )
{
result = archiveName.substring( 0, idx );
}
return( result );
|
public com.sun.appserv.management.helper.DeployNotificationListener | getDeployNotificationListener()To monitor progress or check on final status,
use the listener.
return mListener;
|
public static java.util.Set | getTargetProxies(com.sun.appserv.management.DomainRoot domainRoot, java.lang.String[] names)Get a Set of all {@link StandaloneServerConfig} and
{@link ClusterConfig} corresponding to the target names.
final DomainConfig domainConfig = domainRoot.getDomainConfig();
final Set<DeployedItemRefConfigCR> result = new HashSet<DeployedItemRefConfigCR>();
final Map<String,StandaloneServerConfig> serverConfigs =
domainConfig.getStandaloneServerConfigMap();
final Map<String,ClusterConfig> clusterConfigs =
domainConfig.getClusterConfigMap();
for( final String name : names )
{
if ( serverConfigs.containsKey( name ) )
{
result.add( serverConfigs.get( name ) );
}
else if ( clusterConfigs.containsKey( name ) )
{
result.add( clusterConfigs.get( name ) );
}
}
return result;
|
public com.sun.appserv.management.deploy.DeploymentStatus | waitTillDone(long pollMillis)Wait for deployment to finish, then return status.
// sanity check
if ( pollMillis > 5 * 1000 )
{
throw new IllegalArgumentException();
}
// a more sophisticated solution would be to have
// the DeploymentNotificationListener wake us up...
while ( ! mListener.isCompleted() )
{
Util.sleep( pollMillis );
}
final DeploymentStatus status = mListener.getDeploymentStatus();
return status;
|