You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jd...@apache.org on 2008/11/22 08:14:04 UTC

svn commit: r719819 [1/2] - in /geronimo/gshell/trunk: ./ gshell-support/ gshell-support/gshell-artifact-ivy/ gshell-support/gshell-artifact-ivy/src/main/java/org/apache/geronimo/gshell/ivy/monitor/ gshell-support/gshell-artifact-maven/ gshell-support/...

Author: jdillon
Date: Fri Nov 21 23:14:03 2008
New Revision: 719819

URL: http://svn.apache.org/viewvc?rev=719819&view=rev
Log:
Working on bringing back maven-artifact based artifact resolution as an option

Added:
    geronimo/gshell/trunk/gshell-support/gshell-artifact-ivy/   (props changed)
      - copied from r719193, geronimo/gshell/trunk/gshell-support/gshell-ivy/
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/pom.xml   (with props)
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactManager.java   (with props)
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactManagerException.java   (with props)
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactManagerFactory.java   (with props)
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactRepositoryManager.java   (with props)
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/DefaultArtifactManager.java   (with props)
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/DefaultArtifactRepositoryManager.java   (with props)
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/GShellArtifactMetadataSource.java   (with props)
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/GShellArtifactResolver.java   (with props)
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/InvalidRepositoryException.java   (with props)
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/ResolutionException.java   (with props)
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/Slf4jLoggingManager.java   (with props)
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/monitor/
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/monitor/ProgressSpinner.java   (with props)
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/monitor/ProgressSpinnerMonitor.java   (with props)
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/monitor/TransferListenerSupport.java   (with props)
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/resources/
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/resources/META-INF/
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/resources/META-INF/plexus/
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/resources/META-INF/plexus/components.xml   (with props)
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/resources/META-INF/plexus/plexus.xml   (with props)
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/resources/META-INF/spring/
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/resources/META-INF/spring/components.xml   (with props)
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/test/
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/test/java/
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/test/java/org/
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/test/java/org/apache/
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/test/java/org/apache/geronimo/
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/test/java/org/apache/geronimo/gshell/
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/test/java/org/apache/geronimo/gshell/artifact/
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/test/java/org/apache/geronimo/gshell/artifact/ArtifactManagerFactoryTest.java   (with props)
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/test/resources/
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/test/resources/log4j.xml   (with props)
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/test/resources/org/
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/test/resources/org/apache/
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/test/resources/org/apache/geronimo/
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/test/resources/org/apache/geronimo/gshell/
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/test/resources/org/apache/geronimo/gshell/artifact/
    geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/test/resources/org/apache/geronimo/gshell/artifact/ArtifactManagerFactoryTest-context.xml   (with props)
Removed:
    geronimo/gshell/trunk/gshell-support/gshell-artifact-ivy/src/main/java/org/apache/geronimo/gshell/ivy/monitor/
    geronimo/gshell/trunk/gshell-support/gshell-ivy/
Modified:
    geronimo/gshell/trunk/gshell-support/gshell-artifact-ivy/pom.xml
    geronimo/gshell/trunk/gshell-support/pom.xml
    geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-bootstrap/pom.xml
    geronimo/gshell/trunk/pom.xml

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-ivy/
------------------------------------------------------------------------------
    svn:mergeinfo = 

Modified: geronimo/gshell/trunk/gshell-support/gshell-artifact-ivy/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-artifact-ivy/pom.xml?rev=719819&r1=719193&r2=719819&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-artifact-ivy/pom.xml (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-artifact-ivy/pom.xml Fri Nov 21 23:14:03 2008
@@ -30,8 +30,8 @@
         <version>1.0-alpha-2-SNAPSHOT</version>
     </parent>
 
-    <artifactId>gshell-ivy</artifactId>
-    <name>GShell Support :: Ivy</name>
+    <artifactId>gshell-artifact-ivy</artifactId>
+    <name>GShell Support :: Artifact + Ivy</name>
 
     <description>
         Ivy support.

Added: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/pom.xml?rev=719819&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/pom.xml (added)
+++ geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/pom.xml Fri Nov 21 23:14:03 2008
@@ -0,0 +1,148 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+
+<!-- $Rev$ $Date$ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    
+    <modelVersion>4.0.0</modelVersion>
+    
+    <parent>
+        <groupId>org.apache.geronimo.gshell.support</groupId>
+        <artifactId>gshell-support</artifactId>
+        <version>1.0-alpha-2-SNAPSHOT</version>
+    </parent>
+    
+    <artifactId>gshell-artifact-maven</artifactId>
+    <name>GShell Support :: Artifact + Maven</name>
+    
+    <description>
+        Provides support for working with artifacts and repositories.
+    </description>
+
+    <properties>
+        <maven.test.skip>true</maven.test.skip>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.gshell.support</groupId>
+            <artifactId>gshell-chronos</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.gshell.support</groupId>
+            <artifactId>gshell-io</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.gshell.support</groupId>
+            <artifactId>gshell-spring</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.gshell.support</groupId>
+            <artifactId>gshell-plexus</artifactId>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.apache.maven.artifact</groupId>
+            <artifactId>maven-artifact</artifactId>
+            <version>3.0-alpha-1</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-project</artifactId>
+            <version>2.1.0-SNAPSHOT</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.apache.maven</groupId>
+                    <artifactId>maven-artifact</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.apache.maven</groupId>
+                    <artifactId>maven-artifact-manager</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.maven.wagon</groupId>
+            <artifactId>wagon-provider-api</artifactId>
+            <version>1.0-beta-4</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.maven.wagon</groupId>
+            <artifactId>wagon-file</artifactId>
+            <version>1.0-beta-4</version>
+            <scope>runtime</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.maven.wagon</groupId>
+            <artifactId>wagon-http-lightweight</artifactId>
+            <version>1.0-beta-4</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>jtidy</groupId>
+                    <artifactId>jtidy</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>xml-apis</groupId>
+                    <artifactId>xml-apis</artifactId>
+                </exclusion>
+            </exclusions>
+            <scope>runtime</scope>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.apache.geronimo.gshell.support</groupId>
+            <artifactId>gshell-spring</artifactId>
+            <classifier>tests</classifier>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <showDeprecation>false</showDeprecation>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactManager.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactManager.java?rev=719819&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactManager.java (added)
+++ geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactManager.java Fri Nov 21 23:14:03 2008
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+
+package org.apache.geronimo.gshell.artifact;
+
+import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
+import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
+import org.apache.maven.wagon.events.TransferListener;
+
+/**
+ * Provides a facade over the artifact + repository subsystem.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ArtifactManager
+{
+    ArtifactRepositoryManager getRepositoryManager();
+
+    ArtifactFactory getArtifactFactory();
+
+    void setDownloadMonitor(TransferListener listener);
+
+    ArtifactResolutionResult resolve(ArtifactResolutionRequest request) throws ResolutionException;
+
+    boolean isOnline();
+
+    void setOnline(boolean flag);
+}
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactManager.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactManager.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactManagerException.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactManagerException.java?rev=719819&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactManagerException.java (added)
+++ geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactManagerException.java Fri Nov 21 23:14:03 2008
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ */
+
+package org.apache.geronimo.gshell.artifact;
+
+/**
+ * Thrown to indicate a problem with an {@link ArtifactManager} operation.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ArtifactManagerException
+    extends Exception
+{
+    private static final long serialVersionUID = 1;
+
+    public ArtifactManagerException(final String msg, final Throwable cause) {
+        super(msg, cause);
+    }
+
+    public ArtifactManagerException(final String msg) {
+        super(msg);
+    }
+
+    public ArtifactManagerException(final Throwable cause) {
+        super(cause);
+    }
+
+    public ArtifactManagerException() {
+        super();
+    }
+}
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactManagerException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactManagerException.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactManagerException.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactManagerFactory.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactManagerFactory.java?rev=719819&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactManagerFactory.java (added)
+++ geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactManagerFactory.java Fri Nov 21 23:14:03 2008
@@ -0,0 +1,81 @@
+/*
+ * 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.
+ */
+
+package org.apache.geronimo.gshell.artifact;
+
+import org.apache.geronimo.gshell.artifact.Slf4jLoggingManager;
+import org.codehaus.plexus.DefaultContainerConfiguration;
+import org.codehaus.plexus.DefaultPlexusContainer;
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.classworlds.ClassWorld;
+import org.codehaus.plexus.classworlds.realm.ClassRealm;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.FactoryBean;
+
+/**
+ * Creates {@link ArtifactManager} beans.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ArtifactManagerFactory
+    implements FactoryBean
+{
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    private PlexusContainer createContainer() throws Exception {
+        DefaultContainerConfiguration config = new DefaultContainerConfiguration();
+
+        // When running under ClassWorlds already, then set the containers realm to the current realm
+        ClassLoader cl = getClass().getClassLoader();
+        if (cl instanceof ClassRealm) {
+            config.setRealm((ClassRealm)cl);
+        }
+        else {
+            // Else, when testing, setup a new realm
+            ClassWorld classWorld = new ClassWorld();
+            ClassRealm classRealm = classWorld.newRealm("testing", getClass().getClassLoader());
+            config.setRealm(classRealm);
+        }
+
+        DefaultPlexusContainer container = new DefaultPlexusContainer(config);
+
+        container.setLoggerManager(new Slf4jLoggingManager());
+
+        log.debug("Constructed Plexus container: {}", container);
+
+        return container;
+    }
+
+    public Object getObject() throws Exception {
+        Object target = createContainer().lookup(ArtifactManager.class);
+
+        log.debug("Using ArtifactManager: {}", target);
+
+        return target;
+    }
+
+    public Class getObjectType() {
+        return ArtifactManager.class;
+    }
+
+    public boolean isSingleton() {
+        return true;
+    }
+}
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactManagerFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactManagerFactory.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactManagerFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactRepositoryManager.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactRepositoryManager.java?rev=719819&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactRepositoryManager.java (added)
+++ geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactRepositoryManager.java Fri Nov 21 23:14:03 2008
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+
+package org.apache.geronimo.gshell.artifact;
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+
+import java.io.File;
+import java.net.URI;
+import java.util.List;
+
+/**
+ * Provides a facade over the artifact + repository subsystem.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ArtifactRepositoryManager
+{
+    ArtifactRepository getLocalRepository();
+
+    void setLocalRepository(ArtifactRepository repository) throws InvalidRepositoryException;
+
+    void setLocalRepository(File dir) throws InvalidRepositoryException;
+
+    List<ArtifactRepository> getRemoteRepositories();
+
+    void addRemoteRepository(ArtifactRepository repository) throws InvalidRepositoryException;
+
+    void addRemoteRepository(String id, URI location) throws InvalidRepositoryException;
+
+    List<ArtifactRepository> selectRemoteRepositories(List<ArtifactRepository> repositories);
+}
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactRepositoryManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactRepositoryManager.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactRepositoryManager.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/DefaultArtifactManager.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/DefaultArtifactManager.java?rev=719819&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/DefaultArtifactManager.java (added)
+++ geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/DefaultArtifactManager.java Fri Nov 21 23:14:03 2008
@@ -0,0 +1,202 @@
+/*
+ * 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.
+ */
+
+package org.apache.geronimo.gshell.artifact;
+
+import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.manager.WagonManager;
+import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
+import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
+import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
+import org.apache.maven.artifact.resolver.ArtifactResolver;
+import org.apache.maven.artifact.resolver.ArtifactResolutionException;
+import org.apache.maven.artifact.resolver.CyclicDependencyException;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.wagon.events.TransferListener;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+import org.apache.geronimo.gshell.chronos.StopWatch;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+
+/**
+ * Default implementation of the {@link ArtifactManager} component.
+ *
+ * @version $Rev$ $Date$
+ */
+@Component(role=ArtifactManager.class)
+public class DefaultArtifactManager
+    implements ArtifactManager
+{
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    //
+    // TODO: Look at implementing this with mercury
+    //
+
+    @Requirement
+    private ArtifactFactory artifactFactory;
+
+    @Requirement
+    private ArtifactRepositoryManager repositoryManager;
+
+    @Requirement
+    private ArtifactResolver artifactResolver;
+
+    @Requirement(hint="gshell")
+    private ArtifactMetadataSource artifactMetadataSource;
+
+    @Requirement
+    private WagonManager wagonManager;
+
+    public ArtifactRepositoryManager getRepositoryManager() {
+        return repositoryManager;
+    }
+
+    public ArtifactFactory getArtifactFactory() {
+        return artifactFactory;
+    }
+
+    public void setDownloadMonitor(final TransferListener listener) {
+        assert listener != null;
+
+        wagonManager.setDownloadMonitor(listener);
+
+        log.debug("Using download monitor: {}", listener);
+    }
+    
+    public ArtifactResolutionResult resolve(final ArtifactResolutionRequest request) throws ResolutionException {
+        assert request != null;
+
+        // Automatically fill in some missing bits
+
+        if (request.getLocalRepository() == null) {
+            request.setLocalRepository(repositoryManager.getLocalRepository());
+        }
+
+        if (request.getRemoteRepostories() == null) {
+            request.setRemoteRepostories(repositoryManager.getRemoteRepositories());
+        }
+
+        if (request.getMetadataSource() == null) {
+            request.setMetadataSource(artifactMetadataSource);
+        }
+
+        // If there is no artifact, then assume we want to do some full transitive resolve and install a dummy artifact
+        Artifact artifact = request.getArtifact();
+        if (artifact == null) {
+            artifact = artifactFactory.createArtifact("dummy", "dummy", "dummy", null, "jar");
+            request.setArtifact(artifact);
+        }
+
+        log.debug("Resolving request: {}", request);
+
+        StopWatch watch = new StopWatch(true);
+
+        ArtifactResolutionResult result = artifactResolver.resolve(request);
+
+        log.debug("Resolution completed after: {}", watch);
+
+        return validateResolutionResult(request, result);
+    }
+
+    private ArtifactResolutionResult validateResolutionResult(final ArtifactResolutionRequest request, final ArtifactResolutionResult result) throws ResolutionException {
+        assert request != null;
+        assert result != null;
+
+        log.debug("Validating result: {}", result);
+
+        boolean failed = false;
+
+        if (result.hasErrorArtifactExceptions()) {
+            failed = true;
+
+            log.error("Artifact resolution errors:");
+            List<ArtifactResolutionException> exceptions = result.getErrorArtifactExceptions();
+            for (ArtifactResolutionException exception : exceptions) {
+                log.error("    {}", exception);
+                log.trace("Artifact resolution error", exception);
+            }
+        }
+
+        if (result.hasCircularDependencyExceptions()) {
+            failed = true;
+
+            log.error("Artifact circular dependency errors:");
+            List<CyclicDependencyException> exceptions = result.getCircularDependencyExceptions();
+            for (CyclicDependencyException exception : exceptions) {
+                log.error("    {}", exception);
+                log.trace("Artifact circular dependency error", exception);
+            }
+        }
+
+        if (result.hasMetadataResolutionExceptions()) {
+            failed = true;
+
+            log.error("Artifact metadata resolution errors:");
+            // noinspection unchecked
+            List<ArtifactResolutionException> exceptions = result.getMetadataResolutionExceptions();
+            for (ArtifactResolutionException exception : exceptions) {
+                log.error("    {}", exception);
+                log.trace("Artifact metadata resolution error", exception);
+            }
+        }
+
+        if (result.hasVersionRangeViolations()) {
+            failed = true;
+
+            log.error("Artifact version range violations:");
+            // noinspection unchecked
+            List<Exception> exceptions = result.getVersionRangeViolations();
+            for (Exception exception : exceptions) {
+                log.error("    {}", exception);
+                log.trace("Artifact version range violation", exception);
+            }
+        }
+
+        // noinspection unchecked
+        List<Artifact> artifacts = result.getMissingArtifacts();
+        if (!artifacts.isEmpty()) {
+            failed = true;
+
+            log.error("Missing artifacts:");
+            for (Artifact artifact : artifacts) {
+                log.error("    {}", artifact);
+            }
+        }
+
+        if (failed) {
+            throw new ResolutionException(request, result);
+        }
+        
+        return result;
+    }
+
+    public boolean isOnline() {
+        return wagonManager.isOnline();
+    }
+
+    public void setOnline(final boolean flag) {
+        log.debug("Online: {}", flag);
+
+        wagonManager.setOnline(flag);
+    }
+}
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/DefaultArtifactManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/DefaultArtifactManager.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/DefaultArtifactManager.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/DefaultArtifactRepositoryManager.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/DefaultArtifactRepositoryManager.java?rev=719819&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/DefaultArtifactRepositoryManager.java (added)
+++ geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/DefaultArtifactRepositoryManager.java Fri Nov 21 23:14:03 2008
@@ -0,0 +1,116 @@
+/*
+ * 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.
+ */
+
+package org.apache.geronimo.gshell.artifact;
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
+import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Default implementation of the {@link ArtifactRepositoryManager} component.
+ *
+ * @version $Rev$ $Date$
+ */
+@Component(role=ArtifactRepositoryManager.class)
+public class DefaultArtifactRepositoryManager
+    implements ArtifactRepositoryManager
+{
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    @Requirement
+    private ArtifactRepositoryFactory repositoryFactory;
+
+    private ArtifactRepository localRepository;
+
+    private List<ArtifactRepository> remoteRepositories = new ArrayList<ArtifactRepository>();
+
+    public ArtifactRepository getLocalRepository() {
+        return localRepository;
+    }
+
+    public void setLocalRepository(final ArtifactRepository repository) throws InvalidRepositoryException {
+        assert repository != null;
+
+        localRepository = repository;
+
+        log.debug("Using local repository: {}", repository);
+    }
+
+    public void setLocalRepository(final File dir) throws InvalidRepositoryException {
+        assert dir != null;
+
+        try {
+            ArtifactRepository repo = repositoryFactory.createLocalRepository(dir);
+            setLocalRepository(repo);
+        }
+        catch (Exception e) {
+            throw new InvalidRepositoryException(e);
+        }
+    }
+
+    public List<ArtifactRepository> getRemoteRepositories() {
+        return remoteRepositories;
+    }
+
+    public void addRemoteRepository(final ArtifactRepository repository) throws InvalidRepositoryException {
+        assert repository != null;
+
+        remoteRepositories.add(repository);
+
+         log.debug("Added remote repository: {}", repository);
+    }
+
+    public List<ArtifactRepository> selectRemoteRepositories(final List<ArtifactRepository> repositories) {
+        assert repositories != null;
+
+        // For now just ignore the given repositories, eventually may want to apply some configurable allow/deny logic
+        return getRemoteRepositories();
+    }
+
+    public void addRemoteRepository(final String id, final URI location) throws InvalidRepositoryException {
+        assert id != null;
+        assert location != null;
+
+        try {
+            ArtifactRepository repo = repositoryFactory.createArtifactRepository(
+                id,
+                location.toURL().toExternalForm(),
+                ArtifactRepositoryFactory.DEFAULT_LAYOUT_ID,
+
+                // FIXME: Expose more configuration to user API
+                new ArtifactRepositoryPolicy(),  // snapshots
+                new ArtifactRepositoryPolicy()); // releases
+
+            addRemoteRepository(repo);
+        }
+        catch (Exception e) {
+            throw new InvalidRepositoryException(e);
+        }
+    }
+}
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/DefaultArtifactRepositoryManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/DefaultArtifactRepositoryManager.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/DefaultArtifactRepositoryManager.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/GShellArtifactMetadataSource.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/GShellArtifactMetadataSource.java?rev=719819&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/GShellArtifactMetadataSource.java (added)
+++ geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/GShellArtifactMetadataSource.java Fri Nov 21 23:14:03 2008
@@ -0,0 +1,115 @@
+/*
+ * 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.
+ */
+
+package org.apache.geronimo.gshell.artifact;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
+import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
+import org.apache.maven.artifact.metadata.ResolutionGroup;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.versioning.ArtifactVersion;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+
+/**
+ * Custom {@link ArtifactMetadataSource} for GShell.
+ *
+ * @version $Rev$ $Date$
+ */
+@Component(role=ArtifactMetadataSource.class, hint="gshell")
+public class GShellArtifactMetadataSource
+    implements ArtifactMetadataSource
+{
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    //
+    // TODO: Look into creating a simple model that only deals with dependency bits and perform basic processing, avoiding the need for all this Maven stuff
+    //
+
+    @Requirement(hint="maven")
+    private ArtifactMetadataSource delegate;
+
+    @Requirement
+    private ArtifactRepositoryManager repositoryManager;
+
+    public ResolutionGroup retrieve(final Artifact artifact, final ArtifactRepository localRepository, final List<ArtifactRepository> remoteRepositories)
+        throws ArtifactMetadataRetrievalException
+    {
+        assert delegate != null;
+        assert repositoryManager != null;
+
+        log.trace("Retrieving metadata; artifact={}, local={}, remote={}", new Object[] { artifact, localRepository, remoteRepositories });
+
+        ResolutionGroup result = delegate.retrieve(artifact, localRepository, repositoryManager.selectRemoteRepositories(remoteRepositories));
+
+        log.trace("Resolution group; pom={}, artifacts={}, repositories={}", new Object[] { result.getPomArtifact(), result.getArtifacts(), result.getResolutionRepositories() });
+
+        return new ResolutionGroup(result.getPomArtifact(), result.getArtifacts(), repositoryManager.selectRemoteRepositories(result.getResolutionRepositories()));
+    }
+
+    public List<ArtifactVersion> retrieveAvailableVersions(final Artifact artifact, final ArtifactRepository localRepository, final List<ArtifactRepository> remoteRepositories)
+        throws ArtifactMetadataRetrievalException
+    {
+        assert delegate != null;
+        assert repositoryManager != null;
+
+        log.trace("Retrieving available versions; artifact={}, local={}, remote={}", new Object[] { artifact, localRepository, remoteRepositories });
+
+        List<ArtifactVersion> versions = delegate.retrieveAvailableVersions(artifact, localRepository, repositoryManager.selectRemoteRepositories(remoteRepositories));
+
+        log.trace("Available versions: {}", versions);
+        
+        return versions;
+    }
+
+    public List<ArtifactVersion> retrieveAvailableVersionsFromDeploymentRepository(final Artifact artifact, final ArtifactRepository localRepository, final ArtifactRepository deploymentRepository1)
+        throws ArtifactMetadataRetrievalException
+    {
+        assert delegate != null;
+        assert repositoryManager != null;
+
+        log.trace("Retrieving available versions from deployment repo; artifact={}, local={}, deployment={}", new Object[] { artifact, localRepository, deploymentRepository1 });
+
+        List<ArtifactVersion> versions = delegate.retrieveAvailableVersionsFromDeploymentRepository(artifact, localRepository, deploymentRepository1);
+
+        log.trace("Available versions: {}", versions);
+
+        return versions;
+    }
+
+    public Artifact retrieveRelocatedArtifact(final Artifact artifact, final ArtifactRepository localRepository, final List<ArtifactRepository> remoteRepositories)
+        throws ArtifactMetadataRetrievalException
+    {
+        assert delegate != null;
+        assert repositoryManager != null;
+
+        log.trace("Retrieving relocated artirfat; artifact={}, local={}, remote={}", new Object[] { artifact, localRepository, remoteRepositories });
+
+        Artifact relocated = delegate.retrieveRelocatedArtifact(artifact, localRepository, repositoryManager.selectRemoteRepositories(remoteRepositories));
+
+        log.trace("Relocated artifact: {}", relocated);
+
+        return relocated;
+    }
+}

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/GShellArtifactMetadataSource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/GShellArtifactMetadataSource.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/GShellArtifactMetadataSource.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/GShellArtifactResolver.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/GShellArtifactResolver.java?rev=719819&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/GShellArtifactResolver.java (added)
+++ geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/GShellArtifactResolver.java Fri Nov 21 23:14:03 2008
@@ -0,0 +1,135 @@
+/*
+ * 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.
+ */
+
+package org.apache.geronimo.gshell.artifact;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
+import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
+import org.apache.maven.artifact.resolver.ArtifactResolver;
+import org.apache.maven.artifact.resolver.ResolutionListener;
+import org.apache.maven.artifact.resolver.conflict.ConflictResolver;
+import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Custom {@link ArtifactResolver} for GShell.
+ *
+ * @version $Rev$ $Date$
+ */
+@Component(role=ArtifactResolver.class, hint="gshell")
+public class GShellArtifactResolver
+    implements ArtifactResolver
+{
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    @Requirement(hint="delegate")
+    private ArtifactResolver delegate;
+
+    @Requirement
+    private ArtifactRepositoryManager repositoryManager;
+
+    //
+    // ArtifactResolver
+    //
+
+    public void resolve(Artifact artifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository) throws ArtifactResolutionException, ArtifactNotFoundException {
+        assert delegate != null;
+        assert repositoryManager != null;
+
+        delegate.resolve(artifact, repositoryManager.selectRemoteRepositories(remoteRepositories), localRepository);
+    }
+
+    public ArtifactResolutionResult resolveTransitively(Set<Artifact> artifacts, Artifact artifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository, ArtifactMetadataSource source) throws ArtifactResolutionException, ArtifactNotFoundException {
+        assert delegate != null;
+        assert repositoryManager != null;
+        
+        return delegate.resolveTransitively(artifacts, artifact, repositoryManager.selectRemoteRepositories(remoteRepositories), localRepository, source);
+    }
+
+    public ArtifactResolutionResult resolveTransitively(Set<Artifact> artifacts, Artifact artifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository, ArtifactMetadataSource source, List<ResolutionListener> listeners) throws ArtifactResolutionException, ArtifactNotFoundException {
+        assert delegate != null;
+        assert repositoryManager != null;
+        
+        return delegate.resolveTransitively(artifacts, artifact, repositoryManager.selectRemoteRepositories(remoteRepositories), localRepository, source, listeners);
+    }
+
+    public ArtifactResolutionResult resolveTransitively(Set<Artifact> artifacts, Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter) throws ArtifactResolutionException, ArtifactNotFoundException {
+        assert delegate != null;
+        assert repositoryManager != null;
+        
+        return delegate.resolveTransitively(artifacts, artifact, localRepository, repositoryManager.selectRemoteRepositories(remoteRepositories), source, filter);
+    }
+
+    public ArtifactResolutionResult resolveTransitively(Set<Artifact> artifacts, Artifact artifact, Map managedVersions, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories, ArtifactMetadataSource source) throws ArtifactResolutionException, ArtifactNotFoundException {
+        assert delegate != null;
+        assert repositoryManager != null;
+        
+        return delegate.resolveTransitively(artifacts, artifact, managedVersions, localRepository, repositoryManager.selectRemoteRepositories(remoteRepositories), source);
+    }
+
+    public ArtifactResolutionResult resolveTransitively(Set<Artifact> artifacts, Artifact artifact, Map managedVersions, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter) throws ArtifactResolutionException, ArtifactNotFoundException {
+        assert delegate != null;
+        assert repositoryManager != null;
+        
+        return delegate.resolveTransitively(artifacts, artifact, managedVersions, localRepository, repositoryManager.selectRemoteRepositories(remoteRepositories), source, filter);
+    }
+
+    public ArtifactResolutionResult resolveTransitively(Set<Artifact> artifacts, Artifact artifact, Map managedVersions, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter, List<ResolutionListener> listeners) throws ArtifactResolutionException, ArtifactNotFoundException {
+        assert delegate != null;
+        assert repositoryManager != null;
+        
+        return delegate.resolveTransitively(artifacts, artifact, managedVersions, localRepository, repositoryManager.selectRemoteRepositories(remoteRepositories), source, filter, listeners);
+    }
+
+    public ArtifactResolutionResult resolveTransitively(Set<Artifact> artifacts, Artifact artifact, Map managedVersions, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter, List<ResolutionListener> listeners, List<ConflictResolver> conflictResolvers) throws ArtifactResolutionException, ArtifactNotFoundException {
+        assert delegate != null;
+        assert repositoryManager != null;
+        
+        return delegate.resolveTransitively(artifacts, artifact, managedVersions, localRepository, repositoryManager.selectRemoteRepositories(remoteRepositories), source, filter, listeners, conflictResolvers);
+    }
+
+    public void resolveAlways(Artifact artifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository) throws ArtifactResolutionException, ArtifactNotFoundException {
+        assert delegate != null;
+        assert repositoryManager != null;
+        
+        delegate.resolveAlways(artifact, repositoryManager.selectRemoteRepositories(remoteRepositories), localRepository);
+    }
+
+    public ArtifactResolutionResult resolve(ArtifactResolutionRequest request) {
+        assert request != null;
+        assert delegate != null;
+        assert repositoryManager != null;
+        
+        request.setRemoteRepostories(repositoryManager.selectRemoteRepositories(request.getRemoteRepostories()));
+
+        return delegate.resolve(request);
+    }
+}
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/GShellArtifactResolver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/GShellArtifactResolver.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/GShellArtifactResolver.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/InvalidRepositoryException.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/InvalidRepositoryException.java?rev=719819&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/InvalidRepositoryException.java (added)
+++ geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/InvalidRepositoryException.java Fri Nov 21 23:14:03 2008
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ */
+
+package org.apache.geronimo.gshell.artifact;
+
+/**
+ * Thrown to indicate that a given repository is not valid.
+ *
+ * @version $Rev$ $Date$
+ */
+public class InvalidRepositoryException
+    extends ArtifactManagerException
+{
+    private static final long serialVersionUID = 1;
+
+    public InvalidRepositoryException(final String msg, final Throwable cause) {
+        super(msg, cause);
+    }
+
+    public InvalidRepositoryException(final String msg) {
+        super(msg);
+    }
+
+    public InvalidRepositoryException(final Throwable cause) {
+        super(cause);
+    }
+
+    public InvalidRepositoryException() {
+        super();
+    }
+}
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/InvalidRepositoryException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/InvalidRepositoryException.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/InvalidRepositoryException.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/ResolutionException.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/ResolutionException.java?rev=719819&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/ResolutionException.java (added)
+++ geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/ResolutionException.java Fri Nov 21 23:14:03 2008
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+
+package org.apache.geronimo.gshell.artifact;
+
+import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
+import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
+
+/**
+ * Thrown to indicate that an artifact resolution request has failed.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ResolutionException
+    extends ArtifactManagerException
+{
+    private static final long serialVersionUID = 1;
+
+    public final ArtifactResolutionRequest request;
+    
+    public final ArtifactResolutionResult result;
+
+    public ResolutionException(final ArtifactResolutionRequest request, final ArtifactResolutionResult result) {
+        assert request != null;
+        assert result != null;
+
+        this.request = request;
+        this.result = result;
+    }
+
+    //
+    // TODO: Add an API to query the results?
+    //
+}
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/ResolutionException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/ResolutionException.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/ResolutionException.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/Slf4jLoggingManager.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/Slf4jLoggingManager.java?rev=719819&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/Slf4jLoggingManager.java (added)
+++ geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/Slf4jLoggingManager.java Fri Nov 21 23:14:03 2008
@@ -0,0 +1,91 @@
+/*
+ * 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.
+ */
+
+package org.apache.geronimo.gshell.artifact;
+
+import org.codehaus.plexus.logging.AbstractLogger;
+import org.codehaus.plexus.logging.BaseLoggerManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Adapts the Plexus logging system to SLF4J.
+ *
+ * @version $Rev$ $Date$
+ */
+public class Slf4jLoggingManager
+    extends BaseLoggerManager
+{
+    //
+    // FIXME: Probably need to change this to avoid picking up the BaseLoggerManager, just implement everything ourselves
+    //        Might be able to use AbstractLoggerManager
+
+    protected org.codehaus.plexus.logging.Logger createLogger(final String key) {
+        return new LoggerImpl(getThreshold(), LoggerFactory.getLogger(key));
+    }
+
+    public org.codehaus.plexus.logging.Logger getLoggerForComponent(final String role, final String roleHint) {
+        return createLogger(toMapKey(role, roleHint));
+    }
+
+    public void returnComponentLogger(final String role, final String roleHint) {
+        // Ignore
+    }
+    
+    /**
+     * Adapts the Plexus {@link org.codehaus.plexus.logging.Logger} interface to SLF4J
+     */
+    public static class LoggerImpl
+        extends AbstractLogger
+    {
+        private final Logger log;
+
+        public LoggerImpl(final int threshold, final Logger logger) {
+            super(threshold, logger.getName());
+
+            this.log = logger;
+        }
+
+        public void debug(final String message, final Throwable throwable) {
+            log.debug( message, throwable );
+        }
+
+        public void error(final String message, final Throwable throwable) {
+            log.error(message, throwable);
+        }
+
+        public void fatalError(final String message, final Throwable throwable) {
+            log.error(message, throwable);
+        }
+
+        public org.codehaus.plexus.logging.Logger getChildLogger(final String name) {
+            String childName = log.getName() + "." + name;
+
+            return new LoggerImpl(getThreshold(), LoggerFactory.getLogger(childName));
+        }
+
+        public void info(String message, final Throwable throwable) {
+            log.info(message, throwable);
+        }
+
+        public void warn(String message, final Throwable throwable) {
+            log.warn(message, throwable);
+        }
+    }
+}
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/Slf4jLoggingManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/Slf4jLoggingManager.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/Slf4jLoggingManager.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/monitor/ProgressSpinner.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/monitor/ProgressSpinner.java?rev=719819&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/monitor/ProgressSpinner.java (added)
+++ geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/monitor/ProgressSpinner.java Fri Nov 21 23:14:03 2008
@@ -0,0 +1,115 @@
+/*
+ * 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.
+ */
+
+package org.apache.geronimo.gshell.artifact.monitor;
+
+/**
+ * Provides a fancy text-based progress spinner w/optional informative message.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ProgressSpinner
+{
+    private static final String MESSAGE_PAD = " ";
+
+    private final Style style;
+
+    private int state = 0;
+
+    public ProgressSpinner(final Style style) {
+        assert style != null;
+
+        this.style = style;
+    }
+
+    public ProgressSpinner() {
+        this(new DefaultStyle());
+    }
+
+    public void reset() {
+        state = 0;
+    }
+    
+    public String spin() {
+        return spin(null);
+    }
+
+    public String spin(final String message) {
+        // message may be null
+        
+        StringBuffer buff = new StringBuffer();
+
+        String[] elements = style.getElements();
+        buff.append(style.getPrefix());
+        buff.append(elements[state]);
+        buff.append(style.getSuffix());
+
+        if (message != null) {
+            buff.append(MESSAGE_PAD);
+            buff.append(message);
+        }
+
+        state++;
+        if (state >= elements.length) {
+            state = 0;
+        }
+
+        return buff.toString();
+    }
+
+    //
+    // Style
+    //
+
+    public static interface Style
+    {
+        String getPrefix();
+
+        String[] getElements();
+
+        String getSuffix();
+    }
+
+    //
+    // Default Style
+    //
+    
+    public static class DefaultStyle
+        implements Style
+    {
+        private static final String[] ELEMENTS = {
+            "|",
+            "/",
+            "-",
+            "\\",
+        };
+
+        public String getPrefix() {
+            return "(";
+        }
+
+        public String[] getElements() {
+            return ELEMENTS;
+        }
+
+        public String getSuffix() {
+            return ")";
+        }
+    }
+}
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/monitor/ProgressSpinner.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/monitor/ProgressSpinner.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/monitor/ProgressSpinner.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/monitor/ProgressSpinnerMonitor.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/monitor/ProgressSpinnerMonitor.java?rev=719819&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/monitor/ProgressSpinnerMonitor.java (added)
+++ geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/monitor/ProgressSpinnerMonitor.java Fri Nov 21 23:14:03 2008
@@ -0,0 +1,125 @@
+/*
+ * 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.
+ */
+
+package org.apache.geronimo.gshell.artifact.monitor;
+
+import org.apache.geronimo.gshell.io.IO;
+import static org.apache.maven.wagon.WagonConstants.UNKNOWN_LENGTH;
+import org.apache.maven.wagon.events.TransferEvent;
+import static org.apache.maven.wagon.events.TransferEvent.REQUEST_PUT;
+
+import java.io.IOException;
+
+/**
+ * A download monitor providing a simple spinning progress interface.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ProgressSpinnerMonitor
+    extends TransferListenerSupport
+{
+    private static final String CARRIAGE_RETURN = "\r";
+
+    private final IO io;
+
+    private final ProgressSpinner spinner = new ProgressSpinner();
+
+    private long complete;
+
+    public ProgressSpinnerMonitor(final IO io) throws IOException {
+        assert io != null;
+
+        this.io = io;
+    }
+    
+    private void print(final String message) {
+        if (!io.isQuiet()) {
+            io.out.print(message);
+            io.out.print(CARRIAGE_RETURN);
+            io.out.flush();
+        }
+    }
+
+    private void println(final String message) {
+        if (!io.isQuiet()) {
+            io.out.println(message);
+            io.out.flush();
+        }
+    }
+
+    //
+    // TODO: May actually want to use a little timmer thread to make this spin more often for better user feedback
+    //       that we are still working, then use the event to update the message.  Or really, put the timer in
+    //       the spinner impl, and then just update the status message
+    //
+    
+    public void transferStarted(final TransferEvent event) {
+        assert event != null;
+
+        super.transferStarted(event);
+
+        complete = 0;
+
+        spinner.reset();
+
+        String type = event.getRequestType() == REQUEST_PUT ? "Uploading" : "Downloading";
+        String url = event.getWagon().getRepository().getUrl();
+
+        String message = type + ": " + url + "/" + event.getResource().getName();
+
+        log.debug(message);
+
+        println(message);
+    }
+
+    public void transferProgress(final TransferEvent event, final byte[] buffer, final int length) {
+        assert event != null;
+
+        super.transferProgress(event, buffer, length);
+
+        long total = event.getResource().getContentLength();
+        complete += length;
+
+        String message;
+
+        if (total >= 1024) {
+            message = complete / 1024 + "/" + (total == UNKNOWN_LENGTH ? "?" : total / 1024 + "K");
+        }
+        else {
+            message = complete + "/" + (total == UNKNOWN_LENGTH ? "?" : total + "b");
+        }
+
+        log.trace(message);
+        
+        print(spinner.spin(message));
+    }
+
+    public void transferCompleted(final TransferEvent event) {
+        assert event != null;
+
+        super.transferCompleted(event);
+
+        long length = event.getResource().getContentLength();
+        String type = event.getRequestType() == REQUEST_PUT ? "Uploaded" : "Downloaded";
+        String bytes = length >= 1024 ? ( length / 1024 ) + "K" : length + "b";
+
+        // pad at end just incase, should really blank the reset of the line
+        print(type + " " + bytes + "          ");
+    }
+}
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/monitor/ProgressSpinnerMonitor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/monitor/ProgressSpinnerMonitor.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/monitor/ProgressSpinnerMonitor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/monitor/TransferListenerSupport.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/monitor/TransferListenerSupport.java?rev=719819&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/monitor/TransferListenerSupport.java (added)
+++ geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/monitor/TransferListenerSupport.java Fri Nov 21 23:14:03 2008
@@ -0,0 +1,69 @@
+/*
+ * 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.
+ */
+
+package org.apache.geronimo.gshell.artifact.monitor;
+
+import org.apache.maven.wagon.events.TransferEvent;
+import org.apache.maven.wagon.events.TransferListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Support for Wagon {@link TransferListener} implementations.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TransferListenerSupport
+    implements TransferListener
+{
+    protected final Logger log = LoggerFactory.getLogger(getClass());
+
+    public void transferInitiated(final TransferEvent event) {
+        log.trace("Transfer initiated: {}", event);
+    }
+
+    public void transferStarted(final TransferEvent event) {
+        log.trace("Transfer started: {}", event);
+    }
+
+    public void transferProgress(final TransferEvent event, final byte[] buffer, final int length) {
+        log.trace("Transfer progress: {}, {}, {}", new Object[] { event, buffer, length });
+    }
+
+    public void transferCompleted(final TransferEvent event) {
+        log.trace("Transfer completed: {}", event);
+    }
+
+    public void transferError(final TransferEvent event) {
+        log.trace("Transfer error: {}", event);
+
+        assert event != null;
+
+        Throwable cause = event.getException();
+        assert cause != null;
+        
+        log.error("Transfer failure: " + cause, cause);
+    }
+
+    public void debug(final String message) {
+        assert message != null;
+        
+        log.debug(message);
+    }
+}
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/monitor/TransferListenerSupport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/monitor/TransferListenerSupport.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/java/org/apache/geronimo/gshell/artifact/monitor/TransferListenerSupport.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/resources/META-INF/plexus/components.xml?rev=719819&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/resources/META-INF/plexus/components.xml (added)
+++ geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/resources/META-INF/plexus/components.xml Fri Nov 21 23:14:03 2008
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+
+<!-- $Rev$ $Date$ -->
+
+<component-set>
+    <components>
+        <component>
+            <role>org.apache.geronimo.gshell.artifact.ArtifactManager</role>
+            <implementation>org.apache.geronimo.gshell.artifact.DefaultArtifactManager</implementation>
+            <isolated-realm>false</isolated-realm>
+            <requirements>
+                <requirement>
+                    <role>org.apache.maven.artifact.factory.ArtifactFactory</role>
+                    <field-name>artifactFactory</field-name>
+                </requirement>
+                <requirement>
+                    <role>org.apache.geronimo.gshell.artifact.ArtifactRepositoryManager</role>
+                    <field-name>repositoryManager</field-name>
+                </requirement>
+                <requirement>
+                    <role>org.apache.maven.artifact.resolver.ArtifactResolver</role>
+                    <field-name>artifactResolver</field-name>
+                </requirement>
+                <requirement>
+                    <role>org.apache.maven.artifact.metadata.ArtifactMetadataSource</role>
+                    <role-hint>gshell</role-hint>
+                    <field-name>artifactMetadataSource</field-name>
+                </requirement>
+                <requirement>
+                    <role>org.apache.maven.artifact.manager.WagonManager</role>
+                    <field-name>wagonManager</field-name>
+                </requirement>
+            </requirements>
+        </component>
+
+        <component>
+            <role>org.apache.geronimo.gshell.artifact.ArtifactRepositoryManager</role>
+            <implementation>org.apache.geronimo.gshell.artifact.DefaultArtifactRepositoryManager</implementation>
+            <isolated-realm>false</isolated-realm>
+            <requirements>
+                <requirement>
+                    <role>org.apache.maven.artifact.repository.ArtifactRepositoryFactory</role>
+                    <field-name>repositoryFactory</field-name>
+                </requirement>
+            </requirements>
+        </component>
+
+        <component>
+            <role>org.apache.maven.artifact.metadata.ArtifactMetadataSource</role>
+            <role-hint>gshell</role-hint>
+            <implementation>org.apache.geronimo.gshell.artifact.GShellArtifactMetadataSource</implementation>
+            <isolated-realm>false</isolated-realm>
+            <requirements>
+                <requirement>
+                    <role>org.apache.maven.artifact.metadata.ArtifactMetadataSource</role>
+                    <role-hint>maven</role-hint>
+                    <field-name>delegate</field-name>
+                </requirement>
+                <requirement>
+                    <role>org.apache.geronimo.gshell.artifact.ArtifactRepositoryManager</role>
+                    <field-name>repositoryManager</field-name>
+                </requirement>
+            </requirements>
+        </component>
+
+        <component>
+            <role>org.apache.maven.artifact.resolver.ArtifactResolver</role>
+            <role-hint>gshell</role-hint>
+            <implementation>org.apache.geronimo.gshell.artifact.GShellArtifactResolver</implementation>
+            <isolated-realm>false</isolated-realm>
+            <requirements>
+                <requirement>
+                    <role>org.apache.maven.artifact.resolver.ArtifactResolver</role>
+                    <role-hint>delegate</role-hint>
+                    <field-name>delegate</field-name>
+                </requirement>
+                <requirement>
+                    <role>org.apache.geronimo.gshell.artifact.ArtifactRepositoryManager</role>
+                    <field-name>repositoryManager</field-name>
+                </requirement>
+            </requirements>
+        </component>
+    </components>
+</component-set>

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/resources/META-INF/plexus/components.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/resources/META-INF/plexus/components.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact-maven/src/main/resources/META-INF/plexus/components.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml