geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r659493 - in /geronimo/gshell/trunk: gshell-core/src/main/java/org/apache/geronimo/gshell/application/ gshell-core/src/main/java/org/apache/geronimo/gshell/settings/ gshell-model/src/main/java/org/apache/geronimo/gshell/model/common/ gshell...
Date Fri, 23 May 2008 10:35:13 GMT
Author: jdillon
Date: Fri May 23 03:35:12 2008
New Revision: 659493

URL: http://svn.apache.org/viewvc?rev=659493&view=rev
Log:
Moved config validation to config objects
Added some muck to try and guess a repos id from a uri
Update artifact API to use URI instead of URL

Modified:
    geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/application/ApplicationConfiguration.java
    geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/application/DefaultApplicationManager.java
    geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/settings/DefaultSettingsManager.java
    geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/settings/SettingsConfiguration.java
    geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/common/LocalRepository.java
    geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/common/RemoteRepository.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/ApplicationConfiguration.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/application/ApplicationConfiguration.java?rev=659493&r1=659492&r2=659493&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/application/ApplicationConfiguration.java
(original)
+++ geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/application/ApplicationConfiguration.java
Fri May 23 03:35:12 2008
@@ -78,6 +78,12 @@
         this.application = application;
     }
 
+    public void validate() {
+        if (application == null) {
+            throw new IllegalStateException("Missing application configuration");
+        }    
+    }
+
     public String toString() {
         return ReflectionToStringBuilder.toString(this, ToStringStyle.SHORT_PREFIX_STYLE);
     }

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=659493&r1=659492&r2=659493&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:35:12 2008
@@ -21,7 +21,6 @@
 
 import org.apache.geronimo.gshell.GShell;
 import org.apache.geronimo.gshell.io.IO;
-import org.apache.geronimo.gshell.layout.LayoutManager;
 import org.apache.geronimo.gshell.artifact.ArtifactManager;
 import org.apache.geronimo.gshell.lookup.EnvironmentLookup;
 import org.apache.geronimo.gshell.lookup.IOLookup;
@@ -29,7 +28,6 @@
 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.layout.Layout;
 import org.apache.geronimo.gshell.plexus.GShellPlexusContainer;
 import org.apache.geronimo.gshell.shell.Environment;
 import org.apache.geronimo.gshell.shell.InteractiveShell;
@@ -102,10 +100,9 @@
         log.debug("Configuring; config: {}", config);
 
         // Validate the configuration
+        config.validate();
+
         Application application = config.getApplication();
-        if (application == null) {
-            throw new IllegalStateException("Missing application configuration");
-        }
         log.debug("Application: {}", application);
 
         // Apply artifact manager configuration settings for application
@@ -153,10 +150,7 @@
 
         if (remoteRepositories != null) {
             for (RemoteRepository repo : remoteRepositories) {
-                String loc = repo.getLocation();
-                URL url = new URL(loc);
-                String id = url.getHost(); // FIXME: Need to expose the repo id in the model,
for now assume the id is the hostname
-                artifactManager.addRemoteRepository(id, url);
+                artifactManager.addRemoteRepository(repo.getId(), repo.getLocationUri());
             }
         }
     }
@@ -174,21 +168,21 @@
             realm.addURL(url);
         }
 
-        ContainerConfiguration cc = new DefaultContainerConfiguration();
-        cc.setName(application.getId());
-        cc.setClassWorld(classWorld);
-        cc.setRealm(realm);
+        ContainerConfiguration config = new DefaultContainerConfiguration();
+        config.setName(application.getId());
+        config.setClassWorld(classWorld);
+        config.setRealm(realm);
 
         // HACK: Should need these here, but for some reason components are getting instantiated
in the wrong container
         //       so for now to get something working again, use the parent containers configuration
set in GShellBuilder
 
         // For now use the old Command* bits to get things working, then refactor to use
the new Plugin* bits
-        // cc.addComponentDiscoverer(new CommandDiscoverer());
-        // cc.addComponentDiscoveryListener(new CommandCollector());
-        // cc.addComponentDiscoverer(new PluginDiscoverer());
-        // cc.addComponentDiscoveryListener(new PluginCollector());
+        // config.addComponentDiscoverer(new CommandDiscoverer());
+        // config.addComponentDiscoveryListener(new CommandCollector());
+        // config.addComponentDiscoverer(new PluginDiscoverer());
+        // config.addComponentDiscoveryListener(new PluginCollector());
 
-        GShellPlexusContainer child = parentContainer.createChild(cc);
+        GShellPlexusContainer child = parentContainer.createChild(config);
 
         log.debug("Application container: {}", child);
 

Modified: geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/settings/DefaultSettingsManager.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/settings/DefaultSettingsManager.java?rev=659493&r1=659492&r2=659493&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/settings/DefaultSettingsManager.java
(original)
+++ geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/settings/DefaultSettingsManager.java
Fri May 23 03:35:12 2008
@@ -28,6 +28,7 @@
 import org.slf4j.LoggerFactory;
 
 import java.net.URL;
+import java.net.URI;
 import java.util.List;
 
 /**
@@ -59,6 +60,9 @@
 
         log.debug("Configuring; config: {}", config);
 
+        // Validate the configuration
+        config.validate();
+        
         Settings settings = config.getSettings();
         if (settings != null) {
             configure(settings);
@@ -76,10 +80,7 @@
         
         if (remoteRepositories != null) {
             for (RemoteRepository repo : remoteRepositories) {
-                String loc = repo.getLocation();
-                URL url = new URL(loc);
-                String id = url.getHost(); // FIXME: Need to expose the repo id in the model,
for now assume the id is the hostname
-                artifactManager.addRemoteRepository(id, url);
+                artifactManager.addRemoteRepository(repo.getId(), repo.getLocationUri());
             }
         }
 

Modified: geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/settings/SettingsConfiguration.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/settings/SettingsConfiguration.java?rev=659493&r1=659492&r2=659493&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/settings/SettingsConfiguration.java
(original)
+++ geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/settings/SettingsConfiguration.java
Fri May 23 03:35:12 2008
@@ -40,6 +40,10 @@
         this.settings = settings;
     }
 
+    public void validate() {
+        // Nothing ATM
+    }
+    
     public String toString() {
         return ReflectionToStringBuilder.toString(this, ToStringStyle.SHORT_PREFIX_STYLE);
     }

Modified: geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/common/LocalRepository.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/common/LocalRepository.java?rev=659493&r1=659492&r2=659493&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/common/LocalRepository.java
(original)
+++ geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/common/LocalRepository.java
Fri May 23 03:35:12 2008
@@ -43,10 +43,13 @@
     }
 
     public File getDirectoryFile() {
-        String path = getDirectory();
-        assert path != null;
-        
-        return new File(path);
+        String tmp = getDirectory();
+
+        if (tmp != null) {
+            return new File(tmp);
+        }
+
+        return null;
     }
 
     public void setDirectoryFile(final File directory) {

Modified: geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/common/RemoteRepository.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/common/RemoteRepository.java?rev=659493&r1=659492&r2=659493&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/common/RemoteRepository.java
(original)
+++ geronimo/gshell/trunk/gshell-model/src/main/java/org/apache/geronimo/gshell/model/common/RemoteRepository.java
Fri May 23 03:35:12 2008
@@ -33,8 +33,29 @@
 public class RemoteRepository
     extends ModelElement
 {
+    private String id;
+
     private String location;
 
+    public String getId() {
+        // If no id was configured, and we have a valid location, then try to figure out
a reasonable ID from the URI
+        if (id == null && location != null) {
+            try {
+                // FIXME: This dosen't give too well with URI's that don't have a <host>
bit, like file:
+                return getLocationUri().getHost();
+            }
+            catch (URISyntaxException e) {
+                throw new RuntimeException(e);
+            }
+        }
+
+        return id;
+    }
+
+    public void setId(final String id) {
+        this.id = id;
+    }
+
     public String getLocation() {
         return location;
     }
@@ -45,9 +66,12 @@
 
     public URI getLocationUri() throws URISyntaxException {
         String tmp = getLocation();
-        assert tmp != null;
 
-        return new URI(tmp);
+        if (tmp != null) {
+            return new URI(tmp);
+        }
+
+        return null;
     }
 
     public void setLocationUri(final URI uri) {

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=659493&r1=659492&r2=659493&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:35:12 2008
@@ -19,18 +19,18 @@
 
 package org.apache.geronimo.gshell.artifact;
 
-import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
-import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
-import org.apache.maven.artifact.repository.ArtifactRepository;
 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;
+import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
 import org.apache.maven.wagon.events.TransferListener;
 
-import java.util.List;
 import java.io.File;
-import java.net.URL;
 import java.net.MalformedURLException;
+import java.net.URI;
+import java.util.List;
 
 /**
  * Provides a facade over the artifact + repository subsystem.
@@ -49,8 +49,7 @@
 
     void addRemoteRepository(ArtifactRepository repository);
 
-    // TODO: Change to URI
-    void addRemoteRepository(String id, URL url) throws UnknownRepositoryLayoutException;
+    void addRemoteRepository(String id, URI location) throws MalformedURLException, UnknownRepositoryLayoutException;
 
     ArtifactFactory getArtifactFactory();
 

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=659493&r1=659492&r2=659493&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:35:12 2008
@@ -37,7 +37,8 @@
 import org.slf4j.LoggerFactory;
 
 import java.io.File;
-import java.net.URL;
+import java.net.MalformedURLException;
+import java.net.URI;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -86,7 +87,9 @@
     public void setLocalRepository(final File dir) throws InvalidRepositoryException {
         assert dir != null;
 
-        localRepository = repositoryFactory.createLocalRepository(dir);
+        ArtifactRepository repo = repositoryFactory.createLocalRepository(dir);
+
+        setLocalRepository(repo);
     }
 
     public List<ArtifactRepository> getRemoteRepositories() {
@@ -101,18 +104,20 @@
         log.debug("Added remote repository: {}", repository);
     }
 
-    public void addRemoteRepository(final String id, final URL url) throws UnknownRepositoryLayoutException
{
+    public void addRemoteRepository(final String id, final URI location) throws UnknownRepositoryLayoutException,
MalformedURLException {
         assert id != null;
-        assert url != null;
+        assert location != null;
 
         ArtifactRepository repo = repositoryFactory.createArtifactRepository(
             id,
-            url.toExternalForm(),
+            location.toURL().toExternalForm(),
             ArtifactRepositoryFactory.DEFAULT_LAYOUT_ID,
+
+            // FIXME: Expose more configuration to user API
             new ArtifactRepositoryPolicy(),  // snapshots
             new ArtifactRepositoryPolicy()); // releases
         
-        remoteRepositories.add(repo);
+        addRemoteRepository(repo);
     }
 
     public ArtifactFactory getArtifactFactory() {
@@ -150,6 +155,10 @@
 
         log.debug("Resolution result: {}", result);
 
+        //
+        // TODO: Perform error/failure detection muck here, and toss a new exception with
an easier interface for consuption of this information
+        //
+
         return result;
     }
 }
\ No newline at end of file



Mime
View raw message