[jboss-cvs] JBossAS SVN: r59404 - in projects/microcontainer/branches/2_0/deployers/src/main/org/jboss/deployers: plugins/deployment spi/deployment
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sun Jan 7 12:38:48 EST 2007
Author: scott.stark at jboss.org
Date: 2007-01-07 12:38:44 -0500 (Sun, 07 Jan 2007)
New Revision: 59404
Modified:
projects/microcontainer/branches/2_0/deployers/src/main/org/jboss/deployers/plugins/deployment/MainDeployerImpl.java
projects/microcontainer/branches/2_0/deployers/src/main/org/jboss/deployers/spi/deployment/MainDeployer.java
Log:
Add a process(begin,end) to allow partial processing of deployments through select deployers.
Modified: projects/microcontainer/branches/2_0/deployers/src/main/org/jboss/deployers/plugins/deployment/MainDeployerImpl.java
===================================================================
--- projects/microcontainer/branches/2_0/deployers/src/main/org/jboss/deployers/plugins/deployment/MainDeployerImpl.java 2007-01-07 17:30:36 UTC (rev 59403)
+++ projects/microcontainer/branches/2_0/deployers/src/main/org/jboss/deployers/plugins/deployment/MainDeployerImpl.java 2007-01-07 17:38:44 UTC (rev 59404)
@@ -73,6 +73,7 @@
* TODO implement attachment flow see comment in {@link Deployer}
*
* @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author Scott.Stark at jboss.org
* @version $Revision: 1.1 $
*/
public class MainDeployerImpl implements MainDeployer
@@ -109,7 +110,7 @@
/** The deploy work */
private List<DeploymentContext> deploy = new CopyOnWriteArrayList<DeploymentContext>();
-
+
/**
* Get the structure deployers
*
@@ -372,13 +373,37 @@
return Collections.unmodifiableCollection(topLevelDeployments.values());
}
+ public int getDeployerOrderLessThan(int end)
+ {
+ int max = -1;
+ for(Deployer deployer : deployers)
+ {
+ int order = deployer.getRelativeOrder();
+ if( order < end )
+ max = order;
+ }
+ return max;
+ }
+
public void process()
{
+ process(-1, Integer.MAX_VALUE);
+ }
+ /**
+ * 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)
+ {
if (shutdown.get())
throw new IllegalStateException("The main deployer is shutdown");
List<DeploymentContext> undeployContexts = null;
List<DeploymentContext> deployContexts = null;
+ List<DeploymentContext> processedContexts = new ArrayList<DeploymentContext>();
Deployer[] theDeployers;
synchronized (this)
{
@@ -395,7 +420,6 @@
if (deploy.isEmpty() == false)
{
deployContexts = new ArrayList<DeploymentContext>(deploy);
- deploy.clear();
}
theDeployers = deployers.toArray(new Deployer[deployers.size()]);
}
@@ -420,10 +444,32 @@
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)
{
@@ -441,7 +487,7 @@
// Unwind the deployment
for (int j = i-1; j >= 0; --j)
{
- Deployer other = theDeployers[j];
+ Deployer other = validDeployers.get(j);
prepareUndeploy(other, context, true);
}
context.removeClassLoader();
@@ -459,10 +505,13 @@
isJar = true;
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;
}
private void prepareUndeploy(Deployer deployer, DeploymentContext context, boolean doComponents)
@@ -480,8 +529,9 @@
prepareUndeploy(deployer, theComponents[i], true);
}
}
+
}
-
+
private void commitDeploy(Deployer deployer, DeploymentContext context, Set<DeploymentContext> components) throws DeploymentException
{
DeploymentContext[] theComponents = null;
@@ -517,8 +567,9 @@
prepareUndeploy(deployer, context, false);
throw e;
}
+
}
-
+
public void shutdown()
{
while (topLevelDeployments.isEmpty() == false)
@@ -585,46 +636,6 @@
}
/**
- * Determine the structure
- *
- * @param context the context
- * @param theDeployers the deployers
- * @return true when determined
- * @throws DeploymentException for any problem
- private boolean determineStructure(DeploymentContext context) throws DeploymentException
- {
- boolean trace = log.isTraceEnabled();
- if (trace)
- log.trace("Trying to determine structure: " + context.getName());
-
- boolean result = this.structureDeployers.determineStructure(context);
- for (StructureDeployer deployer : theDeployers)
- {
- if (deployer.determineStructure(context, deployers))
- {
- result = true;
- break;
- }
- }
- if (result == false && context.isCandidate() == false)
- throw new DeploymentException("No structural deployer recognised the deployment. " + context.getName());
-
- Set<DeploymentContext> children = context.getChildren();
- for (DeploymentContext child : children)
- {
- if (child.getRoot() == null)
- throw new DeploymentException("Unable to determine structure context has no root: " + context.getName());
-
- // This must be a candidate that doesn't match
- if (determineStructure(child, theDeployers) == false)
- context.removeChild(child);
- }
-
- return result;
- }
- */
-
- /**
* Add a context
*
* @param context the context
Modified: projects/microcontainer/branches/2_0/deployers/src/main/org/jboss/deployers/spi/deployment/MainDeployer.java
===================================================================
--- projects/microcontainer/branches/2_0/deployers/src/main/org/jboss/deployers/spi/deployment/MainDeployer.java 2007-01-07 17:30:36 UTC (rev 59403)
+++ projects/microcontainer/branches/2_0/deployers/src/main/org/jboss/deployers/spi/deployment/MainDeployer.java 2007-01-07 17:38:44 UTC (rev 59404)
@@ -112,12 +112,25 @@
boolean removeDeploymentContext(String name) throws DeploymentException;
/**
- * Process the outstanding deployments
+ * Process the outstanding deployments.
+ * This is equivalent to calling process(-1, Integer.MAX_VALUE).
*/
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
+ */
+ Collection<DeploymentContext> process(int begin, int end);
+
+ /**
* Shutdown. Removes all the deployments.
*/
void shutdown();
+
}
More information about the jboss-cvs-commits
mailing list