geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r659498 - in /geronimo/gshell/trunk: gshell-core/src/main/java/org/apache/geronimo/gshell/application/ gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/
Date Fri, 23 May 2008 10:57:09 GMT
Author: jdillon
Date: Fri May 23 03:57:08 2008
New Revision: 659498

URL: http://svn.apache.org/viewvc?rev=659498&view=rev
Log:
Add some exceptions to the gshell-artifact facade

Added:
    geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactManagerException.java
      - copied, changed from r659493, geronimo/gshell/trunk/gshell-support/gshell-common/src/main/java/org/apache/geronimo/gshell/common/NestedIOException.java
    geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactResolutionException.java
  (with props)
    geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/InvalidRepositoryException.java
  (with props)
Modified:
    geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/application/DefaultApplicationManager.java
    geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactManager.java
    geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/DefaultArtifactManager.java

Modified: geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/application/DefaultApplicationManager.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/application/DefaultApplicationManager.java?rev=659498&r1=659497&r2=659498&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/application/DefaultApplicationManager.java
(original)
+++ geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/application/DefaultApplicationManager.java
Fri May 23 03:57:08 2008
@@ -20,14 +20,14 @@
 package org.apache.geronimo.gshell.application;
 
 import org.apache.geronimo.gshell.GShell;
-import org.apache.geronimo.gshell.io.IO;
 import org.apache.geronimo.gshell.artifact.ArtifactManager;
+import org.apache.geronimo.gshell.io.IO;
 import org.apache.geronimo.gshell.lookup.EnvironmentLookup;
 import org.apache.geronimo.gshell.lookup.IOLookup;
 import org.apache.geronimo.gshell.model.application.Application;
 import org.apache.geronimo.gshell.model.common.Dependency;
-import org.apache.geronimo.gshell.model.common.RemoteRepository;
 import org.apache.geronimo.gshell.model.common.LocalRepository;
+import org.apache.geronimo.gshell.model.common.RemoteRepository;
 import org.apache.geronimo.gshell.plexus.GShellPlexusContainer;
 import org.apache.geronimo.gshell.shell.Environment;
 import org.apache.geronimo.gshell.shell.InteractiveShell;
@@ -51,7 +51,6 @@
 import org.slf4j.LoggerFactory;
 
 import java.io.File;
-import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.LinkedHashSet;
 import java.util.LinkedList;
@@ -81,6 +80,10 @@
     public void contextualize(final Context context) throws ContextException {
         assert context != null;
 
+        //
+        // FIXME: See if we need to use Contextualize here, or if the @Requirement bits inject
the correct container instance
+        //
+        
         parentContainer = (GShellPlexusContainer) context.get(PlexusConstants.PLEXUS_KEY);
         
         log.debug("Parent container: {}", parentContainer);
@@ -189,7 +192,7 @@
         return child;
     }
 
-    private List<URL> createClassPath(final Application application) throws MalformedURLException
{
+    private List<URL> createClassPath(final Application application) throws Exception
{
         assert application != null;
 
         ArtifactFactory factory = artifactManager.getArtifactFactory();
@@ -220,10 +223,6 @@
 
         ArtifactResolutionResult result = artifactManager.resolve(request);
 
-        //
-        // FIXME: Validate the result and complain if not valid (exceptions/missing/whatever),
may want to move that to the AM
-        //
-
         List<URL> classPath = new LinkedList<URL>();
         Set<Artifact> resolvedArtifacts = result.getArtifacts();
 

Modified: geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactManager.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactManager.java?rev=659498&r1=659497&r2=659498&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactManager.java
(original)
+++ geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactManager.java
Fri May 23 03:57:08 2008
@@ -19,8 +19,6 @@
 
 package org.apache.geronimo.gshell.artifact;
 
-import org.apache.maven.artifact.InvalidRepositoryException;
-import org.apache.maven.artifact.UnknownRepositoryLayoutException;
 import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
@@ -28,7 +26,6 @@
 import org.apache.maven.wagon.events.TransferListener;
 
 import java.io.File;
-import java.net.MalformedURLException;
 import java.net.URI;
 import java.util.List;
 
@@ -41,19 +38,19 @@
 {
     ArtifactRepository getLocalRepository();
 
-    void setLocalRepository(ArtifactRepository repository);
+    void setLocalRepository(ArtifactRepository repository) throws InvalidRepositoryException;
 
-    void setLocalRepository(File dir) throws MalformedURLException, InvalidRepositoryException;
+    void setLocalRepository(File dir) throws InvalidRepositoryException;
 
     List<ArtifactRepository> getRemoteRepositories();
 
-    void addRemoteRepository(ArtifactRepository repository);
+    void addRemoteRepository(ArtifactRepository repository) throws InvalidRepositoryException;
 
-    void addRemoteRepository(String id, URI location) throws MalformedURLException, UnknownRepositoryLayoutException;
+    void addRemoteRepository(String id, URI location) throws InvalidRepositoryException;
 
     ArtifactFactory getArtifactFactory();
 
     void setDownloadMonitor(TransferListener listener);
 
-    ArtifactResolutionResult resolve(ArtifactResolutionRequest request);
+    ArtifactResolutionResult resolve(ArtifactResolutionRequest request) throws ArtifactResolutionException;
 }
\ No newline at end of file

Copied: geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactManagerException.java
(from r659493, geronimo/gshell/trunk/gshell-support/gshell-common/src/main/java/org/apache/geronimo/gshell/common/NestedIOException.java)
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactManagerException.java?p2=geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactManagerException.java&p1=geronimo/gshell/trunk/gshell-support/gshell-common/src/main/java/org/apache/geronimo/gshell/common/NestedIOException.java&r1=659493&r2=659498&rev=659498&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-common/src/main/java/org/apache/geronimo/gshell/common/NestedIOException.java
(original)
+++ geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactManagerException.java
Fri May 23 03:57:08 2008
@@ -17,35 +17,31 @@
  * under the License.
  */
 
-package org.apache.geronimo.gshell.common;
-
-import java.io.IOException;
+package org.apache.geronimo.gshell.artifact;
 
 /**
- * Nested {@link IOException}.
+ * Thrown to indicate a problem with an {@link ArtifactManager} operation.
  *
- * @version $Rev: 577545 $ $Date: 2007-09-19 21:55:19 -0700 (Wed, 19 Sep 2007) $
+ * @version $Rev$ $Date$
  */
-public class NestedIOException
-    extends IOException
+public class ArtifactManagerException
+    extends Exception
 {
     private static final long serialVersionUID = 1;
 
-    public NestedIOException(final String msg, final Throwable cause) {
-        super(msg);
-
-        initCause(cause);
+    public ArtifactManagerException(final String msg, final Throwable cause) {
+        super(msg, cause);
     }
 
-    public NestedIOException(final String msg) {
+    public ArtifactManagerException(final String msg) {
         super(msg);
     }
 
-    public NestedIOException(final Throwable cause) {
-        initCause(cause);
+    public ArtifactManagerException(final Throwable cause) {
+        super(cause);
     }
 
-    public NestedIOException() {
+    public ArtifactManagerException() {
         super();
     }
 }
\ No newline at end of file

Added: geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactResolutionException.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactResolutionException.java?rev=659498&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactResolutionException.java
(added)
+++ geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactResolutionException.java
Fri May 23 03:57:08 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.ArtifactResolutionResult;
+import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
+
+/**
+ * Thrown to indicate that a given repository is not valid.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ArtifactResolutionException
+    extends ArtifactManagerException
+{
+    private static final long serialVersionUID = 1;
+
+    public final ArtifactResolutionRequest request;
+    
+    public final ArtifactResolutionResult result;
+
+    public ArtifactResolutionException(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/src/main/java/org/apache/geronimo/gshell/artifact/ArtifactResolutionException.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

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

Modified: geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/DefaultArtifactManager.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/DefaultArtifactManager.java?rev=659498&r1=659497&r2=659498&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/DefaultArtifactManager.java
(original)
+++ geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/DefaultArtifactManager.java
Fri May 23 03:57:08 2008
@@ -19,8 +19,6 @@
 
 package org.apache.geronimo.gshell.artifact;
 
-import org.apache.maven.artifact.InvalidRepositoryException;
-import org.apache.maven.artifact.UnknownRepositoryLayoutException;
 import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.manager.WagonManager;
 import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
@@ -37,7 +35,6 @@
 import org.slf4j.LoggerFactory;
 
 import java.io.File;
-import java.net.MalformedURLException;
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.List;
@@ -76,7 +73,7 @@
         return localRepository;
     }
 
-    public void setLocalRepository(final ArtifactRepository repository) {
+    public void setLocalRepository(final ArtifactRepository repository) throws InvalidRepositoryException
{
         assert repository != null;
 
         localRepository = repository;
@@ -87,16 +84,20 @@
     public void setLocalRepository(final File dir) throws InvalidRepositoryException {
         assert dir != null;
 
-        ArtifactRepository repo = repositoryFactory.createLocalRepository(dir);
-
-        setLocalRepository(repo);
+        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) {
+    public void addRemoteRepository(final ArtifactRepository repository) throws InvalidRepositoryException
{
         assert repository != null;
 
         remoteRepositories.add(repository);
@@ -104,20 +105,25 @@
         log.debug("Added remote repository: {}", repository);
     }
 
-    public void addRemoteRepository(final String id, final URI location) throws UnknownRepositoryLayoutException,
MalformedURLException {
+    public void addRemoteRepository(final String id, final URI location) throws InvalidRepositoryException
{
         assert id != null;
         assert location != null;
 
-        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);
+        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);
+        }
     }
 
     public ArtifactFactory getArtifactFactory() {
@@ -132,7 +138,7 @@
         log.debug("Using download monitor: {}", listener);
     }
     
-    public ArtifactResolutionResult resolve(final ArtifactResolutionRequest request) {
+    public ArtifactResolutionResult resolve(final ArtifactResolutionRequest request) throws
ArtifactResolutionException {
         assert request != null;
 
         // Automatically fill in some missing bits
@@ -153,11 +159,18 @@
 
         ArtifactResolutionResult result = artifactResolver.resolve(request);
 
-        log.debug("Resolution result: {}", result);
+        return validateResolutionResult(request, result);
+    }
+
+    private ArtifactResolutionResult validateResolutionResult(final ArtifactResolutionRequest
request, final ArtifactResolutionResult result) throws ArtifactResolutionException {
+        assert request != null;
+        assert result != null;
 
-        //
-        // TODO: Perform error/failure detection muck here, and toss a new exception with
an easier interface for consuption of this information
-        //
+        log.debug("Validating result: {}", result);
+
+        if (/* TODO: detect failure */ false) {
+            throw new ArtifactResolutionException(request, result);
+        }
 
         return result;
     }

Added: geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/InvalidRepositoryException.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/InvalidRepositoryException.java?rev=659498&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/InvalidRepositoryException.java
(added)
+++ geronimo/gshell/trunk/gshell-support/gshell-artifact/src/main/java/org/apache/geronimo/gshell/artifact/InvalidRepositoryException.java
Fri May 23 03:57:08 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/src/main/java/org/apache/geronimo/gshell/artifact/InvalidRepositoryException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-support/gshell-artifact/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/src/main/java/org/apache/geronimo/gshell/artifact/InvalidRepositoryException.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message