[jboss-cvs] JBossAS SVN: r111385 - in projects/jboss-deployers/branches/Branch_2_0/deployers-impl/src: test/java/org/jboss/test/deployers/main/test and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon May 16 15:22:50 EDT 2011
Author: alesj
Date: 2011-05-16 15:22:50 -0400 (Mon, 16 May 2011)
New Revision: 111385
Modified:
projects/jboss-deployers/branches/Branch_2_0/deployers-impl/src/main/java/org/jboss/deployers/plugins/sort/SortedDeployers.java
projects/jboss-deployers/branches/Branch_2_0/deployers-impl/src/test/java/org/jboss/test/deployers/main/test/DynamicDeployerUsageTestCase.java
Log:
Port JBDEPLOY-274.
Modified: projects/jboss-deployers/branches/Branch_2_0/deployers-impl/src/main/java/org/jboss/deployers/plugins/sort/SortedDeployers.java
===================================================================
--- projects/jboss-deployers/branches/Branch_2_0/deployers-impl/src/main/java/org/jboss/deployers/plugins/sort/SortedDeployers.java 2011-05-16 19:04:04 UTC (rev 111384)
+++ projects/jboss-deployers/branches/Branch_2_0/deployers-impl/src/main/java/org/jboss/deployers/plugins/sort/SortedDeployers.java 2011-05-16 19:22:50 UTC (rev 111385)
@@ -1,3 +1,24 @@
+/*
+* 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.plugins.sort;
import java.util.ArrayList;
@@ -12,13 +33,13 @@
/**
* @author <a href="mailto:bill at burkecentral.com">Bill Burke</a>
+ * @author <a href="ales.justin at jboss.org">Ales Justin</a>
* @version $Revision: 1 $
*/
public class SortedDeployers
{
private static class Entry
{
-
public Deployer deployer;
public int index;
@@ -66,8 +87,8 @@
Map<String, List<Entry>> outputMap = new HashMap<String, List<Entry>>();
Map<String, List<Entry>> inputMap = new HashMap<String, List<Entry>>();
- ArrayList<Entry> entries = new ArrayList<Entry>();
- ArrayList<Deployer> deployers = new ArrayList<Deployer>();
+ List<Entry> entries = new ArrayList<Entry>();
+ volatile List<Deployer> deployers = new ArrayList<Deployer>();
public void addOutputs(Entry deployer)
{
@@ -108,11 +129,12 @@
if (entries.size() == 0)
{
insertAt(n);
- deployers.clear();
+ List<Deployer> copy = new ArrayList<Deployer>();
for (Entry entry : entries)
{
- deployers.add(entry.deployer);
+ copy.add(entry.deployer);
}
+ deployers = copy;
return;
}
@@ -123,11 +145,12 @@
// For some reason, something depends on a new list within MC/VDF
// be careful if you change this
- deployers = new ArrayList<Deployer>();
+ List<Deployer> copy = new ArrayList<Deployer>();
for (Entry entry : entries)
{
- deployers.add(entry.deployer);
+ copy.add(entry.deployer);
}
+ deployers = copy;
}
public void removeDeployer(Deployer d)
@@ -136,14 +159,15 @@
int esize = entries.size();
for (int i = 0; i < esize; i++)
{
- if (entries.get(0).deployer.equals(d))
+ Entry entry = entries.get(i);
+ if (entry.deployer.equals(d))
{
- removed = entries.get(0);
+ removed = entry;
removeAt(i);
break;
}
}
- if (d.getInputs() != null)
+ if (removed != null && d.getInputs() != null)
{
for (String input : d.getInputs())
{
@@ -154,7 +178,7 @@
}
}
}
- if (d.getOutputs() != null)
+ if (removed != null && d.getOutputs() != null)
{
for (String output : d.getOutputs())
{
@@ -165,16 +189,17 @@
}
}
}
- deployers = new ArrayList<Deployer>();
+ List<Deployer> copy = new ArrayList<Deployer>();
for (Entry entry : entries)
{
- deployers.add(entry.deployer);
+ copy.add(entry.deployer);
}
+ deployers = copy;
}
public List<Deployer> getDeployers()
{
- return deployers;
+ return Collections.unmodifiableList(deployers);
}
private void traverseOutputs(Entry n, IdentityHashMap<Entry, Entry> visited)
Modified: projects/jboss-deployers/branches/Branch_2_0/deployers-impl/src/test/java/org/jboss/test/deployers/main/test/DynamicDeployerUsageTestCase.java
===================================================================
--- projects/jboss-deployers/branches/Branch_2_0/deployers-impl/src/test/java/org/jboss/test/deployers/main/test/DynamicDeployerUsageTestCase.java 2011-05-16 19:04:04 UTC (rev 111384)
+++ projects/jboss-deployers/branches/Branch_2_0/deployers-impl/src/test/java/org/jboss/test/deployers/main/test/DynamicDeployerUsageTestCase.java 2011-05-16 19:22:50 UTC (rev 111385)
@@ -46,12 +46,17 @@
public void testAddRemove() throws Exception
{
- MarkerDeployer md = new MarkerDeployer();
- DeployerClient main = createMainDeployer(md);
+ // make sure md1 is before md2
+ MarkerDeployer md1 = new MarkerDeployer();
+ md1.addOutput(MarkerDeployer.class);
+ MarkerDeployer md2 = new MarkerDeployer();
+ md2.addInput(MarkerDeployer.class);
+
+ DeployerClient main = createMainDeployer(md1, md2);
Deployment deployment = createSimpleDeployment("test");
main.deploy(deployment);
- removeDeployer(main, md);
+ removeDeployer(main, md2);
main.undeploy(deployment);
- assertNull(md.unit);
+ assertNull(md2.unit);
}
}
More information about the jboss-cvs-commits
mailing list