public DeploymentStatus deploy(File deployFile, File planFile,
String archiveName, String moduleID, DeploymentProperties dProps,
DeploymentCallback callback) throws IASDeploymentException {
try {
if (deployFile == null) {
throw new IASDeploymentException(
localStrings.getString("deployfile_not_specified"));
}
/*
*Save the current time to use in preparing the audit info later so
*the audit measurement includes all the logic below.
*/
long startTime = System.currentTimeMillis();
sLogger.log(Level.FINE, "mbean.begin_deploy", moduleID);
DeployableObjectType type = null;
if (dProps.getType() != null) {
type = DeploymentServiceUtils.getDeployableObjectType(dProps.getType());
} else {
type = DeploymentServiceUtils.getTypeFromFile(
moduleID, deployFile.getAbsolutePath());
}
InstanceEnvironment env =
ApplicationServer.getServerContext().getInstanceEnvironment();
DeploymentRequest req = new DeploymentRequest(
env,
type,
DeploymentCommand.DEPLOY);
DeploymentRequestRegistry.getRegistry().addDeploymentRequest(
moduleID, req);
req.setName(moduleID);
boolean isRegistered = false;
isRegistered = DeploymentServiceUtils.isRegistered(moduleID, type);
// FIXME validation for new REDEPLOY property
if (isRegistered) {
DeploymentServiceUtils.validate(moduleID,type,REDEPLOY_ACTION, req);
}
req.setFileSource(deployFile);
req.setDeploymentPlan(planFile);
req.setForced(dProps.getForce());
// Set the context Root for extension modules
if(type.isWEB() || req.isExtensionModule()) {
req.setDefaultContextRoot(dProps.getDefaultContextRoot(
archiveName));
req.setContextRoot(dProps.getContextRoot());
}
req.setVerifying(dProps.getVerify());
req.setPrecompileJSP(dProps.getPrecompileJSP());
req.setGenerateRMIStubs(dProps.getGenerateRMIStubs());
req.setAvailabilityEnabled(dProps.getAvailabilityEnabled());
req.setStartOnDeploy(dProps.getEnable());
req.setDescription(dProps.getDescription());
req.setLibraries(dProps.getLibraries());
req.setJavaWebStartEnabled(dProps.getJavaWebStartEnabled());
req.setExternallyManagedPath(dProps.getExternallyManaged());
req.setDeploymentCallback(callback);
req.setIsRedeployInProgress(dProps.getRedeploy());
DeploymentServiceUtils.setResourceOptionsInRequest(req, dProps);
/*
* The property option (name=value)[:name=value]* pair
* is sent as String which is read here and converted to a Map.
* The Map is sent in the request
*/
Properties propOption= new Properties();
Map<String, String> propMap = new HashMap();
if(dProps != null)
{
for (Iterator itr = dProps.keySet().iterator(); itr.hasNext();) {
String propKey = (String) itr.next();
if(propKey.equals(PROPERTY)) {
String propValue = (String) dProps.get(propKey);
StringTokenizer tok = new StringTokenizer(propValue, ":");
while(tok.hasMoreElements()) {
StringTokenizer token = new StringTokenizer(tok.nextToken(), "=");
String key = token.nextToken();
String val = token.nextToken();
propMap.put(key, val);
}
}
}
}
propOption.put(PROPERTY, propMap);
Properties optionalAttributes = new Properties();
String virtualServers = dProps.getVirtualServers();
if(virtualServers!=null) {
optionalAttributes.put(ServerTags.VIRTUAL_SERVERS,
virtualServers);
}
req.setOptionalAttributes(optionalAttributes);
req.addOptionalArguments(dProps.prune());
req.addOptionalArguments(propOption);
DeploymentServiceUtils.setHostAndPort(req);
return deploy(req, createAuditInfoIfOn(req, AuditInfo.Operation.deploy, startTime));
} catch(Exception e) {
sLogger.log(Level.WARNING, "mbean.deploy_failed", e);
if (e instanceof IASDeploymentException) {
throw (IASDeploymentException)e;
}
else {
throw new IASDeploymentException(e);
}
}
}