Methods Summary |
---|
public void | addProgressListener(javax.enterprise.deploy.spi.status.ProgressListener pol)Add a listener to receive Progress events on deployment
actions.
synchronized (listeners) {
listeners.add(pol);
if (deliveredEvents.size() > 0) {
Print.dprintln("Delivering undelivered messages...");
for (Iterator i = deliveredEvents.iterator(); i.hasNext();) {
pol.handleProgressEvent((ProgressEvent)i.next());
}
}
}
|
public void | cancel()(optional)
A cancel request on an in-process operation
stops all further processing of the operation and returns
the environment to it original state before the operation
was executed. An operation that has run to completion
cannot be cancelled.
throw new OperationUnsupportedException("cancel not supported");
|
protected boolean | checkStatusAndAddStage(com.sun.enterprise.deployapi.SunTarget aTarget, com.sun.enterprise.deployment.client.RollBackAction rollback, java.lang.String action, com.sun.appserv.management.client.ConnectionSource dasConnection, com.sun.enterprise.deployment.backend.DeploymentStatus currentStatus)
return checkStatusAndAddStage(aTarget, rollback, action, dasConnection,
currentStatus, false);
|
protected boolean | checkStatusAndAddStage(com.sun.enterprise.deployapi.SunTarget aTarget, com.sun.enterprise.deployment.client.RollBackAction rollback, java.lang.String action, com.sun.appserv.management.client.ConnectionSource dasConnection, com.sun.enterprise.deployment.backend.DeploymentStatus currentStatus, boolean isStartPhase)Given a Deployment status, this checks if the status is success
If the status is failed, it tries roll back operations (if rollback is specified) and then sets up
for an abnormal exit
String statusMsg = getDeploymentStatusMessage(currentStatus,
isStartPhase);
finalDeploymentStatus.addSubStage(currentStatus);
if(statusMsg == null) {
fireProgressEvent(StateType.RUNNING,
localStrings.getString("enterprise.deployment.client.action_completed", action),
aTarget);
return true;
}
if(rollback != null) {
com.sun.enterprise.deployment.backend.DeploymentStatus tmp = new
com.sun.enterprise.deployment.backend.DeploymentStatus();
if(!rollback.rollback(dasConnection, tmp)) {
fireProgressEvent(StateType.RUNNING,
localStrings.getString("enterprise.deployment.client.action_failed", "Rollback failed"),
aTarget);
tmp.setStageStatus(com.sun.enterprise.deployment.backend.DeploymentStatus.FAILURE);
tmp.setStageStatusMessage(localStrings.getString("enterprise.deployment.client.action_failed", "Rollback failed"));
} else {
fireProgressEvent(StateType.RUNNING,
localStrings.getString("enterprise.deployment.client.action_completed", "Rollback"),
aTarget);
tmp.setStageStatus(com.sun.enterprise.deployment.backend.DeploymentStatus.SUCCESS);
tmp.setStageStatusMessage(localStrings.getString("enterprise.deployment.client.action_completed", "Rollback"));
}
finalDeploymentStatus.addSubStage(tmp);
}
setupForAbnormalExit(localStrings.getString("enterprise.deployment.client.action_failed_with_message", action, statusMsg), aTarget);
return false;
|
protected void | fireProgressEvent(javax.enterprise.deploy.spi.status.ProgressEvent progressEvent)Notifies all listeners that have registered interest for ProgressEvent notification.
/*
*Bug 4977764
*Iteration failed due to concurrent modification of the vector. Even though the add, remove, and fire
*methods synchronize on the listeners vector, a listener could conceivably invoke add or remove
*recursively, thereby triggering the concurrent modification exception.
*
*Fix: clone the listeners vector and iterate through the clone.
*/
Vector currentListeners = null;
synchronized (listeners) {
currentListeners = (Vector) listeners.clone();
/*
*The following add must remain inside the synchronized block. Otherwise, there will be a small window
*in which a new listener's registration could interleave with fireProgressEvent, registering itself
*after the listeners vector had been cloned (thus excluding the new listener from the iteration a
*few lines below) but before the list of previously-delivered events had been updated.
*This would cause the new listener to miss the event that was firing.
*Keeping the following add inside the synchronized block ensures that updates to the listeners
*vector by addProgressListener and to deliveredEvents by fireProgressEvent do not interleave and therefore
*all listeners will receive all events.
*/
deliveredEvents.add(progressEvent);
}
for (Iterator listenersItr = currentListeners.iterator(); listenersItr.hasNext();) {
((ProgressListener)listenersItr.next()).handleProgressEvent(progressEvent);
}
currentListeners = null;
|
protected void | fireProgressEvent(javax.enterprise.deploy.shared.StateType state, java.lang.String message)Notifies all listeners that have registered interest for ProgressEvent notification.
fireProgressEvent(state, message, target);
|
protected void | fireProgressEvent(javax.enterprise.deploy.shared.StateType state, java.lang.String message, com.sun.enterprise.deployapi.SunTarget aTarget)Notifies all listeners that have registered interest for ProgressEvent notification.
StateType stateToBroadcast = (state != null) ? state : deploymentStatus.getState();
/* new copy of DeploymentStatus */
DeploymentStatusImpl depStatus = new DeploymentStatusImpl(this);
depStatus.setState(stateToBroadcast);
depStatus.setMessage(message);
/*
*Update this progress object's status before notifying listeners.
*/
if (state != null) {
deploymentStatus.setMessage(message);
deploymentStatus.setState(state); // retain current state
}
/* send notification */
SunTargetModuleID tmi = new SunTargetModuleID(moduleID, aTarget);
tmi.setModuleType(getModuleType());
fireProgressEvent(new ProgressEvent(this, tmi, depStatus));
|
public javax.enterprise.deploy.spi.status.ClientConfiguration | getClientConfiguration(javax.enterprise.deploy.spi.TargetModuleID id)Return the ClientConfiguration object associated with the
TargetModuleID.
return null;
|
javax.enterprise.deploy.shared.CommandType | getCommandType()
return commandType;
|
public com.sun.enterprise.deployment.backend.DeploymentStatus | getCompletedStatus()Retrieve the final deployment status which has complete details for each stage
if(deployActionCompleted) {
return finalDeploymentStatus;
}
return null;
|
public javax.enterprise.deploy.spi.status.DeploymentStatus | getDeploymentStatus()Retrieve the status of this activity.
DeploymentStatusImpl result = new DeploymentStatusImpl(this);
result.setState(deploymentStatus.getState());
result.setMessage(deploymentStatus.getMessage());
return result;
|
protected java.lang.String | getDeploymentStatusMessage(com.sun.enterprise.deployment.backend.DeploymentStatus status)
return getDeploymentStatusMessage(status, false);
|
protected java.lang.String | getDeploymentStatusMessage(com.sun.enterprise.deployment.backend.DeploymentStatus status, boolean isStartPhase)Parse the DeploymentStatus to get the status message within
if(status == null) {
return null;
}
// if stage status is success, return as it is
if (status!=null && status.getStatus() >= com.sun.enterprise.deployment.backend.DeploymentStatus.SUCCESS) {
return null;
}
ByteArrayOutputStream bos = new ByteArrayOutputStream();
PrintWriter pw = new PrintWriter(bos);
com.sun.enterprise.deployment.backend.DeploymentStatus.parseDeploymentStatus(status, pw);
byte[] statusBytes = bos.toByteArray();
String statusString = new String(statusBytes);
// if stage status is WARNING, collect the warning messages
if(status.getStatus() == com.sun.enterprise.deployment.backend.DeploymentStatus.WARNING) {
if(warningMessages==null) {
warningMessages = WARNING_PREFIX + statusString;
} else {
warningMessages += statusString;
}
// add additional messages if it failed at loading.
if (isStartPhase) {
warningMessages = localStrings.getString("enterprise.deployment.client.start_failed_msg") + warningMessages;
}
return null;
}
// Failed stage; return the failure message
return statusString;
|
public javax.enterprise.deploy.shared.ModuleType | getModuleType()
return moduleType;
|
public javax.enterprise.deploy.spi.TargetModuleID[] | getResultTargetModuleIDs()Retrieve the list of TargetModuleIDs successfully
processed or created by the associated DeploymentManager
operation.
/**
* this should go once CTS has fixed their bugs...
*/
if (targetModuleIDs==null) {
if(target != null) {
initializeTargetModuleIDs(moduleID);
} else if(targetsList != null) {
initializeTargetModuleIDForAllServers(null, null);
}
}
// will return null until the operation is completed
return targetModuleIDs;
|
protected java.lang.String | getThrowableString(java.lang.Throwable t)Since DeploymentStatus only provides the ability to pass a String to the
ProgressListener, the following is a convenience method for allowing the
stack-trace from a Throwable to be converted to a String to send to the
ProgressListeners.
ByteArrayOutputStream bos = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(bos);
t.printStackTrace(ps);
ps.close(); // may not be necessary
return bos.toString();
|
private void | initTargetModuleIDWebURL(com.sun.enterprise.deployapi.SunTargetModuleID tm, com.sun.enterprise.admin.util.HostAndPort webHost, java.lang.String contextRoot)private method to initialize the web url for the associated deployed web
module
if (webHost==null)
return;
try {
// Patchup code for fixing netbeans issue 6221411; Need to find a
// good solution for this and WSDL publishing
String host;
SunDeploymentManager sdm = new SunDeploymentManager(tm.getConnectionInfo());
if(sdm.isPE()) {
host = tm.getConnectionInfo().getHostName();
} else {
host = webHost.getHost();
}
URL webURL = new URL("http", host, webHost.getPort(), contextRoot);
tm.setWebURL(webURL.toExternalForm());
} catch(Exception e) {
Print.dprintStackTrace(e.getLocalizedMessage(),e);
}
|
protected void | initializeTargetModuleIDForAllServers(com.sun.enterprise.deployment.backend.DeploymentStatus status, javax.management.MBeanServerConnection mbsc)Initialize the target module IDs with the application information stored
in the DeploymentStatus for all the server in the target list.
if(targetsList == null) {
return;
}
targetModuleIDs = new SunTargetModuleID[targetsList.length];
String moduleID = status == null
? this.moduleID : status.getProperty(MODULE_ID);
String key = moduleID + KEY_SEPARATOR + MODULE_TYPE;
ModuleType type = status == null
? getModuleType()
: ModuleType.getModuleType((new Integer(status.getProperty(key))).intValue());
for(int i=0; i<targetsList.length; i++) {
SunTargetModuleID parentTargetModuleID = new SunTargetModuleID(moduleID, targetsList[i]);
parentTargetModuleID.setModuleType(type);
targetModuleIDs[i] = parentTargetModuleID;
if (status != null) {
// let's get the host name and port where the application was deployed
HostAndPort webHost=null;
try {
Object[] params = new Object[]{ moduleID, Boolean.FALSE };
String[] signature = new String[]{ "java.lang.String", "boolean"};
ObjectName applicationsMBean = new ObjectName(APPS_CONFIGMBEAN_OBJNAME);
webHost = (HostAndPort) mbsc.invoke(applicationsMBean, "getHostAndPort", params, signature);
} catch(Exception e) {
Print.dprintStackTrace(e.getLocalizedMessage(), e);
}
key = moduleID + KEY_SEPARATOR + SUBMODULE_COUNT;
if (status.getProperty(key) == null) { //standalone module
if (ModuleType.WAR.equals(type)) {
key = moduleID + KEY_SEPARATOR + CONTEXT_ROOT;
String contextRoot = status.getProperty(key);
initTargetModuleIDWebURL(parentTargetModuleID, webHost, contextRoot);
}
} else {
int counter = (Integer.valueOf(status.getProperty(key))).intValue();
// now for each sub module
for (int j = 0; j < counter; j++) {
//subModuleID
key = moduleID + KEY_SEPARATOR + MODULE_ID + KEY_SEPARATOR + String.valueOf(j);
String subModuleID = status.getProperty(key);
SunTargetModuleID subModule = new SunTargetModuleID(subModuleID, targetsList[i]);
//subModuleType
key = subModuleID + KEY_SEPARATOR + MODULE_TYPE;
type = ModuleType.getModuleType((new Integer(status.getProperty(key))).intValue());
subModule.setModuleType(type);
if (ModuleType.WAR.equals(type) && webHost!=null) {
key = subModuleID + KEY_SEPARATOR + CONTEXT_ROOT;
String contextRoot = status.getProperty(key);
initTargetModuleIDWebURL(subModule, webHost, contextRoot);
}
parentTargetModuleID.addChildTargetModuleID(subModule);
}
}
}
}
|
protected void | initializeTargetModuleIDs(java.lang.String moduleID)initialize the target module IDs with the passed application moduleID
and the descriptors
SunTargetModuleID parentTargetModuleID = new SunTargetModuleID(moduleID, target);
parentTargetModuleID.setModuleType(getModuleType());
targetModuleIDs = new SunTargetModuleID[1];
targetModuleIDs[0] = parentTargetModuleID;
|
public boolean | isCancelSupported()Tests whether the vendor supports a cancel
opertation for deployment activities.
return false;
|
public boolean | isStopSupported()Tests whether the vendor supports a stop
opertation for deployment activities.
return false;
|
public void | removeProgressListener(javax.enterprise.deploy.spi.status.ProgressListener pol)Remove a ProgressObject listener.
synchronized (listeners) {
listeners.remove(pol);
}
|
public abstract void | run()implement this method to do the actual processing
|
public void | setCommand(javax.enterprise.deploy.shared.CommandType commandType, java.lang.Object[] args)
this.commandType = commandType;
this.args = args;
|
public void | setModuleType(javax.enterprise.deploy.shared.ModuleType moduleType)Sets the module type for this deployed module
this.moduleType = moduleType;
|
protected void | setupForAbnormalExit(java.lang.String errorMsg, com.sun.enterprise.deployapi.SunTarget aTarget)
String i18nmsg = localStrings.getString("enterprise.deployment.client.action_failed", errorMsg);
finalDeploymentStatus.setStageStatus(com.sun.enterprise.deployment.backend.DeploymentStatus.FAILURE);
finalDeploymentStatus.setStageStatusMessage(i18nmsg);
deployActionCompleted = true;
fireProgressEvent(StateType.FAILED, i18nmsg, aTarget);
return;
|
protected void | setupForNormalExit(java.lang.String message, com.sun.enterprise.deployapi.SunTarget aTarget)
String i18nmsg;
// If we ever got some warning during any of the stages, the the final status is warning; else status=success
if(warningMessages == null) {
i18nmsg = localStrings.getString("enterprise.deployment.client.action_completed", message);
finalDeploymentStatus.setStageStatus(com.sun.enterprise.deployment.backend.DeploymentStatus.SUCCESS);
} else {
i18nmsg = localStrings.getString("enterprise.deployment.client.action_completed_with_warning", warningMessages);
finalDeploymentStatus.setStageStatus(com.sun.enterprise.deployment.backend.DeploymentStatus.WARNING);
}
finalDeploymentStatus.setStageStatusMessage(i18nmsg);
deployActionCompleted = true;
fireProgressEvent(StateType.COMPLETED, i18nmsg, aTarget);
return;
|
public void | stop()(optional)
A stop request on an in-process operation allows the
operation on the current TargetModuleID to run to completion but
does not process any of the remaining unprocessed TargetModuleID
objects. The processed TargetModuleIDs must be returned by the
method getResultTargetModuleIDs.
throw new OperationUnsupportedException("stop not supported");
|