Methods Summary |
---|
public void | deploy(org.jboss.deployment.spi.SerializableTargetModuleID moduleID)
String url = moduleID.getModuleID();
// Create a status object
URL deployURL = new URL(url);
URLConnection conn = deployURL.openConnection();
int contentLength = conn.getContentLength();
log.debug("Begin deploy, url: " + deployURL + ", contentLength: " + contentLength);
// Create the local path
File path = new File(deployURL.getFile());
String archive = path.getName();
File deployFile = new File(uploadDir, archive);
if (failOnCollision && deployFile.exists())
throw new IOException("deployURL(" + deployURL + ") collides with: " + deployFile.getPath());
if (deployFile.exists())
Files.delete(deployFile);
File parentFile = deployFile.getParentFile();
if (parentFile.exists() == false)
{
if (parentFile.mkdirs() == false)
throw new IOException("Failed to create local path: " + parentFile);
}
InputStream is = conn.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is);
byte[] buffer = new byte[4096];
FileOutputStream fos = new FileOutputStream(deployFile);
BufferedOutputStream bos = new BufferedOutputStream(fos);
int count = 0;
while ((count = bis.read(buffer)) > 0)
{
bos.write(buffer, 0, count);
}
bis.close();
bos.close();
moduleMap.put(url, moduleID);
|
private void | fillChildrenTargetModuleID(org.jboss.deployment.spi.SerializableTargetModuleID moduleID, org.jboss.deployment.DeploymentInfo info)
Iterator it = info.subDeployments.iterator();
while (it.hasNext())
{
DeploymentInfo sdi = (DeploymentInfo)it.next();
try
{
ModuleType type = getModuleType(sdi);
// Discard unknown ModuleTypes
if (type != null)
{
String module = sdi.url.toString();
boolean isRunning = (DeploymentState.STARTED == sdi.state);
SerializableTargetModuleID child = new SerializableTargetModuleID(moduleID, module, type.getValue(), isRunning);
moduleID.addChildTargetModuleID(child);
fillChildrenTargetModuleID(child, sdi);
}
}
catch (UnsupportedOperationException e)
{
if (log.isTraceEnabled())
log.trace("Ignoring", e);
}
}
|
public org.jboss.deployment.spi.SerializableTargetModuleID[] | getAvailableModules(int moduleType)
ArrayList matches = new ArrayList();
Iterator modules = moduleMap.values().iterator();
while (modules.hasNext())
{
SerializableTargetModuleID module = (SerializableTargetModuleID)modules.next();
if (module.getModuleType() == moduleType)
matches.add(module);
}
SerializableTargetModuleID[] ids = new SerializableTargetModuleID[matches.size()];
matches.toArray(ids);
return ids;
|
public javax.management.ObjectName | getCARDeployer()
return carDeployer;
|
public javax.management.ObjectName | getEARDeployer()
return earDeployer;
|
public javax.management.ObjectName | getEJBDeployer()
return ejbDeployer;
|
public javax.management.ObjectName | getMainDeployer()
return mainDeployer;
|
public java.util.Map | getModuleMap()
return Collections.unmodifiableMap(moduleMap);
|
private javax.enterprise.deploy.shared.ModuleType | getModuleType(org.jboss.deployment.DeploymentInfo info)
if (info.deployer == null)
return null;
ModuleType type = null;
ObjectName deployer = info.deployer.getServiceName();
// Validate an ejb vs car based on the watch url
if (deployer.equals(carDeployer))
{
type = ModuleType.CAR;
}
else if (deployer.equals(ejbDeployer))
{
type = ModuleType.EJB;
}
else if (deployer.equals(earDeployer))
{
type = ModuleType.EAR;
}
else if (deployer.equals(rarDeployer))
{
type = ModuleType.RAR;
}
else if (deployer.equals(warDeployer))
{
type = ModuleType.WAR;
}
return type;
|
public javax.management.ObjectName | getRARDeployer()
return rarDeployer;
|
public java.io.File | getUploadDir()
return this.uploadDir;
|
public javax.management.ObjectName | getWARDeployer()
return warDeployer;
|
public boolean | isDeleteOnUndeploy()
return deleteOnUndeploy;
|
public boolean | isFailOnCollision()
return failOnCollision;
|
public void | setCARDeployer(javax.management.ObjectName name)
this.carDeployer = name;
|
public void | setDeleteOnUndeploy(boolean deleteOnUndeploy)
this.deleteOnUndeploy = deleteOnUndeploy;
|
public void | setEARDeployer(javax.management.ObjectName name)
this.earDeployer = name;
|
public void | setEJBDeployer(javax.management.ObjectName name)
this.ejbDeployer = name;
|
public void | setFailOnCollision(boolean failOnCollision)
this.failOnCollision = failOnCollision;
|
public void | setMainDeployer(javax.management.ObjectName mainDeployer)
this.mainDeployer = mainDeployer;
|
public void | setRARDeployer(javax.management.ObjectName name)
this.rarDeployer = name;
|
public void | setUploadDir(java.io.File uploadDir)
this.uploadDir = uploadDir;
|
public void | setWARDeployer(javax.management.ObjectName name)
this.warDeployer = name;
|
public void | start(java.lang.String url)
SerializableTargetModuleID moduleID = (SerializableTargetModuleID)moduleMap.get(url);
if (moduleID == null)
throw new IOException("deployURL(" + url + ") has not been distributed");
URL deployURL = new URL(url);
// Build the local path
File path = new File(deployURL.getFile());
String archive = path.getName();
File deployFile = new File(uploadDir, archive);
if (deployFile.exists() == false)
throw new IOException("deployURL(" + url + ") has no local archive");
MainDeployerMBean proxy = (MainDeployerMBean)MBeanServerInvocationHandler.newProxyInstance(server, mainDeployer, MainDeployerMBean.class, false);
proxy.deploy(deployFile.toURL());
moduleID.setRunning(true);
moduleID.clearChildModuleIDs();
// Repopulate the child modules
DeploymentInfo info = proxy.getDeployment(deployFile.toURL());
fillChildrenTargetModuleID(moduleID, info);
|
public void | stop(java.lang.String url)
SerializableTargetModuleID moduleID = (SerializableTargetModuleID)moduleMap.get(url);
if (moduleID == null)
throw new IOException("deployURL(" + url + ") has not been distributed");
URL deployURL = new URL(url);
// Build the local path
File path = new File(deployURL.getFile());
String archive = path.getName();
File deployFile = new File(uploadDir, archive);
if (deployFile.exists() == false)
throw new IOException("deployURL(" + url + ") has no local archive");
MainDeployerMBean proxy = (MainDeployerMBean)MBeanServerInvocationHandler.newProxyInstance(server, mainDeployer, MainDeployerMBean.class, false);
proxy.undeploy(deployFile.toURL());
moduleID.setRunning(false);
|
public void | undeploy(java.lang.String url)
SerializableTargetModuleID moduleID = (SerializableTargetModuleID)moduleMap.get(url);
if (moduleID == null)
return;
// If the module is still running, stop it
if (moduleID.isRunning())
stop(url);
URL deployURL = new URL(url);
// Build the local path
File path = new File(deployURL.getFile());
String archive = path.getName();
File deployFile = new File(uploadDir, archive);
if (deployFile.exists() == false)
throw new IOException("deployURL(" + url + ") has not been distributed");
if (deleteOnUndeploy)
Files.delete(deployFile);
moduleMap.remove(url);
|