Methods Summary |
---|
private void | addDeploymentPlanEntry(java.util.jar.JarOutputStream jos, java.lang.String moduleName)Add an entry from the deployment plan, if found
if (moduleName == null)
moduleName = "";
// ignore deployment plan entries that do not start like this
String moduleKey = moduleName + "!/";
Iterator it = mapDeploymentPlan.keySet().iterator();
while (it.hasNext())
{
String key = (String)it.next();
if (key.startsWith(moduleKey))
{
String dpName = key.substring(moduleKey.length());
log.debug("found deployment plan entry: " + dpName);
File dpFile = (File)mapDeploymentPlan.get(key);
FileInputStream dpin = new FileInputStream(dpFile);
JarUtils.addJarEntry(jos, dpName, dpin);
dpin.close();
}
}
|
public javax.enterprise.deploy.spi.DeploymentConfiguration | createConfiguration(javax.enterprise.deploy.model.DeployableObject obj)Retrieve server specific configuration for a component
// do some stuff to figure out what kind of config to return.
if (obj.getType().equals(ModuleType.WAR))
return new WarConfiguration(obj);
throw new InvalidModuleException("CreateConfiguration: Module type not yet supported");
|
private org.jboss.deployment.spi.DeploymentManagerImpl$TargetModuleInfo | createDeployment(java.io.InputStream moduleArchive)Create the JBoss deployment, by enhancing the content of the module
archive with the entries in the deployment plan.
File tmpFile = File.createTempFile("jboss_deployment_", ".zip");
log.debug("temporary deployment file: " + tmpFile);
JarInputStream jis = new JarInputStream(moduleArchive);
// make sure we don't loose the manifest when creating a new JarOutputStream
JarOutputStream jos = null;
FileOutputStream fos = new FileOutputStream(tmpFile);
Manifest manifest = jis.getManifest();
if (manifest != null)
jos = new JarOutputStream(fos, manifest);
else jos = new JarOutputStream(fos);
// process all modules
TargetModuleInfo moduleInfo = new TargetModuleInfo();
ModuleType moduleType = null;
JarEntry entry = jis.getNextJarEntry();
while (entry != null)
{
String entryName = entry.getName();
// only process file entries
if (entryName.endsWith("/") == false)
{
if (entryName.endsWith("/application.xml"))
{
moduleType = ModuleType.EAR;
}
else if (entryName.endsWith("/application-client.xml"))
{
moduleType = ModuleType.CAR;
}
else if (entryName.endsWith("/ra.xml"))
{
moduleType = ModuleType.RAR;
}
else if (entryName.endsWith("/web.xml"))
{
moduleType = ModuleType.WAR;
}
else if (entryName.endsWith("/ejb-jar.xml"))
{
moduleType = ModuleType.EJB;
}
// process a sub module
if (entryName.endsWith(".jar") || entryName.endsWith(".war"))
{
moduleInfo.addChild(entryName);
File tmpSubModule = processSubModule(entryName, jis);
FileInputStream fis = new FileInputStream(tmpSubModule);
JarUtils.addJarEntry(jos, entryName, fis);
fis.close();
}
else
{
if (mapDeploymentPlan.get("!/" + entryName) == null)
JarUtils.addJarEntry(jos, entryName, jis);
else log.debug("Skip entry found in deployment plan: " + entryName);
}
}
entry = jis.getNextJarEntry();
}
if (moduleType == null)
{
throw new RuntimeException("cannot obtain module type");
}
moduleInfo.setModuleType(moduleType);
// there may be top level deployment plan entries, add them
addDeploymentPlanEntry(jos, null);
jos.close();
// rename the deployment
String deploymentName = tmpFile.getParent() + File.separator + metaData.getDeploymentName();
File deployment = new File(deploymentName);
if (deployment.exists() && deployment.delete() == false)
throw new IOException("Cannot delete existing deployment: " + deployment);
tmpFile.renameTo(deployment);
moduleInfo.setModuleID(deployment.toURL());
return moduleInfo;
|
public javax.enterprise.deploy.spi.status.ProgressObject | distribute(javax.enterprise.deploy.spi.Target[] targets, java.io.File moduleArchive, java.io.File deploymentPlan)Validates the configuration, generates all container specific classes and moves the archive
to the targets
log.debug("distribute module: " + moduleArchive + ", plan: " + deploymentPlan);
if (isConnected == false)
throw new IllegalStateException("DeploymentManager is not connected");
InputStream isModuleArchive = null;
InputStream isDeploymentPlan = null;
try
{
isModuleArchive = new FileInputStream(moduleArchive);
isDeploymentPlan = new FileInputStream(deploymentPlan);
return distribute(targets, isModuleArchive, isDeploymentPlan);
}
catch (FileNotFoundException e)
{
String message = "Cannot find deployment file" + e.getMessage();
log.error(message, e);
DeploymentStatus status = new DeploymentStatusImpl(StateType.FAILED, CommandType.DISTRIBUTE, ActionType.EXECUTE, message);
return new ProgressObjectImpl(status, null);
}
|
public javax.enterprise.deploy.spi.status.ProgressObject | distribute(javax.enterprise.deploy.spi.Target[] targets, java.io.InputStream moduleArchive, java.io.InputStream deploymentPlan)Validates the configuration, generates all container specific classes and moves the archive
to the targets
if (isConnected == false)
throw new IllegalStateException("DeploymentManager is not connected");
TargetModuleID[] targetModuleIDs = new TargetModuleID[targets.length];
try
{
// create for each entry in the deploymentPlan a temp file
mapDeploymentPlan = unpackDeploymentPlan(deploymentPlan);
initDeploymentMetaData();
// create the temp file that contains the deployment
TargetModuleInfo moduleInfo = createDeployment(moduleArchive);
URL deployment = moduleInfo.getModuleID();
// create the target module ids
for (int i = 0; i < targets.length; i++)
{
JBossTarget target = (JBossTarget)targets[i];
String moduleID = deployment.toExternalForm();
TargetModuleIDImpl tmid = new TargetModuleIDImpl(target, moduleID, null, false, moduleInfo.getModuleType());
// The children modules are only added for compliance
// since they are not used by our implementation.
for (Iterator it = moduleInfo.getChildren().iterator(); it.hasNext(); )
{
String childModule = (String)it.next();
tmid.addChildTargetModuleID(new TargetModuleIDImpl(target, childModule, tmid, false, ModuleType.EJB));
}
targetModuleIDs[i] = tmid;
}
// delete all temp files, except the depoyment
for (int i = 0; i < tmpFiles.size(); i++)
{
File file = (File)tmpFiles.get(i);
if (file.equals(deployment) == false)
file.delete();
}
}
catch (IOException e)
{
String message = "Exception during deployment validation";
log.error(message, e);
DeploymentStatus status = new DeploymentStatusImpl(StateType.FAILED, CommandType.DISTRIBUTE, ActionType.EXECUTE, message);
return new ProgressObjectImpl(status, targetModuleIDs);
}
// start the deployment process
DeploymentStatus status = new DeploymentStatusImpl(StateType.RUNNING, CommandType.DISTRIBUTE, ActionType.EXECUTE, null);
ProgressObject progress = new ProgressObjectImpl(status, targetModuleIDs);
DeploymentWorker worker = new DeploymentWorker(progress);
worker.start();
return progress;
|
public javax.enterprise.deploy.spi.TargetModuleID[] | getAvailableModules(javax.enterprise.deploy.shared.ModuleType moduleType, javax.enterprise.deploy.spi.Target[] targets)Retrieve the list of all J2EE application modules running or not running on the identified targets.
if (isConnected == false)
throw new IllegalStateException("DeploymentManager is not connected");
log.debug("getAvailableModules [type=" + moduleType + ",targets=" + Arrays.asList(targets) + "]");
// get non running modules
List targetModules = new ArrayList();
for (int i = 0; i < targets.length; i++)
{
JBossTarget target = (JBossTarget)targets[i];
TargetModuleID[] tmids = target.getAvailableModules(moduleType);
targetModules.addAll(Arrays.asList(tmids));
}
log.debug("Found [" + targetModules.size() + "] available modules");
// convert set to array
if (targetModules.size() > 0)
{
TargetModuleID[] idarr = new TargetModuleID[targetModules.size()];
targetModules.toArray(idarr);
return idarr;
}
// according to the spec, we have to return null
return null;
|
public java.util.Locale | getCurrentLocale()Currently we only support the default locale
return Locale.getDefault();
|
public javax.enterprise.deploy.shared.DConfigBeanVersionType | getDConfigBeanVersion()Get the J2EE platform version
return DConfigBeanVersionType.V1_4;
|
public java.util.Locale | getDefaultLocale()Get the default locale
return Locale.getDefault();
|
public javax.enterprise.deploy.spi.TargetModuleID[] | getNonRunningModules(javax.enterprise.deploy.shared.ModuleType moduleType, javax.enterprise.deploy.spi.Target[] targets)Get the non running modules
if (isConnected == false)
throw new IllegalStateException("DeploymentManager is not connected");
log.debug("getNonRunningModules [type=" + moduleType + ",targets=" + Arrays.asList(targets) + "]");
// get non running modules
Set moduleSet = new HashSet();
TargetModuleID[] availableModules = getAvailableModules(moduleType, targets);
if (availableModules == null)
{
log.debug("No modules available");
return null;
}
for (int i = 0; i < availableModules.length; i++)
{
TargetModuleIDImpl moduleID = (TargetModuleIDImpl)availableModules[i];
if (moduleID.isRunning() == false)
{
moduleSet.add(moduleID);
}
}
log.debug("Found [" + moduleSet.size() + "] non running modules");
// convert set to array
TargetModuleID[] idarr = new TargetModuleID[moduleSet.size()];
moduleSet.toArray(idarr);
return idarr;
|
public javax.enterprise.deploy.spi.TargetModuleID[] | getRunningModules(javax.enterprise.deploy.shared.ModuleType moduleType, javax.enterprise.deploy.spi.Target[] targets)Get the running modules
if (isConnected == false)
throw new IllegalStateException("DeploymentManager is not connected");
log.debug("getRunningModules [type=" + moduleType + ",targets=" + Arrays.asList(targets) + "]");
// get running modules
Set moduleSet = new HashSet();
TargetModuleID[] availableModules = getAvailableModules(moduleType, targets);
if (availableModules == null)
{
log.debug("No modules available");
return null;
}
for (int i = 0; i < availableModules.length; i++)
{
TargetModuleIDImpl moduleID = (TargetModuleIDImpl)availableModules[i];
if (moduleID.isRunning())
{
moduleSet.add(moduleID);
}
}
log.debug("Found [" + moduleSet.size() + "] running modules");
// convert set to array
TargetModuleID[] idarr = new TargetModuleID[moduleSet.size()];
moduleSet.toArray(idarr);
return idarr;
|
public java.util.Locale[] | getSupportedLocales()Currently we only support the default locale
return new Locale[] { Locale.getDefault() };
|
public javax.enterprise.deploy.spi.Target[] | getTargets()Get the available targets. This is determined by parsing the deployURI.
Currently there is only one target, either a JMXTarget that uses
the RMIAdaptor based on the URI info, or a LocalhostTarget if the
URI opaque.
if (isConnected == false)
throw new IllegalStateException("DeploymentManager is not connected");
if (targets == null)
{
if (deployURI.isOpaque())
{
log.debug("Opaque URI seen, defaulting to LocalhostTarget");
targets = new Target[] { new LocalhostTarget() };
}
else
{
log.debug("Non-Opaque URI seen, using to JMXTarget");
targets = new Target[] { new JMXTarget(deployURI) };
}
}
return targets;
|
private java.io.File | getTempFile(java.lang.String entryName)Get a temp file for an jar entry name
entryName = entryName.replace('/", '_");
int index = entryName.lastIndexOf(".");
String prefix = entryName.substring(0, index);
String suffix = entryName.substring(index);
File tempFile = File.createTempFile(prefix, suffix);
tmpFiles.add(tempFile);
return tempFile;
|
private void | initDeploymentMetaData()Initialize the deployment meta data
File metaTmpFile = (File)mapDeploymentPlan.get(DeploymentMetaData.ENTRY_NAME);
if (metaTmpFile == null)
throw new IOException("Deployment plan does not contain an entry: " + DeploymentMetaData.ENTRY_NAME);
try
{
SAXReader reader = new SAXReader();
reader.setEntityResolver(new JBossEntityResolver());
Document metaDoc = reader.read(metaTmpFile);
metaData = new DeploymentMetaData(metaDoc);
log.debug(DeploymentMetaData.ENTRY_NAME + "\n" + metaData.toXMLString());
}
catch (Exception e)
{
log.error("Cannot obtain meta data: " + e);
}
|
public boolean | isDConfigBeanVersionSupported(javax.enterprise.deploy.shared.DConfigBeanVersionType dConfigBeanVersionType)
return dConfigBeanVersionType == DConfigBeanVersionType.V1_4;
|
public boolean | isDConfigBeanVersionTypeSupported(javax.enterprise.deploy.shared.DConfigBeanVersionType version)Test whether the version is supported
return version == DConfigBeanVersionType.V1_4;
|
public boolean | isLocaleSupported(java.util.Locale locale)Currently we only support the default locale
return Locale.getDefault().equals(locale);
|
public boolean | isRedeploySupported()Is redeploy supported
return false;
|
private java.io.File | processSubModule(java.lang.String entryName, java.util.jar.JarInputStream jis)Process a potential sub module, adding descriptors from the deployment plan
// first copy te entry as is to a temp file
File tmpModule = getTempFile(entryName);
tmpFiles.add(tmpModule);
FileOutputStream fos = new FileOutputStream(tmpModule);
JarUtils.copyStream(fos, jis);
fos.close();
// now open the copy we just made and copy again entry by entry
JarInputStream jisModule = new JarInputStream(new FileInputStream(tmpModule));
File tmpJBossModule = getTempFile("jboss_" + entryName);
tmpFiles.add(tmpJBossModule);
JarOutputStream jos = null;
fos = new FileOutputStream(tmpJBossModule);
Manifest manifest = jisModule.getManifest();
if (manifest != null)
jos = new JarOutputStream(fos, manifest);
else jos = new JarOutputStream(fos);
// now copy entry by entry
JarEntry entry = jisModule.getNextJarEntry();
while (entry != null)
{
String subEntryName = entry.getName();
if (mapDeploymentPlan.get(entryName + "!/" + subEntryName) == null)
JarUtils.addJarEntry(jos, subEntryName, jisModule);
else log.debug("Skip entry found in deployment plan: " + subEntryName);
entry = jisModule.getNextJarEntry();
}
jisModule.close();
addDeploymentPlanEntry(jos, entryName);
jos.close();
return tmpJBossModule;
|
public javax.enterprise.deploy.spi.status.ProgressObject | redeploy(javax.enterprise.deploy.spi.TargetModuleID[] targetModuleIDs, java.io.File file, java.io.File file1)
if (isConnected == false)
throw new IllegalStateException("DeploymentManager is not connected");
throw new UnsupportedOperationException("redeploy");
|
public javax.enterprise.deploy.spi.status.ProgressObject | redeploy(javax.enterprise.deploy.spi.TargetModuleID[] targetModuleIDs, java.io.InputStream inputStream, java.io.InputStream inputStream1)
if (isConnected == false)
throw new IllegalStateException("DeploymentManager is not connected");
throw new UnsupportedOperationException("redeploy");
|
public javax.enterprise.deploy.spi.status.ProgressObject | redeploy(javax.enterprise.deploy.spi.TargetModuleID[] moduleIDList)Redeploys the modules
if (isConnected == false)
throw new IllegalStateException("DeploymentManager is not connected");
throw new UnsupportedOperationException("redeploy");
|
public void | release()The release method is the mechanism by which the tool signals to the DeploymentManager that the tool does not need
it to continue running connected to the platform. The tool may be signaling it wants to run in a
disconnected mode or it is planning to shutdown.
When release is called the DeploymentManager may close any J2EE resource connections it had for deployment
configuration and perform other related resource cleanup.
It should not accept any new operation requests (i.e., distribute, start stop, undeploy, redeploy.
It should finish any operations that are currently in process.
Each ProgressObject associated with a running operation should be marked as released (see the ProgressObject).
isConnected = false;
|
public void | setDConfigBeanVersion(javax.enterprise.deploy.shared.DConfigBeanVersionType dConfigBeanVersionType)
throw new UnsupportedOperationException("setDConfigBeanVersion");
|
public void | setDConfigBeanVersionType(javax.enterprise.deploy.shared.DConfigBeanVersionType version)Set the J2EE version
throw new UnsupportedOperationException("setDConfigBeanVersionType");
|
public void | setLocale(java.util.Locale locale)Currently we only support the default locale
throw new UnsupportedOperationException("setLocale");
|
public javax.enterprise.deploy.spi.status.ProgressObject | start(javax.enterprise.deploy.spi.TargetModuleID[] targetModuleIDs)Start the modules
if (isConnected == false)
throw new IllegalStateException("DeploymentManager is not connected");
log.debug("start " + Arrays.asList(targetModuleIDs));
// start the deployment process
DeploymentStatus status = new DeploymentStatusImpl(StateType.RUNNING, CommandType.START, ActionType.EXECUTE, null);
ProgressObject progress = new ProgressObjectImpl(status, targetModuleIDs);
DeploymentWorker worker = new DeploymentWorker(progress);
worker.start();
return progress;
|
public javax.enterprise.deploy.spi.status.ProgressObject | stop(javax.enterprise.deploy.spi.TargetModuleID[] targetModuleIDs)Stop the modules
if (isConnected == false)
throw new IllegalStateException("DeploymentManager is not connected");
log.debug("stop " + Arrays.asList(targetModuleIDs));
DeploymentStatus status = new DeploymentStatusImpl(StateType.RUNNING, CommandType.STOP, ActionType.EXECUTE, null);
ProgressObject progress = new ProgressObjectImpl(status, targetModuleIDs);
DeploymentWorker worker = new DeploymentWorker(progress);
worker.start();
return progress;
|
public javax.enterprise.deploy.spi.status.ProgressObject | undeploy(javax.enterprise.deploy.spi.TargetModuleID[] targetModuleIDs)Removes the modules
if (isConnected == false)
throw new IllegalStateException("DeploymentManager is not connected");
log.debug("undeploy " + Arrays.asList(targetModuleIDs));
// start the deployment process
DeploymentStatus status = new DeploymentStatusImpl(StateType.RUNNING, CommandType.UNDEPLOY, ActionType.EXECUTE, null);
ProgressObject progress = new ProgressObjectImpl(status, targetModuleIDs);
DeploymentWorker worker = new DeploymentWorker(progress);
worker.start();
return progress;
|
private java.util.HashMap | unpackDeploymentPlan(java.io.InputStream deploymentPlan)Create a temp file for every entry in the deployment plan
HashMap dpMap = new HashMap();
if (deploymentPlan == null)
return dpMap;
// process the deployment plan
try
{
JarInputStream jarDeploymentPlan = new JarInputStream(deploymentPlan);
JarEntry entry = jarDeploymentPlan.getNextJarEntry();
while (entry != null)
{
String entryName = entry.getName();
File tempFile = getTempFile(entryName);
log.debug("unpack deployment plan entry: " + entryName + ", into temp file: " + tempFile);
dpMap.put(entryName, tempFile);
FileOutputStream out = new FileOutputStream(tempFile);
JarUtils.copyStream(out, jarDeploymentPlan);
out.close();
entry = jarDeploymentPlan.getNextJarEntry();
}
}
finally
{
deploymentPlan.close();
}
return dpMap;
|