You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@continuum.apache.org by ct...@apache.org on 2009/08/18 09:34:53 UTC

svn commit: r805299 - in /continuum/trunk: continuum-api/src/main/java/org/apache/continuum/utils/ continuum-api/src/test/java/org/ continuum-api/src/test/java/org/apache/ continuum-api/src/test/java/org/apache/continuum/ continuum-api/src/test/java/or...

Author: ctan
Date: Tue Aug 18 07:34:52 2009
New Revision: 805299

URL: http://svn.apache.org/viewvc?rev=805299&view=rev
Log:
[CONTINUUM-2194] use plexus-spring in data management cli
merge -r805286:805287 of 1.3.x branch

Added:
    continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/ProjectSorter.java
    continuum/trunk/continuum-api/src/test/java/org/
    continuum/trunk/continuum-api/src/test/java/org/apache/
    continuum/trunk/continuum-api/src/test/java/org/apache/continuum/
    continuum/trunk/continuum-api/src/test/java/org/apache/continuum/utils/
    continuum/trunk/continuum-api/src/test/java/org/apache/continuum/utils/ProjectSorterTest.java
    continuum/trunk/continuum-data-management/data-management-cli/src/main/java/org/apache/maven/continuum/management/util/
    continuum/trunk/continuum-data-management/data-management-cli/src/main/java/org/apache/maven/continuum/management/util/PlexusApplicationContextDelegate.java
    continuum/trunk/continuum-data-management/data-management-cli/src/main/java/org/apache/maven/continuum/management/util/PlexusFileSystemXmlApplicationContext.java
Removed:
    continuum/trunk/continuum-commons/src/main/java/org/apache/continuum/utils/ProjectSorter.java
    continuum/trunk/continuum-commons/src/test/java/org/apache/continuum/utils/ProjectSorterTest.java
Modified:
    continuum/trunk/continuum-commons/src/main/resources/META-INF/spring-context.xml
    continuum/trunk/continuum-data-management/data-management-cli/pom.xml
    continuum/trunk/continuum-data-management/data-management-cli/src/main/java/org/apache/maven/continuum/management/DataManagementCli.java
    continuum/trunk/continuum-data-management/data-management-jdo/pom.xml

Added: continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/ProjectSorter.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/ProjectSorter.java?rev=805299&view=auto
==============================================================================
--- continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/ProjectSorter.java (added)
+++ continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/ProjectSorter.java Tue Aug 18 07:34:52 2009
@@ -0,0 +1,176 @@
+package org.apache.continuum.utils;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.model.project.ProjectDependency;
+import org.codehaus.plexus.util.dag.CycleDetectedException;
+import org.codehaus.plexus.util.dag.DAG;
+import org.codehaus.plexus.util.dag.TopologicalSorter;
+import org.slf4j.Logger;
+
+/**
+ * Sort projects by dependencies.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ * @version $Id: ProjectSorter.java 777411 2009-05-22 07:13:37Z ctan $
+ */
+public class ProjectSorter
+{
+    private ProjectSorter()
+    {
+        // no touchy...
+    }
+
+    /**
+     * Sort a list of projects.
+     * <ul>
+     * <li>collect all the vertices for the projects that we want to build.</li>
+     * <li>iterate through the deps of each project and if that dep is within
+     * the set of projects we want to build then add an edge, otherwise throw
+     * the edge away because that dependency is not within the set of projects
+     * we are trying to build. we assume a closed set.</li>
+     * <li>do a topo sort on the graph that remains.</li>
+     * </ul>
+     */
+    public static List<Project> getSortedProjects( Collection<Project> projects, Logger logger )
+    {
+        DAG dag = new DAG();
+
+        Map<String, Project> projectMap = new HashMap<String, Project>();
+
+        for ( Project project : projects )
+        {
+            String id = getProjectId( project );
+
+            if ( dag.getVertex( id ) != null )
+            {
+                logger.warn( "Project '" + id + "' is duplicated in the reactor." );
+            }
+
+            dag.addVertex( id );
+
+            projectMap.put( id, project );
+        }
+
+        for ( Project project : projects )
+        {
+            String id = getProjectId( project );
+            
+            String projectGroupId = "[" + project.getProjectGroup().getId() + "]";
+
+            // Dependencies
+            for ( Object o : project.getDependencies() )
+            {
+                ProjectDependency dependency = (ProjectDependency) o;
+
+                String dependencyId = projectGroupId + ":" + getDependencyId( dependency );
+
+                if ( dag.getVertex( dependencyId ) != null )
+                {
+                    try
+                    {
+                        dag.addEdge( id, dependencyId );
+                    }
+                    catch ( CycleDetectedException e )
+                    {
+                        logger.warn( "Ignore cycle detected in project dependencies: " + e.getMessage() );
+                    }
+                }
+            }
+
+            // Parent
+            ProjectDependency parent = project.getParent();
+
+            if ( parent != null )
+            {
+                String parentId = projectGroupId + ":" + getDependencyId( parent );
+
+                if ( dag.getVertex( parentId ) != null )
+                {
+                    // Parent is added as an edge, but must not cause a cycle - so we remove any other edges it has in conflict
+                    if ( dag.hasEdge( parentId, id ) )
+                    {
+                        dag.removeEdge( parentId, id );
+                    }
+                    try
+                    {
+                        dag.addEdge( id, parentId );
+                    }
+                    catch ( CycleDetectedException e )
+                    {
+                        logger.warn( "Ignore cycle detected in project parent: " + e.getMessage() );
+                    }
+                }
+            }
+        }
+
+        List<Project> sortedProjects = new ArrayList<Project>();
+
+        for ( Object o : TopologicalSorter.sort( dag ) )
+        {
+            String id = (String) o;
+
+            sortedProjects.add( projectMap.get( id ) );
+        }
+
+        return sortedProjects;
+    }
+
+    private static String getProjectId( Project project )
+    {
+        String groupId;
+
+        String artifactId;
+
+        if ( project.getGroupId() == null )
+        {
+            groupId = project.getName();
+        }
+        else
+        {
+            groupId = project.getGroupId();
+        }
+
+        if ( project.getArtifactId() == null )
+        {
+            artifactId = project.getName();
+        }
+        else
+        {
+            artifactId = project.getArtifactId();
+        }
+        
+        String projectGroupId = "[" + project.getProjectGroup().getId() + "]";
+
+        return projectGroupId + ":" + groupId + ":" + artifactId + ":" + project.getVersion();
+    }
+
+    private static String getDependencyId( ProjectDependency project )
+    {
+        return project.getGroupId() + ":" + project.getArtifactId() + ":" + project.getVersion();
+    }
+}

Added: continuum/trunk/continuum-api/src/test/java/org/apache/continuum/utils/ProjectSorterTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/test/java/org/apache/continuum/utils/ProjectSorterTest.java?rev=805299&view=auto
==============================================================================
--- continuum/trunk/continuum-api/src/test/java/org/apache/continuum/utils/ProjectSorterTest.java (added)
+++ continuum/trunk/continuum-api/src/test/java/org/apache/continuum/utils/ProjectSorterTest.java Tue Aug 18 07:34:52 2009
@@ -0,0 +1,227 @@
+package org.apache.continuum.utils;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.model.project.ProjectDependency;
+import org.apache.maven.continuum.model.project.ProjectGroup;
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:jmcconnell@apache.org">Jesse McConnell</a>
+ * @version $Id:$
+ */
+public class ProjectSorterTest
+    extends TestCase
+{
+
+    /**
+     * test basic three project tree (really a line in this case)
+     */
+    public void testBasicNestedProjectStructure()
+        throws Exception
+    {
+        List<Project> list = new ArrayList<Project>();
+
+        Project top = getNewProject( "top" );
+        list.add( top );
+
+        Project c1 = getNewProject( "c1" );
+        c1.setParent( generateProjectDependency( top ) );
+        list.add( c1 );
+
+        Project c2 = getNewProject( "c2" );
+        c2.setParent( generateProjectDependency( top ) );
+        c2.setDependencies( Collections.singletonList( generateProjectDependency( c1 ) ) );
+        list.add( c2 );
+
+        List<Project> sortedList = ProjectSorter.getSortedProjects( list, null );
+
+        assertNotNull( sortedList );
+
+        Project p1 = sortedList.get( 0 );
+        assertEquals( top.getArtifactId(), p1.getArtifactId() );
+        Project p2 = sortedList.get( 1 );
+        assertEquals( c1.getArtifactId(), p2.getArtifactId() );
+        Project p3 = sortedList.get( 2 );
+        assertEquals( c2.getArtifactId(), p3.getArtifactId() );
+    }
+
+    public void testNestedProjectStructureWithoutModulesDefinedInParentPom()
+        throws Exception
+    {
+        Project top = getNewProject( "top" );
+
+        Project war1 = getNewProject( "war1" );
+        war1.setParent( generateProjectDependency( top ) );
+
+        Project war2 = getNewProject( "war2" );
+        war2.setParent( generateProjectDependency( top ) );
+
+        Project ear1 = getNewProject( "ear1" );
+        ear1.setParent( generateProjectDependency( top ) );
+        List<ProjectDependency> deps = new ArrayList<ProjectDependency>();
+        deps.add( generateProjectDependency( war1 ) );
+        deps.add( generateProjectDependency( war2 ) );
+        ear1.setDependencies( deps );
+
+        List<Project> list = new ArrayList<Project>();
+
+        // We add projects in a random order to really check the project orter
+        list.add( top );
+        list.add( ear1 );
+        list.add( war1 );
+        list.add( war2 );
+
+        List<Project> sortedList = ProjectSorter.getSortedProjects( list, null );
+
+        assertNotNull( sortedList );
+
+        Project p1 = sortedList.get( 0 ); //top project must be the first
+        assertEquals( top.getArtifactId(), p1.getArtifactId() );
+        Project p4 = sortedList.get( 3 ); //ear1 project must be the latest
+        assertEquals( ear1.getArtifactId(), p4.getArtifactId() );
+    }
+    
+    /**
+     * test project build order
+     * build order: B -> A -> D -> C -> E
+     *
+     * @throws Exception
+     */
+    public void testProjectBuildOrder()
+        throws Exception
+    {
+        List<Project> list = new ArrayList<Project>();
+
+        Project projectA = getNewProject( "A" );
+        Project projectB = getNewProject( "B" );
+        Project projectC = getNewProject( "C" );
+        Project projectD = getNewProject( "D" );
+        Project projectE = getNewProject( "E" );
+        
+        projectA.setParent( generateProjectDependency( projectB ) );
+        projectE.setParent( generateProjectDependency( projectB ) );
+        projectC.setParent( generateProjectDependency( projectA ) );
+        projectC.setDependencies( Collections.singletonList( generateProjectDependency( projectD ) ) );
+        projectD.setParent( generateProjectDependency( projectA ) );
+                
+        list.add( projectA );
+        list.add( projectB );
+        list.add( projectC );
+        list.add( projectD );
+        list.add( projectE );
+
+        List<Project> sortedList = ProjectSorter.getSortedProjects( list, null );
+        assertNotNull( sortedList );
+        
+        List<Project> expectedList = new ArrayList<Project>();
+        
+        expectedList.add( projectB );
+        expectedList.add( projectA );
+        expectedList.add( projectD );
+        expectedList.add( projectC );
+        expectedList.add( projectE );
+        
+        for ( int i = 0; i < sortedList.size(); i++ )
+        {
+            Project sorted = sortedList.get( i );
+            Project expected = expectedList.get( i );
+            assertEquals( sorted.getArtifactId(), expected.getArtifactId() );
+        }
+    }
+
+    /**
+     * test one of the child projects not having the artifactId or groupId empty and working off the
+     * name instead
+     */
+    public void testIncompleteNestedProjectStructure()
+        throws Exception
+    {
+        List<Project> list = new ArrayList<Project>();
+
+        Project top = getNewProject( "top" );
+        list.add( top );
+
+        Project c1 = getIncompleteProject( "c1" );
+        c1.setParent( generateProjectDependency( top ) );
+        list.add( c1 );
+
+        Project c2 = getNewProject( "c2" );
+        c2.setParent( generateProjectDependency( top ) );
+        c2.setDependencies( Collections.singletonList( generateProjectDependency( c1 ) ) );
+        list.add( c2 );
+
+        List<Project> sortedList = ProjectSorter.getSortedProjects( list, null );
+
+        assertNotNull( sortedList );
+
+        Project p1 = sortedList.get( 0 );
+        assertEquals( top.getArtifactId(), p1.getArtifactId() );
+        Project p2 = sortedList.get( 1 );
+        assertEquals( c1.getArtifactId(), p2.getArtifactId() );
+        Project p3 = sortedList.get( 2 );
+        assertEquals( c2.getArtifactId(), p3.getArtifactId() );
+    }
+
+    /**
+     * project sorter can work with name replacing the artifactid and groupId
+     *
+     * @param projectId The project id
+     * @return The generated Project
+     */
+    private Project getIncompleteProject( String projectId )
+    {
+        Project project = new Project();
+        project.setName( "foo" + projectId );
+        project.setVersion( "v" + projectId );
+        project.setProjectGroup( new ProjectGroup() );
+
+        return project;
+    }
+
+    private Project getNewProject( String projectId )
+    {
+        Project project = new Project();
+        project.setArtifactId( "a" + projectId );
+        project.setGroupId( "g" + projectId );
+        project.setVersion( "v" + projectId );
+        project.setName( "n" + projectId );
+        project.setProjectGroup( new ProjectGroup() );
+
+        return project;
+    }
+
+    private ProjectDependency generateProjectDependency( Project project )
+    {
+        ProjectDependency dep = new ProjectDependency();
+        dep.setArtifactId( project.getArtifactId() );
+        dep.setGroupId( project.getGroupId() );
+        dep.setVersion( project.getVersion() );
+
+        return dep;
+    }
+
+}

Modified: continuum/trunk/continuum-commons/src/main/resources/META-INF/spring-context.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-commons/src/main/resources/META-INF/spring-context.xml?rev=805299&r1=805298&r2=805299&view=diff
==============================================================================
--- continuum/trunk/continuum-commons/src/main/resources/META-INF/spring-context.xml (original)
+++ continuum/trunk/continuum-commons/src/main/resources/META-INF/spring-context.xml Tue Aug 18 07:34:52 2009
@@ -29,13 +29,11 @@
   <context:annotation-config />
   <context:component-scan 
     base-package="org.apache.continuum.installation,org.apache.continuum.profile,
-                  org.apache.maven.continuum.configuration,org.apache.maven.continuum.utils,
-                  org.apache.continuum.utils.shell"/>
+                  org.apache.maven.continuum.configuration,org.apache.maven.continuum.utils"/>
 
   <bean id="configurationService" class="org.apache.maven.continuum.configuration.DefaultConfigurationService"
         init-method="initialize">
     <property name="applicationHome" value="data"/>
   </bean> 
-  <bean id="shellCommandHelper" class="org.apache.continuum.utils.shell.DefaultShellCommandHelper"/>
   <bean id="buildQueueService" class="org.apache.continuum.buildqueue.DefaultBuildQueueService"/>
 </beans>
\ No newline at end of file

Modified: continuum/trunk/continuum-data-management/data-management-cli/pom.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-data-management/data-management-cli/pom.xml?rev=805299&r1=805298&r2=805299&view=diff
==============================================================================
--- continuum/trunk/continuum-data-management/data-management-cli/pom.xml (original)
+++ continuum/trunk/continuum-data-management/data-management-cli/pom.xml Tue Aug 18 07:34:52 2009
@@ -55,10 +55,6 @@
     </dependency>
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
-      <artifactId>plexus-classworlds</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-utils</artifactId>
     </dependency>
     <dependency>
@@ -75,6 +71,11 @@
       <scope>runtime</scope>
     </dependency>
     <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>jcl-over-slf4j</artifactId>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
       <groupId>log4j</groupId>
       <artifactId>log4j</artifactId>
     </dependency>
@@ -89,44 +90,52 @@
     </dependency>
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
-      <artifactId>plexus-container-default</artifactId>
+      <artifactId>plexus-spring</artifactId>
     </dependency>
   </dependencies>
   <build>
     <plugins>
-      <!-- TODO: shade it instead, not currently working with this
-        <plugin>
-          <artifactId>shade-maven-plugin</artifactId>
-          <groupId>org.codehaus.mojo</groupId>
-          <executions>
-            <execution>
-              <goals>
-                <goal>shade</goal>
-              </goals>
-            </execution>
-          </executions>
-        </plugin>
-      -->
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-assembly-plugin</artifactId>
-        <configuration>
-          <descriptor>src/assembly/app.xml</descriptor>
-          <archive>
-            <manifest>
-              <mainClass>org.apache.maven.continuum.management.DataManagementCli</mainClass>
-            </manifest>
-          </archive>
-        </configuration>
+        <artifactId>maven-shade-plugin</artifactId>
         <executions>
           <execution>
             <phase>package</phase>
             <goals>
-              <goal>single</goal>
+              <goal>shade</goal>
             </goals>
+            <configuration>
+              <finalName>data-management-cli-${project.version}-app</finalName>
+              <transformers>
+                <transformer implementation="org.apache.maven.plugins.shade.resource.ComponentsXmlResourceTransformer" />
+                <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+                  <resource>META-INF/spring.handlers</resource>
+                </transformer>
+                <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+                  <resource>META-INF/spring.schemas</resource>
+                </transformer>
+              </transformers>
+              <artifactSet>
+                <excludes>
+                  <exclude>xml-apis:xml-apis</exclude>
+                </excludes>
+              </artifactSet>
+            </configuration>
           </execution>
         </executions>
       </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <version>2.1</version>
+        <configuration>
+          <archive>
+            <manifest>
+              <mainClass>org.apache.maven.continuum.management.DataManagementCli</mainClass>
+            </manifest>
+          </archive>
+        </configuration>
+      </plugin>
     </plugins>
   </build>
 </project>

Modified: continuum/trunk/continuum-data-management/data-management-cli/src/main/java/org/apache/maven/continuum/management/DataManagementCli.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-data-management/data-management-cli/src/main/java/org/apache/maven/continuum/management/DataManagementCli.java?rev=805299&r1=805298&r2=805299&view=diff
==============================================================================
--- continuum/trunk/continuum-data-management/data-management-cli/src/main/java/org/apache/maven/continuum/management/DataManagementCli.java (original)
+++ continuum/trunk/continuum-data-management/data-management-cli/src/main/java/org/apache/maven/continuum/management/DataManagementCli.java Tue Aug 18 07:34:52 2009
@@ -40,6 +40,7 @@
 import org.apache.maven.artifact.resolver.ResolutionListener;
 import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
 import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter;
+import org.apache.maven.continuum.management.util.PlexusFileSystemXmlApplicationContext;
 import org.apache.maven.settings.MavenSettingsBuilder;
 import org.apache.maven.settings.Mirror;
 import org.apache.maven.settings.Profile;
@@ -48,12 +49,12 @@
 import org.apache.maven.settings.Server;
 import org.apache.maven.settings.Settings;
 import org.apache.maven.wagon.repository.RepositoryPermissions;
-import org.codehaus.plexus.DefaultPlexusContainer;
 import org.codehaus.plexus.PlexusContainer;
 import org.codehaus.plexus.PlexusContainerException;
-import org.codehaus.plexus.classworlds.realm.ClassRealm;
 import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException;
 import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+import org.codehaus.plexus.spring.PlexusClassPathXmlApplicationContext;
+import org.codehaus.plexus.spring.PlexusContainerAdapter;
 import org.codehaus.plexus.util.xml.Xpp3Dom;
 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 
@@ -78,6 +79,14 @@
 {
     private static final Logger LOGGER = Logger.getLogger( DataManagementCli.class );
 
+    private static final String JAR_FILE_PREFIX = "jar:file:";
+
+    private static final String FILE_PREFIX = "file:";
+
+    private static final String SPRING_CONTEXT_LOC = "!/**/META-INF/spring-context.xml";
+
+    private static final String PLEXUS_XML_LOC = "!/**/META-INF/plexus/components.xml";
+
     public static void main( String[] args )
         throws Exception
     {
@@ -203,7 +212,12 @@
         DatabaseParams params = new DatabaseParams( databaseType.defaultParams );
         params.setUrl( jdbcUrl );
 
-        DefaultPlexusContainer container = new DefaultPlexusContainer();
+        PlexusClassPathXmlApplicationContext classPathApplicationContext = new PlexusClassPathXmlApplicationContext(
+            new String[]{"classpath*:/META-INF/spring-context.xml", "classpath*:/META-INF/plexus/components.xml",
+            		"classpath*:/META-INF/plexus/plexus.xml"} );
+
+        PlexusContainerAdapter container = new PlexusContainerAdapter();
+        container.setApplicationContext( classPathApplicationContext );
 
         initializeWagon( container, setting );
 
@@ -216,11 +230,13 @@
                                             applicationVersion, setting ) );
         artifacts.addAll( downloadArtifact( container, "jpox", "jpox", databaseFormat.getJpoxVersion(), setting ) );
 
-        List<File> jars = new ArrayList<File>();
+        List<String> jars = new ArrayList<String>();
 
         // Little hack to make it work more nicely in the IDE
         List<String> exclusions = new ArrayList<String>();
         URLClassLoader cp = (URLClassLoader) DataManagementCli.class.getClassLoader();
+        List<URL> jarUrls = new ArrayList<URL>();
+
         for ( URL url : cp.getURLs() )
         {
             String urlEF = url.toExternalForm();
@@ -235,7 +251,8 @@
                 {
                     LOGGER.debug( "[IDE Help] Adding '" + id + "' as an exclusion and using one from classpath" );
                     exclusions.add( "org.apache.continuum:" + id );
-                    jars.add( new File( url.getPath() ) );
+                    jars.add( url.getPath() );
+                    jarUrls.add( url );
                 }
             }
 
@@ -243,9 +260,11 @@
             if ( urlEF.contains( "jpox-enhancer" ) )
             {
                 LOGGER.debug( "[IDE Help] Adding 'jpox-enhancer' as an exclusion and using one from classpath" );
-                jars.add( new File( url.getPath() ) );
+                jars.add( url.getPath() );
+                jarUrls.add( url );
             }
         }
+
         ArtifactFilter filter = new ExcludesArtifactFilter( exclusions );
 
         for ( Artifact a : artifacts )
@@ -255,29 +274,35 @@
                 if ( a.getVersion().equals( databaseFormat.getJpoxVersion() ) )
                 {
                     LOGGER.debug( "Adding artifact: " + a.getFile() );
-                    jars.add( a.getFile() );
+                    jars.add( JAR_FILE_PREFIX + a.getFile().getAbsolutePath() + SPRING_CONTEXT_LOC );
+                    jars.add( JAR_FILE_PREFIX + a.getFile().getAbsolutePath() + PLEXUS_XML_LOC );
+                    jarUrls.add( new URL( FILE_PREFIX + a.getFile().getAbsolutePath() ) );
                 }
             }
             else if ( filter.include( a ) )
             {
                 LOGGER.debug( "Adding artifact: " + a.getFile() );
-                jars.add( a.getFile() );
+                jars.add( JAR_FILE_PREFIX + a.getFile().getAbsolutePath() + SPRING_CONTEXT_LOC );
+                jars.add( JAR_FILE_PREFIX + a.getFile().getAbsolutePath() + PLEXUS_XML_LOC );
+                jarUrls.add( new URL( FILE_PREFIX + a.getFile().getAbsolutePath() ) );
             }
         }
 
-        ClassRealm realm = container.createComponentRealm( "app", jars );
+        URLClassLoader newClassLoader = new URLClassLoader( (URL[]) jarUrls.toArray( new URL[jarUrls.size()] ), cp );
+        Thread.currentThread().setContextClassLoader( newClassLoader );
+        classPathApplicationContext.setClassLoader( newClassLoader );
 
-        ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
-        Thread.currentThread().setContextClassLoader( realm );
+        PlexusFileSystemXmlApplicationContext fileSystemApplicationContext = new PlexusFileSystemXmlApplicationContext(
+             (String[]) jars.toArray( new String[jars.size()] ), classPathApplicationContext );
+        fileSystemApplicationContext.setClassLoader( newClassLoader );
+        container.setApplicationContext( fileSystemApplicationContext );
 
-        ClassRealm oldRealm = container.setLookupRealm( realm );
-
-        DatabaseFactoryConfigurator configurator = (DatabaseFactoryConfigurator) container.lookup(
-            DatabaseFactoryConfigurator.class.getName(), configRoleHint, realm );
+        DatabaseFactoryConfigurator configurator = (DatabaseFactoryConfigurator) container.lookup( 
+                                DatabaseFactoryConfigurator.class.getName(), configRoleHint );
         configurator.configure( params );
 
         DataManagementTool manager =
-            (DataManagementTool) container.lookup( DataManagementTool.class.getName(), toolRoleHint, realm );
+            (DataManagementTool) container.lookup( DataManagementTool.class.getName(), toolRoleHint );
 
         if ( mode == OperationMode.EXPORT )
         {
@@ -288,12 +313,9 @@
             manager.eraseDatabase();
             manager.restoreDatabase( directory, strict );
         }
-
-        container.setLookupRealm( oldRealm );
-        Thread.currentThread().setContextClassLoader( oldLoader );
     }
 
-    private static void initializeWagon( DefaultPlexusContainer container, File setting )
+    private static void initializeWagon( PlexusContainerAdapter container, File setting )
         throws ComponentLookupException, ComponentLifecycleException, IOException
     {
         WagonManager wagonManager = (WagonManager) container.lookup( WagonManager.ROLE );

Added: continuum/trunk/continuum-data-management/data-management-cli/src/main/java/org/apache/maven/continuum/management/util/PlexusApplicationContextDelegate.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-data-management/data-management-cli/src/main/java/org/apache/maven/continuum/management/util/PlexusApplicationContextDelegate.java?rev=805299&view=auto
==============================================================================
--- continuum/trunk/continuum-data-management/data-management-cli/src/main/java/org/apache/maven/continuum/management/util/PlexusApplicationContextDelegate.java (added)
+++ continuum/trunk/continuum-data-management/data-management-cli/src/main/java/org/apache/maven/continuum/management/util/PlexusApplicationContextDelegate.java Tue Aug 18 07:34:52 2009
@@ -0,0 +1,80 @@
+package org.apache.maven.continuum.management.util;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.codehaus.plexus.spring.PlexusBeanDefinitionDocumentReader;
+import org.codehaus.plexus.spring.PlexusConfigurationPropertyEditor;
+import org.codehaus.plexus.spring.PlexusContainerAdapter;
+import org.codehaus.plexus.spring.PlexusLifecycleBeanPostProcessor;
+import org.codehaus.plexus.spring.editors.CollectionPropertyEditor;
+import org.codehaus.plexus.spring.editors.MapPropertyEditor;
+import org.codehaus.plexus.spring.editors.PropertiesPropertyEditor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.context.ApplicationContext;
+
+public class PlexusApplicationContextDelegate
+{
+    /** Logger used by this class. */
+    protected Logger logger = LoggerFactory.getLogger( getClass() );
+
+    private PlexusLifecycleBeanPostProcessor lifecycleBeanPostProcessor;
+
+    /**
+     * @see org.springframework.context.support.AbstractXmlApplicationContext#loadBeanDefinitions(org.springframework.beans.factory.xml.XmlBeanDefinitionReader)
+     */
+    protected void loadBeanDefinitions( XmlBeanDefinitionReader reader )
+        throws BeansException, IOException
+    {
+        logger.info( "Registering Plexus to Spring XML translation" );
+        reader.setDocumentReaderClass( PlexusBeanDefinitionDocumentReader.class );
+    }
+
+    /**
+     * @see org.springframework.context.support.AbstractApplicationContext#postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory)
+     */
+    protected void postProcessBeanFactory( ConfigurableListableBeanFactory beanFactory, ApplicationContext context )
+    {
+        // Register a PlexusContainerAdapter bean to allow context lookups using plexus API
+        PlexusContainerAdapter plexus = new PlexusContainerAdapter();
+        plexus.setApplicationContext( context );
+        beanFactory.registerSingleton( "plexusContainer", plexus );
+
+        // Register a beanPostProcessor to handle plexus interface-based lifecycle management
+        lifecycleBeanPostProcessor = new PlexusLifecycleBeanPostProcessor();
+        lifecycleBeanPostProcessor.setBeanFactory( context );
+        beanFactory.addBeanPostProcessor( lifecycleBeanPostProcessor );
+
+        // Register a PropertyEditor to support plexus XML <configuration> set as CDATA in
+        // a spring context XML file.
+        beanFactory.addPropertyEditorRegistrar( new PlexusConfigurationPropertyEditor() );
+        beanFactory.addPropertyEditorRegistrar( new PropertiesPropertyEditor() );
+        beanFactory.addPropertyEditorRegistrar( new CollectionPropertyEditor( List.class, ArrayList.class ) );
+        beanFactory.addPropertyEditorRegistrar( new CollectionPropertyEditor( Set.class, HashSet.class ) );
+        beanFactory.addPropertyEditorRegistrar( new MapPropertyEditor( Map.class, HashMap.class ) );
+    }
+
+    /**
+     * @see org.springframework.context.support.AbstractApplicationContext#doClose()
+     */
+    protected void doClose()
+    {
+        try
+        {
+            lifecycleBeanPostProcessor.destroy();
+        }
+        catch ( Throwable ex )
+        {
+            logger.error( "Exception thrown from PlexusLifecycleBeanPostProcessor handling ContextClosedEvent", ex );
+        }
+    }
+}
\ No newline at end of file

Added: continuum/trunk/continuum-data-management/data-management-cli/src/main/java/org/apache/maven/continuum/management/util/PlexusFileSystemXmlApplicationContext.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-data-management/data-management-cli/src/main/java/org/apache/maven/continuum/management/util/PlexusFileSystemXmlApplicationContext.java?rev=805299&view=auto
==============================================================================
--- continuum/trunk/continuum-data-management/data-management-cli/src/main/java/org/apache/maven/continuum/management/util/PlexusFileSystemXmlApplicationContext.java (added)
+++ continuum/trunk/continuum-data-management/data-management-cli/src/main/java/org/apache/maven/continuum/management/util/PlexusFileSystemXmlApplicationContext.java Tue Aug 18 07:34:52 2009
@@ -0,0 +1,98 @@
+package org.apache.maven.continuum.management.util;
+
+import java.io.IOException;
+
+import org.codehaus.plexus.spring.PlexusXmlBeanDefinitionReader;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.beans.factory.support.DefaultListableBeanFactory;
+import org.springframework.beans.factory.xml.ResourceEntityResolver;
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.FileSystemXmlApplicationContext;
+
+public class PlexusFileSystemXmlApplicationContext
+    extends FileSystemXmlApplicationContext
+{
+    private static PlexusApplicationContextDelegate delegate = new PlexusApplicationContextDelegate();
+
+    public PlexusFileSystemXmlApplicationContext( String configLocation )
+    {
+        super( configLocation );
+    }
+
+    public PlexusFileSystemXmlApplicationContext( String[] configLocations )
+    {
+        super( configLocations );
+    }
+
+    public PlexusFileSystemXmlApplicationContext( String[] configLocations, ApplicationContext parent )
+    {
+        super( configLocations, parent );
+    }
+
+    public PlexusFileSystemXmlApplicationContext( String[] configLocations, boolean refresh )
+    {
+        super( configLocations, refresh );
+    }
+
+    public PlexusFileSystemXmlApplicationContext( String[] configLocations, boolean refresh, ApplicationContext parent )
+    {
+        super( configLocations, refresh, parent );
+    }
+
+    /**
+     * {@inheritDoc}
+     *
+     * @see org.springframework.context.support.AbstractXmlApplicationContext#loadBeanDefinitions(org.springframework.beans.factory.xml.XmlBeanDefinitionReader)
+     */
+    protected void loadBeanDefinitions( XmlBeanDefinitionReader reader )
+        throws BeansException, IOException
+    {
+        delegate.loadBeanDefinitions( reader );
+        super.loadBeanDefinitions( reader );
+    }
+
+    /**
+     * Copied from {@link AbstractXmlApplicationContext}
+     * Loads the bean definitions via an XmlBeanDefinitionReader.
+     * @see org.springframework.beans.factory.xml.XmlBeanDefinitionReader
+     * @see #initBeanDefinitionReader
+     * @see #loadBeanDefinitions
+     */
+    protected void loadBeanDefinitions( DefaultListableBeanFactory beanFactory ) throws IOException {
+        // Create a new XmlBeanDefinitionReader for the given BeanFactory.
+        XmlBeanDefinitionReader beanDefinitionReader = new PlexusXmlBeanDefinitionReader( beanFactory );
+
+        // Configure the bean definition reader with this context's
+        // resource loading environment.
+        beanDefinitionReader.setResourceLoader( this );
+        beanDefinitionReader.setEntityResolver( new ResourceEntityResolver( this ) );
+
+        // Allow a subclass to provide custom initialization of the reader,
+        // then proceed with actually loading the bean definitions.
+        initBeanDefinitionReader( beanDefinitionReader );
+        loadBeanDefinitions( beanDefinitionReader );
+    }
+
+    /**
+     * {@inheritDoc}
+     *
+     * @see org.springframework.context.support.AbstractApplicationContext#postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory)
+     */
+    protected void postProcessBeanFactory( ConfigurableListableBeanFactory beanFactory )
+    {
+        delegate.postProcessBeanFactory( beanFactory, this );
+    }
+
+    /**
+     * {@inheritDoc}
+     *
+     * @see org.springframework.context.support.AbstractApplicationContext#doClose()
+     */
+    protected void doClose()
+    {
+        delegate.doClose();
+        super.doClose();
+    }
+}
\ No newline at end of file

Modified: continuum/trunk/continuum-data-management/data-management-jdo/pom.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-data-management/data-management-jdo/pom.xml?rev=805299&r1=805298&r2=805299&view=diff
==============================================================================
--- continuum/trunk/continuum-data-management/data-management-jdo/pom.xml (original)
+++ continuum/trunk/continuum-data-management/data-management-jdo/pom.xml Tue Aug 18 07:34:52 2009
@@ -73,6 +73,7 @@
     <dependency>
       <groupId>org.apache.continuum</groupId>
       <artifactId>continuum-commons</artifactId>
+      <scope>test</scope>
     </dependency>
     <dependency>
       <groupId>stax</groupId>