[jboss-cvs] JBossAS SVN: r60094 - in projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers: spi/deployment and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Jan 29 00:18:26 EST 2007
Author: scott.stark at jboss.org
Date: 2007-01-29 00:18:26 -0500 (Mon, 29 Jan 2007)
New Revision: 60094
Modified:
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployment/MainDeployerImpl.java
projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployment/MainDeployer.java
Log:
Add a ProcessMode notion and replace the process(int begin, int end) with a process(ProcessMode mode).
Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployment/MainDeployerImpl.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployment/MainDeployerImpl.java 2007-01-29 05:00:18 UTC (rev 60093)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployment/MainDeployerImpl.java 2007-01-29 05:18:26 UTC (rev 60094)
@@ -403,16 +403,13 @@
public void process()
{
- process(-1, Integer.MAX_VALUE);
+ process(ProcessMode.Runtime);
}
/**
* Process the new deployments.
*
- * TODO: Only deployment uses begin/end. Does it make sense to have
- * partial undeployment?
- *
*/
- public Collection<DeploymentContext> process(int begin, int end)
+ public Collection<DeploymentContext> process(ProcessMode mode)
{
if (shutdown.get())
throw new IllegalStateException("The main deployer is shutdown");
@@ -436,6 +433,7 @@
if (deploy.isEmpty() == false)
{
deployContexts = new ArrayList<DeploymentContext>(deploy);
+ deploy.clear();
}
theDeployers = deployers.toArray(new Deployer[deployers.size()]);
}
@@ -446,7 +444,10 @@
{
Deployer deployer = theDeployers[i];
for (DeploymentContext context : undeployContexts)
+ {
prepareUndeploy(deployer, context, true);
+ commitUndeploy(deployer, context, true);
+ }
}
for (DeploymentContext context : undeployContexts)
{
@@ -460,38 +461,18 @@
if (deployContexts != null)
{
- // Restrict deployers to begin/end range
- boolean validDeployersIncludesLastDeployer = false;
- ArrayList<Deployer> validDeployers = new ArrayList<Deployer>();
for (int i = 0; i < theDeployers.length; ++i)
{
Deployer deployer = theDeployers[i];
- int order = deployer.getRelativeOrder();
- // If the deployer is in the [begin, end) range
- if( (begin <= order && order < end) ||
- // Integer.MAX_VALUE has to be treated specially since its used by deployers
- // TODO change the default deployer order to Integer.MAX_VALUE-1
- (begin <= order && end == Integer.MAX_VALUE) )
- {
- validDeployers.add(deployer);
- if( i == theDeployers.length-1 )
- validDeployersIncludesLastDeployer = true;
- }
- }
- // Clear the deployments if the all deployments
- if (validDeployersIncludesLastDeployer)
- deploy.clear();
- for (int i = 0; i < validDeployers.size(); ++i)
- {
- Deployer deployer = validDeployers.get(i);
-
Set<DeploymentContext> errors = new HashSet<DeploymentContext>();
for (DeploymentContext context : deployContexts)
{
try
{
+ context.getTransientAttachments().addAttachment(ProcessMode.class, mode);
Set<DeploymentContext> components = context.getComponents();
+ prepareDeploy(deployer, context, components);
commitDeploy(deployer, context, components);
}
catch (DeploymentException e)
@@ -503,7 +484,7 @@
// Unwind the deployment
for (int j = i-1; j >= 0; --j)
{
- Deployer other = validDeployers.get(j);
+ Deployer other = theDeployers[j];
prepareUndeploy(other, context, true);
}
context.removeClassLoader();
@@ -519,14 +500,14 @@
VirtualFile root = context.getRoot();
if (root != null && root.getName().endsWith(".jar"))
isJar = true;
- if (validDeployersIncludesLastDeployer && context.isDeployed() == false && isJar == false)
+ if (context.isDeployed() == false && isJar == false)
missingDeployers.put(name, context);
- // TODO: Should there be a PARTIAL_DEPLOYED state for end < max deployer
context.setState(DEPLOYED);
processedContexts.add(context);
log.debug("Deployed: " + name);
}
}
+
return processedContexts;
}
@@ -546,16 +527,70 @@
}
}
}
-
- private void commitDeploy(Deployer deployer, DeploymentContext context, Set<DeploymentContext> components) throws DeploymentException
+ private void commitUndeploy(Deployer deployer, DeploymentContext context, boolean doComponents)
{
+ DeploymentUnit unit = context.getDeploymentUnit();
+ deployer.commitUndeploy(unit);
+
+ if (doComponents)
+ {
+ Set<DeploymentContext> components = context.getComponents();
+ if (components != null && components.isEmpty() == false)
+ {
+ DeploymentContext[] theComponents = components.toArray(new DeploymentContext[components.size()]);
+ for (int i = theComponents.length-1; i >= 0; --i)
+ commitUndeploy(deployer, theComponents[i], true);
+ }
+ }
+ }
+
+ private void prepareDeploy(Deployer deployer, DeploymentContext context, Set<DeploymentContext> components)
+ throws DeploymentException
+ {
DeploymentContext[] theComponents = null;
if (components != null && components.isEmpty() == false)
theComponents = components.toArray(new DeploymentContext[components.size()]);
DeploymentUnit unit = context.getDeploymentUnit();
+ deployer.prepareDeploy(unit);
+
+ try
+ {
+ if (theComponents != null)
+ {
+ for (int i = 0; i < theComponents.length; ++i)
+ {
+ try
+ {
+ Set<DeploymentContext> componentComponents = theComponents[i].getComponents();
+ prepareDeploy(deployer, theComponents[i], componentComponents);
+ }
+ catch (DeploymentException e)
+ {
+ // Unwind the previous components
+ for (int j = i-1; j >=0; --j)
+ prepareUndeploy(deployer, theComponents[j], true);
+ throw e;
+ }
+ }
+ }
+ }
+ catch (DeploymentException e)
+ {
+ prepareUndeploy(deployer, context, false);
+ throw e;
+ }
+ }
+ private void commitDeploy(Deployer deployer, DeploymentContext context, Set<DeploymentContext> components)
+ throws DeploymentException
+ {
+ DeploymentContext[] theComponents = null;
+ if (components != null && components.isEmpty() == false)
+ theComponents = components.toArray(new DeploymentContext[components.size()]);
+
+ DeploymentUnit unit = context.getDeploymentUnit();
deployer.commitDeploy(unit);
-
+
try
{
if (theComponents != null)
Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployment/MainDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployment/MainDeployer.java 2007-01-29 05:00:18 UTC (rev 60093)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployment/MainDeployer.java 2007-01-29 05:18:26 UTC (rev 60094)
@@ -43,6 +43,13 @@
*/
public interface MainDeployer
{
+ public enum ProcessMode {
+ /** Partial processing for validation of deployments metadata, dependencies */
+ Validation,
+ /** Full processing to runtime microcontainer components */
+ Runtime
+ };
+
/**
* Get a deployment context
*
@@ -115,20 +122,15 @@
/**
* Process the outstanding deployments.
- * This is equivalent to calling process(-1, Integer.MAX_VALUE).
+ * Equivalent to process(ProcessMode.Runtime);
+ *
*/
void process();
/**
- * Process all the outstanding deployments through the deployers whose
- * relative order is in the range [begin, end), which begin <= ro < end.
- *
- * @param begin - the minimum relative order value of of deployers to
- * use
- * @param end - the max relative order value of of deployers to
- * use
- * @return the top-level DeploymentContexts that were processed
+ * Process the outstanding deployments.
+ * @param mode, the mode in which processing should be done.
*/
- Collection<DeploymentContext> process(int begin, int end);
+ Collection<DeploymentContext> process(ProcessMode mode);
/**
* Shutdown. Removes all the deployments.
More information about the jboss-cvs-commits
mailing list