The legacy component for deployer management. This now simply delegates to the
Main
| Method from org.jboss.deployment.MainDeployer Detail: |
public void addDeployer(SubDeployer deployer) {
log.debug("Adding deployer: " + deployer);
ObjectName deployerName = deployer.getServiceName();
synchronized(deployers)
{
deployers.addFirst(deployer);
try
{
String[] suffixes = (String[]) server.getAttribute(deployerName, "EnhancedSuffixes");
suffixOrderHelper.addEnhancedSuffixes(suffixes);
}
catch(Exception e)
{
log.debug(deployerName + " does not support EnhancedSuffixes");
suffixOrderHelper.addSuffixes(deployer.getSuffixes(), deployer.getRelativeOrder());
}
}
// Send a notification about the deployer addition
Notification msg = new Notification(ADD_DEPLOYER, this, getNextNotificationSequenceNumber());
msg.setUserData(deployerName);
sendNotification(msg);
synchronized (waitingDeployments)
{
List copy = new ArrayList(waitingDeployments);
waitingDeployments.clear();
for (Iterator i = copy.iterator(); i.hasNext();)
{
DeploymentInfo di = (DeploymentInfo)i.next();
log.debug("trying to deploy with new deployer: " + di.shortName);
try
{
di.setServer(server);
deploy(di);
}
catch (DeploymentException e)
{
log.error("DeploymentException while trying to deploy a package with a new deployer", e);
} // end of try-catch
} // end of for ()
}
} Deprecated!The addDeployer method registers a deployer with the main deployer.
Any waiting packages are tested to see if the new deployer will deploy them. |
protected boolean checkDeployed(String name) {
org.jboss.deployers.spi.DeploymentState deploymentState = delegate.getDeploymentState(name);
log.debug("isDeployed, url="+name+", state="+deploymentState);
return deploymentState == org.jboss.deployers.spi.DeploymentState.DEPLOYED;
} Deprecated! |
public void checkIncompleteDeployments() throws DeploymentException {
try
{
delegate.checkComplete();
}
catch (Exception e)
{
throw new DeploymentException("Deployments are incomplete", e);
}
} Deprecated!Check the current deployment states and generate a IncompleteDeploymentException
if there are mbeans waiting for depedencies. |
protected void copy(URL src,
File dest) throws IOException {
log.debug("Copying " + src + " - > " + dest);
// Validate that the dest parent directory structure exists
File dir = dest.getParentFile();
if (!dir.exists())
{
boolean created = dir.mkdirs();
if( created == false )
throw new IOException("mkdirs failed for: "+dir.getAbsolutePath());
}
// Remove any existing dest content
if( dest.exists() == true )
{
boolean deleted = Files.delete(dest);
if( deleted == false )
throw new IOException("delete of previous content failed for: "+dest.getAbsolutePath());
}
if (src.getProtocol().equals("file"))
{
File srcFile = new File(src.getFile());
if (srcFile.isDirectory())
{
log.debug("Making zip copy of: " + srcFile);
// make a jar archive of the directory
OutputStream out = new BufferedOutputStream(new FileOutputStream(dest));
JarUtils.jar(out, srcFile.listFiles());
out.close();
return;
}
}
InputStream in = new BufferedInputStream(src.openStream());
OutputStream out = new BufferedOutputStream(new FileOutputStream(dest));
Streams.copy(in, out);
out.flush();
out.close();
in.close();
} Deprecated! |
protected void createService() throws Exception {
ServerConfig config = ServerConfigLocator.locate();
// Get the temp directory location
File basedir = config.getServerTempDir();
// Set the local copy temp dir to tmp/deploy
tempDir = new File(basedir, "deploy");
// Delete any existing content
Files.delete(tempDir);
// Make sure the directory exists
tempDir.mkdirs();
// used in inLocalCopyDir
tempDirString = tempDir.toURL().toString();
// handles SuffixOrder & RelativeSuffixOrder attributes
suffixOrderHelper.initialize();
} Deprecated!The createService method is one of the ServiceMBean lifecyle operations.
(no jmx tag needed from superinterface) |
public void deploy(String urlspec) throws MalformedURLException, DeploymentException {
if( server == null )
throw new DeploymentException("The MainDeployer has been unregistered");
URL url;
try
{
url = new URL(urlspec);
}
catch (MalformedURLException e)
{
File file = new File(urlspec);
url = file.toURL();
}
deploy(url);
} Deprecated!The deploy method deploys a package identified by a
string representation of a URL. |
public void deploy(URL url) throws DeploymentException {
log.info("deploy, url="+url);
String deploymentName = contextMap.get(url);
// if it does not exist create a new deployment
if (deploymentName == null)
{
try
{
VirtualFile file = VFS.getRoot(url);
VFSDeployment deployment = deploymentFactory.createVFSDeployment(file);
delegate.addDeployment(deployment);
deploymentName = deployment.getName();
delegate.process();
// TODO: JBAS-4292
contextMap.put(url, deploymentName);
delegate.checkComplete(deployment);
}
catch(Exception e)
{
log.warn("Failed to deploy: "+url, e);
DeploymentException ex = new DeploymentException("Failed to deploy: "+url, e);
throw ex;
}
}
} Deprecated!The deploy method deploys a package identified by a URL |
public void deploy(DeploymentInfo deployment) throws DeploymentException {
// If we are already deployed return
if (isDeployed(deployment.url))
{
log.info("Package: " + deployment.url + " is already deployed");
return;
}
log.debug("Starting deployment of package: " + deployment.url);
boolean inited = false;
try
{
inited = init(deployment);
}
catch (Throwable t)
{
log.error("Could not initialise deployment: " + deployment.url, t);
DeploymentException.rethrowAsDeploymentException("Could not initialise deployment: " + deployment.url, t);
}
if ( inited )
{
create(deployment);
start(deployment);
log.debug("Deployed package: " + deployment.url);
} // end of if ()
else
{
log.debug("Deployment of package: " + deployment.url + " is waiting for an appropriate deployer.");
} // end of else
} Deprecated!The deploy method deploys a package represented by a DeploymentInfo object. |
public KernelController getController() {
return controller;
} Deprecated! |
public boolean getCopyFiles() {
return copyFiles;
} Deprecated!Get the flag indicating whether directory content will be deployed |
public Deployment getDeployment(URL url) {
String name = contextMap.get(url);
if (name == null)
return null;
Deployment dc = delegate.getDeployment(name);
log.debug("getDeployment, url="+url+", dc="+dc);
return dc;
} Deprecated!The getDeployment method returns the Deployment
object for the URL supplied. |
public DeploymentContext getDeploymentContext(URL url) {
String name = contextMap.get(url);
if (name == null)
return null;
MainDeployerStructure structure = (MainDeployerStructure) delegate;
DeploymentContext dc = structure.getDeploymentContext(name);
log.debug("getDeploymentContext, url="+url+", dc="+dc);
return dc;
} Deprecated!The getDeploymentContext method returns the DeploymentContext
object for the URL supplied. |
public DeploymentUnit getDeploymentUnit(URL url) {
String name = contextMap.get(url);
if (name == null)
return null;
MainDeployerStructure structure = (MainDeployerStructure) delegate;
DeploymentUnit du = structure.getDeploymentUnit(name);
log.debug("getDeploymentUnit, url="+url+", du="+du);
return du;
} Deprecated!The getDeploymentUnit method returns the DeploymentUnit
object for the URL supplied. |
public String[] getEnhancedSuffixOrder() {
return suffixOrderHelper.getEnhancedSuffixes();
} Deprecated!Get the enhanced suffix order |
public DeployerClient getKernelMainDeployer() {
return delegate;
} Deprecated! |
protected ObjectName getObjectName(MBeanServer server,
ObjectName name) throws MalformedObjectNameException {
return name == null ? OBJECT_NAME : name;
} Deprecated! |
public String[] getSuffixOrder() {
return suffixOrderHelper.getSuffixOrder();
} Deprecated!Get the ordering of the deployment suffixes |
public File getTempDir() {
return tempDir;
} Deprecated! |
public String getTempDirString() {
return tempDirString;
} Deprecated! |
public URL getWatchUrl(URL url) {
return url;
} Deprecated!The getWatchUrl method returns the URL that, when modified,
indicates that a redeploy is needed. |
public boolean isDeployed(String url) throws MalformedURLException {
return isDeployed(new URL(url));
} Deprecated!The isDeployed method tells you if a package identified by a string
representation of a URL is currently deployed. |
public boolean isDeployed(URL url) {
String name = contextMap.get(url);
if (name == null)
{
if (log.isTraceEnabled())
log.trace("No such context: " + url);
if (url == null)
throw new IllegalArgumentException("Null url");
String urlString = url.toString();
// remove this once the JBoss-test is updated with VFS usage
if (urlString.startsWith("vfs") == false)
return checkDeployed("vfs" + urlString);
else
return checkDeployed(urlString);
}
return checkDeployed(name);
} Deprecated!The isDeployed method tells you if a packaged identified by
a URL is deployed. |
public Collection listDeployed() {
synchronized (deploymentList)
{
log.debug("deployment list string: " + deploymentList);
return new ArrayList(deploymentList);
}
} Deprecated!The listDeployed method returns a collection of DeploymemtInfo
objects for the currently deployed packages. |
public String listDeployedAsString() {
return "< pre >" + listDeployed() + "< /pre >";
} Deprecated!Describe listDeployedAsString method here. |
public Collection listDeployedModules() {
log.debug("listDeployedModules");
HashMap map = new HashMap();
synchronized (deploymentList)
{
Collection col = new ArrayList(deploymentList);
// create a map entry for each deployment
for (Iterator it = col.iterator(); it.hasNext();)
{
DeploymentInfo info = (DeploymentInfo) it.next();
map.put(info.url, new SerializableDeploymentInfo(info));
// assign parent and sub deployments
fillParentAndChildrenSDI(info, map);
}
}
// map.values is not serializable, so we copy
return new ArrayList(map.values());
} Deprecated!The listDeployedModules method returns a collection of
SerializableDeploymentInfo objects for the currently deployed packages. |
public Collection listDeployers() {
ArrayList deployerNames = new ArrayList();
synchronized(deployers)
{
for(int n = 0; n < deployers.size(); n ++)
{
SubDeployer deployer = (SubDeployer) deployers.get(n);
ObjectName name = deployer.getServiceName();
deployerNames.add(name);
}
}
return deployerNames;
} Deprecated!The listDeployers method returns a collection of ObjectNames of
deployers registered with the MainDeployer. |
public Collection listIncompletelyDeployed() {
List id = new ArrayList();
List copy;
synchronized (deploymentList)
{
copy = new ArrayList(deploymentList);
}
for (Iterator i = copy.iterator(); i.hasNext();)
{
DeploymentInfo di = (DeploymentInfo)i.next();
if (!"Deployed".equals(di.status) && !"Starting".equals(di.status))
{
id.add(di);
} // end of if ()
} // end of for ()
return id;
} Deprecated!The listIncompletelyDeployed method returns a list of packages that have
not deployed completely. The toString method will include any exception in the status
field. |
public Collection listWaitingForDeployer() {
synchronized (waitingDeployments)
{
return new ArrayList(waitingDeployments);
}
} Deprecated!The listWaitingForDeployer method returns a collection
of the packages that currently have no identified deployer. |
public void redeploy(String urlspec) throws MalformedURLException, DeploymentException {
redeploy(new URL(urlspec));
} Deprecated!Describe redeploy method here. |
public void redeploy(URL url) throws DeploymentException {
undeploy(url);
deploy(url);
} Deprecated!Describe redeploy method here. |
public void redeploy(DeploymentInfo sdi) throws DeploymentException {
try
{
undeploy(sdi);
}
catch (Throwable t)
{
log.info("Throwable from undeployment attempt: ", t);
} // end of try-catch
sdi.setServer(server);
deploy(sdi);
} Deprecated!Describe redeploy method here. |
public void removeDeployer(SubDeployer deployer) {
log.debug("Removing deployer: " + deployer);
ObjectName deployerName = deployer.getServiceName();
boolean removed = false;
synchronized(deployers)
{
removed = deployers.remove(deployer);
try
{
String[] suffixes = (String[]) server.getAttribute(deployerName, "EnhancedSuffixes");
suffixOrderHelper.removeEnhancedSuffixes(suffixes);
}
catch(Exception e)
{
log.debug(deployerName + " does not support EnhancedSuffixes");
suffixOrderHelper.removeSuffixes(deployer.getSuffixes(), deployer.getRelativeOrder());
}
}
// Send a notification about the deployer removal
if (removed)
{
Notification msg = new Notification(REMOVE_DEPLOYER, this, getNextNotificationSequenceNumber());
msg.setUserData(deployerName);
sendNotification(msg);
}
List copy;
synchronized (deploymentList)
{
copy = new ArrayList(deploymentList);
}
for (Iterator i = copy.iterator(); i.hasNext(); )
{
DeploymentInfo di = (DeploymentInfo)i.next();
if (di.deployer == deployer)
{
undeploy(di);
di.deployer = null;
synchronized (waitingDeployments)
{
waitingDeployments.add(di);
}
}
}
} Deprecated!The removeDeployer method unregisters a deployer with the MainDeployer.
Deployed packages deployed with this deployer are undeployed. |
public void setController(KernelController controller) {
this.controller = controller;
} Deprecated! |
public void setCopyFiles(boolean copyFiles) {
this.copyFiles = copyFiles;
} Deprecated!Set the flag indicating whether directory content will be deployed. The
default value is taken from the jboss.deploy.localcopy system
property. |
public void setEnhancedSuffixOrder(String[] enhancedSuffixOrder) {
suffixOrderHelper.setEnhancedSuffixes(enhancedSuffixOrder);
} Deprecated!Set the enhanced suffix order |
public void setKernelMainDeployer(DeployerClient delegate) {
this.delegate = delegate;
} Deprecated! |
public void setServiceController(ObjectName serviceController) {
this.serviceController = serviceController;
} Deprecated!Describe setServiceController method here. |
public void setTempDir(File tempDir) {
this.tempDir = tempDir;
} Deprecated! |
public void shutdown() {
// if we shutdown in the middle of a scan, it still might be possible that we try to redeploy
// things we are busy killing...
int deployCounter = 0;
// undeploy everything in sight
List copy;
synchronized (deploymentList)
{
copy = new ArrayList(deploymentList);
}
for (ListIterator i = copy.listIterator(copy.size()); i.hasPrevious(); )
{
try
{
undeploy((DeploymentInfo)i.previous(), true);
deployCounter++;
}
catch (Exception e)
{
log.info("exception trying to undeploy during shutdown", e);
}
}
// Help GC
this.deployers.clear();
this.deploymentMap.clear();
this.deploymentList.clear();
this.waitingDeployments.clear();
this.tempDir = null;
log.debug("Undeployed " + deployCounter + " deployed packages");
} Deprecated!The shutdown method undeploys all deployed packages in
reverse order of their deployement. |
public void start(String urlspec) throws MalformedURLException, DeploymentException {
throw new DeploymentException("Not supported");
} Deprecated!The start method starts a package identified by a URL |
public void stop(String urlspec) throws MalformedURLException, DeploymentException {
throw new DeploymentException("Not supported");
} Deprecated!The stop method stops a package identified by a URL |
public void undeploy(String urlspec) throws MalformedURLException, DeploymentException {
undeploy(new URL(urlspec));
} Deprecated!The undeploy method undeploys a package identified by a string
representation of a URL. |
public void undeploy(URL url) throws DeploymentException {
String deploymentName = contextMap.remove(url);
if (deploymentName != null)
{
try
{
delegate.removeDeployment(deploymentName);
delegate.process();
}
catch(Exception e)
{
DeploymentException ex = new DeploymentException("Error during undeploy of: "+url, e);
throw ex;
}
}
else
{
log.warn("undeploy '" + url + "' : package not deployed");
}
} Deprecated!The undeploy method undeploys a package identified by a URL |
public void undeploy(DeploymentInfo di) {
undeploy(di, false);
} Deprecated!The undeploy method undeploys a package represented by a
DeploymentInfo object. |
protected void undeploy(DeploymentInfo di,
boolean isShutdown) {
log.debug("Undeploying "+di.url);
stop(di);
destroy(di);
} Deprecated! |