[jboss-cvs] JBossAS SVN: r69551 - in projects/microcontainer/trunk: deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/helpers and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Feb 1 18:01:09 EST 2008
Author: alesj
Date: 2008-02-01 18:01:08 -0500 (Fri, 01 Feb 2008)
New Revision: 69551
Added:
projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/helpers/RelativeDeploymentContextComparator.java
projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/helpers/RevertedDeploymentContextComparator.java
Removed:
projects/microcontainer/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/structure/war/ExplicitOrderWARStructure.java
Modified:
projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/main/MainDeployerImpl.java
projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/helpers/AbstractStructureDeployer.java
Log:
Top deployment context order.
TODO tests.
Modified: projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/main/MainDeployerImpl.java
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/main/MainDeployerImpl.java 2008-02-01 22:31:16 UTC (rev 69550)
+++ projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/main/MainDeployerImpl.java 2008-02-01 23:01:08 UTC (rev 69551)
@@ -22,11 +22,12 @@
package org.jboss.deployers.plugins.main;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.Comparator;
import java.util.List;
import java.util.Map;
-import java.util.Arrays;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -41,6 +42,8 @@
import org.jboss.deployers.structure.spi.DeploymentContext;
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.deployers.structure.spi.StructuralDeployers;
+import org.jboss.deployers.structure.spi.helpers.RelativeDeploymentContextComparator;
+import org.jboss.deployers.structure.spi.helpers.RevertedDeploymentContextComparator;
import org.jboss.deployers.structure.spi.main.MainDeployerStructure;
import org.jboss.logging.Logger;
import org.jboss.managed.api.ManagedDeployment;
@@ -94,7 +97,29 @@
/** The process lock */
private ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
+ /** The top deployment context comparator */
+ private Comparator<DeploymentContext> comparator;
+ private Comparator<DeploymentContext> reverted;
+
+ public MainDeployerImpl()
+ {
+ setComparator(RelativeDeploymentContextComparator.INSTANCE);
+ }
+
/**
+ * Set the top deployment context comparator.
+ *
+ * @param comparator the deployment context comparator
+ */
+ public void setComparator(Comparator<DeploymentContext> comparator)
+ {
+ if (comparator == null)
+ throw new IllegalArgumentException("Null comparator");
+ this.comparator = comparator;
+ this.reverted = new RevertedDeploymentContextComparator(comparator);
+ }
+
+ /**
* Get the deployers
*
* @return the deployers
@@ -487,11 +512,13 @@
undeployContexts = new ArrayList<DeploymentContext>(undeploy.size());
for (int i = undeploy.size() - 1; i >= 0; --i)
undeployContexts.add(undeploy.get(i));
+ Collections.sort(undeployContexts, reverted);
undeploy.clear();
}
if (deploy.isEmpty() == false)
{
deployContexts = new ArrayList<DeploymentContext>(deploy);
+ Collections.sort(deployContexts, comparator);
deploy.clear();
}
Added: projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/helpers/RelativeDeploymentContextComparator.java
===================================================================
--- projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/helpers/RelativeDeploymentContextComparator.java (rev 0)
+++ projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/helpers/RelativeDeploymentContextComparator.java 2008-02-01 23:01:08 UTC (rev 69551)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.deployers.structure.spi.helpers;
+
+import java.io.Serializable;
+import java.util.Comparator;
+
+import org.jboss.deployers.structure.spi.DeploymentContext;
+
+/**
+ * RelativeDeploymentContextComparator.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class RelativeDeploymentContextComparator implements Comparator<DeploymentContext>, Serializable
+{
+ private static final long serialVersionUID = 4933914203587980050L;
+
+ /** The singleton */
+ public static final RelativeDeploymentContextComparator INSTANCE = new RelativeDeploymentContextComparator();
+
+ public int compare(DeploymentContext o1, DeploymentContext o2)
+ {
+ return o1.getRelativeOrder() - o2.getRelativeOrder();
+ }
+
+ Object readResolve()
+ {
+ return INSTANCE;
+ }
+}
Added: projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/helpers/RevertedDeploymentContextComparator.java
===================================================================
--- projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/helpers/RevertedDeploymentContextComparator.java (rev 0)
+++ projects/microcontainer/trunk/deployers-structure-spi/src/main/org/jboss/deployers/structure/spi/helpers/RevertedDeploymentContextComparator.java 2008-02-01 23:01:08 UTC (rev 69551)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.deployers.structure.spi.helpers;
+
+import java.io.Serializable;
+import java.util.Comparator;
+
+import org.jboss.deployers.structure.spi.DeploymentContext;
+
+/**
+ * RevertedDeploymentContextComparator.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class RevertedDeploymentContextComparator implements Comparator<DeploymentContext>, Serializable
+{
+ private static final long serialVersionUID = 4933914203587980050L;
+ private Comparator<DeploymentContext> comparator;
+
+ public RevertedDeploymentContextComparator(Comparator<DeploymentContext> comparator)
+ {
+ if (comparator == null)
+ throw new IllegalArgumentException("Null comparator");
+ this.comparator = comparator;
+ }
+
+ public int compare(DeploymentContext o1, DeploymentContext o2)
+ {
+ return comparator.compare(o1, o2) * (-1);
+ }
+}
Deleted: projects/microcontainer/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/structure/war/ExplicitOrderWARStructure.java
===================================================================
--- projects/microcontainer/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/structure/war/ExplicitOrderWARStructure.java 2008-02-01 22:31:16 UTC (rev 69550)
+++ projects/microcontainer/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/structure/war/ExplicitOrderWARStructure.java 2008-02-01 23:01:08 UTC (rev 69551)
@@ -1,49 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.deployers.vfs.plugins.structure.war;
-
-import org.jboss.deployers.spi.structure.ContextInfo;
-import org.jboss.deployers.spi.structure.StructureMetaData;
-import org.jboss.virtual.VirtualFile;
-
-/**
- * ExplicitOrderWARStructure.
- * By default we put war context at the end.
- *
- * @author <a href="ales.justin at jboss.com">Ales Justin</a>
- */
-public class ExplicitOrderWARStructure extends WARStructure
-{
- private int contextOrder = Integer.MAX_VALUE;
-
- protected ContextInfo createContext(VirtualFile root, String metaDataPath, StructureMetaData structureMetaData)
- {
- ContextInfo contextInfo = super.createContext(root, metaDataPath, structureMetaData);
- contextInfo.setRelativeOrder(contextOrder);
- return contextInfo;
- }
-
- public void setContextOrder(int contextOrder)
- {
- this.contextOrder = contextOrder;
- }
-}
Modified: projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/helpers/AbstractStructureDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/helpers/AbstractStructureDeployer.java 2008-02-01 22:31:16 UTC (rev 69550)
+++ projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/helpers/AbstractStructureDeployer.java 2008-02-01 23:01:08 UTC (rev 69551)
@@ -55,7 +55,10 @@
/** The candidate structure visitor factory */
private CandidateStructureVisitorFactory candidateStructureVisitorFactory = DefaultCandidateStructureVisitorFactory.INSTANCE;
-
+
+ /** The context info order */
+ private Integer contextInfoOrder;
+
/**
* Get the relative path between two virtual files
*
@@ -101,8 +104,12 @@
{
this.relativeOrder = order;
}
-
+ public void setContextInfoOrder(Integer contextInfoOrder)
+ {
+ this.contextInfoOrder = contextInfoOrder;
+ }
+
/**
* Get the candidateStructureVisitorFactory.
*
@@ -269,6 +276,10 @@
result = StructureMetaDataFactory.createContextInfo("", metaDataPath, null);
else
result = StructureMetaDataFactory.createContextInfo("", null);
+
+ if (result != null && contextInfoOrder != null)
+ result.setRelativeOrder(contextInfoOrder);
+
structureMetaData.addContext(result);
if (trace)
log.trace("Added context " + result + " from " + root.getName());
More information about the jboss-cvs-commits
mailing list