geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r641946 - in /geronimo/gshell/trunk: ./ gshell-core/ gshell-core/src/main/java/org/apache/geronimo/gshell/loader/ gshell-support/ gshell-support/gshell-plexus/ gshell-support/gshell-plexus/src/ gshell-support/gshell-plexus/src/main/ gshell-...
Date Thu, 27 Mar 2008 19:03:01 GMT
Author: jdillon
Date: Thu Mar 27 12:02:58 2008
New Revision: 641946

URL: http://svn.apache.org/viewvc?rev=641946&view=rev
Log:
Add gshell-plexus module, add more testing for the new loader muck

Added:
    geronimo/gshell/trunk/gshell-support/gshell-plexus/
    geronimo/gshell/trunk/gshell-support/gshell-plexus/pom.xml   (with props)
    geronimo/gshell/trunk/gshell-support/gshell-plexus/src/
    geronimo/gshell/trunk/gshell-support/gshell-plexus/src/main/
    geronimo/gshell/trunk/gshell-support/gshell-plexus/src/main/java/
    geronimo/gshell/trunk/gshell-support/gshell-plexus/src/main/java/org/
    geronimo/gshell/trunk/gshell-support/gshell-plexus/src/main/java/org/apache/
    geronimo/gshell/trunk/gshell-support/gshell-plexus/src/main/java/org/apache/geronimo/
    geronimo/gshell/trunk/gshell-support/gshell-plexus/src/main/java/org/apache/geronimo/gshell/
    geronimo/gshell/trunk/gshell-support/gshell-plexus/src/main/java/org/apache/geronimo/gshell/support/
    geronimo/gshell/trunk/gshell-support/gshell-plexus/src/main/java/org/apache/geronimo/gshell/support/plexus/
    geronimo/gshell/trunk/gshell-support/gshell-plexus/src/main/java/org/apache/geronimo/gshell/support/plexus/GShellPlexusContainer.java
  (with props)
    geronimo/gshell/trunk/gshell-support/gshell-plexus/src/main/resources/
    geronimo/gshell/trunk/gshell-support/gshell-plexus/src/main/resources/org/
    geronimo/gshell/trunk/gshell-support/gshell-plexus/src/main/resources/org/apache/
    geronimo/gshell/trunk/gshell-support/gshell-plexus/src/main/resources/org/apache/geronimo/
    geronimo/gshell/trunk/gshell-support/gshell-plexus/src/main/resources/org/apache/geronimo/gshell/
    geronimo/gshell/trunk/gshell-support/gshell-plexus/src/main/resources/org/apache/geronimo/gshell/support/
    geronimo/gshell/trunk/gshell-support/gshell-plexus/src/main/resources/org/apache/geronimo/gshell/support/plexus/
    geronimo/gshell/trunk/gshell-support/gshell-plexus/src/test/
    geronimo/gshell/trunk/gshell-support/gshell-plexus/src/test/java/
    geronimo/gshell/trunk/gshell-support/gshell-plexus/src/test/java/org/
    geronimo/gshell/trunk/gshell-support/gshell-plexus/src/test/java/org/apache/
    geronimo/gshell/trunk/gshell-support/gshell-plexus/src/test/java/org/apache/geronimo/
    geronimo/gshell/trunk/gshell-support/gshell-plexus/src/test/java/org/apache/geronimo/gshell/
    geronimo/gshell/trunk/gshell-support/gshell-plexus/src/test/java/org/apache/geronimo/gshell/support/
    geronimo/gshell/trunk/gshell-support/gshell-plexus/src/test/java/org/apache/geronimo/gshell/support/plexus/
    geronimo/gshell/trunk/gshell-support/gshell-plexus/src/test/resources/
    geronimo/gshell/trunk/gshell-support/gshell-plexus/src/test/resources/org/
    geronimo/gshell/trunk/gshell-support/gshell-plexus/src/test/resources/org/apache/
    geronimo/gshell/trunk/gshell-support/gshell-plexus/src/test/resources/org/apache/geronimo/
    geronimo/gshell/trunk/gshell-support/gshell-plexus/src/test/resources/org/apache/geronimo/gshell/
    geronimo/gshell/trunk/gshell-support/gshell-plexus/src/test/resources/org/apache/geronimo/gshell/support/
    geronimo/gshell/trunk/gshell-support/gshell-plexus/src/test/resources/org/apache/geronimo/gshell/support/plexus/
Modified:
    geronimo/gshell/trunk/gshell-core/pom.xml
    geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/loader/GShellLoader.java
    geronimo/gshell/trunk/gshell-support/pom.xml
    geronimo/gshell/trunk/pom.xml

Modified: geronimo/gshell/trunk/gshell-core/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-core/pom.xml?rev=641946&r1=641945&r2=641946&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-core/pom.xml (original)
+++ geronimo/gshell/trunk/gshell-core/pom.xml Thu Mar 27 12:02:58 2008
@@ -39,6 +39,11 @@
 
     <dependencies>
         <dependency>
+            <groupId>org.apache.geronimo.gshell.support</groupId>
+            <artifactId>gshell-plexus</artifactId>
+        </dependency>
+
+        <dependency>
             <groupId>org.apache.geronimo.gshell</groupId>
             <artifactId>gshell-command-api</artifactId>
         </dependency>

Modified: geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/loader/GShellLoader.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/loader/GShellLoader.java?rev=641946&r1=641945&r2=641946&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/loader/GShellLoader.java
(original)
+++ geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/loader/GShellLoader.java
Thu Mar 27 12:02:58 2008
@@ -19,28 +19,27 @@
 
 package org.apache.geronimo.gshell.loader;
 
-import org.apache.geronimo.gshell.model.application.Application;
-import org.apache.geronimo.gshell.model.settings.Settings;
-import org.apache.geronimo.gshell.command.IO;
-import org.apache.geronimo.gshell.lookup.IOLookup;
-import org.apache.geronimo.gshell.lookup.EnvironmentLookup;
-import org.apache.geronimo.gshell.shell.Environment;
-import org.apache.geronimo.gshell.shell.InteractiveShell;
-import org.apache.geronimo.gshell.DefaultEnvironment;
-import org.apache.geronimo.gshell.security.ShellSecurityManager;
+import java.io.File;
+import java.net.MalformedURLException;
+
 import org.apache.geronimo.gshell.GShell;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
-import org.apache.maven.artifact.repository.DefaultArtifactRepository;
-import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.geronimo.gshell.support.plexus.GShellPlexusContainer;
+import org.apache.geronimo.gshell.plugin.CommandDiscoverer;
+import org.apache.geronimo.gshell.plugin.CommandDiscoveryListener;
+import org.apache.geronimo.gshell.command.IO;
+import org.apache.geronimo.gshell.model.application.Application;
 import org.codehaus.plexus.classworlds.ClassWorld;
-import org.codehaus.plexus.ContainerConfiguration;
 import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.ContainerConfiguration;
 import org.codehaus.plexus.DefaultContainerConfiguration;
 import org.codehaus.plexus.DefaultPlexusContainer;
 import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.DefaultArtifactRepository;
+import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
+import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Loads {@link org.apache.geronimo.gshell.GShell} instances.
@@ -55,15 +54,9 @@
 
     private final IO io;
 
-    private final Environment environment;
-
-    private final SecurityManager securityManager;
-
-    private final PlexusContainer container;
-
     private Application application;
 
-    private Settings settings;
+    private GShellPlexusContainer container;
 
     public GShellLoader(final ClassWorld classWorld, final IO io) throws Exception {
         assert classWorld != null;
@@ -71,73 +64,53 @@
 
         this.classWorld = classWorld;
         this.io = io;
-        this.environment = new DefaultEnvironment(io);
-        this.securityManager = new ShellSecurityManager();
-
-        this.container = createContainer();
-
-        // Install IO and Environment lookups
-        IOLookup.set(container, io);
-        EnvironmentLookup.set(container, environment);
     }
 
-    private PlexusContainer createContainer() throws Exception {
-        ContainerConfiguration config = new DefaultContainerConfiguration();
-        config.setName("gshell.core");
-        config.setClassWorld(classWorld);
-
-        return new DefaultPlexusContainer(config);
+    public GShellLoader(final IO io) throws Exception {
+        this(new ClassWorld("gshell", Thread.currentThread().getContextClassLoader()), io);
     }
 
-    private ArtifactRepository createArtifactRepository() throws ComponentLookupException
{
-        ArtifactRepositoryLayout repositoryLayout =
-                (ArtifactRepositoryLayout) container.lookup(ArtifactRepositoryLayout.ROLE,
"default");
-
-        ArtifactRepositoryFactory artifactRepositoryFactory =
-                (ArtifactRepositoryFactory) container.lookup(ArtifactRepositoryFactory.ROLE);
-
-        String url = null; //settings.getLocalRepository();
-
-        if (!url.startsWith("file:")) {
-            url = "file://" + url;
-        }
-
-        ArtifactRepository localRepository = new DefaultArtifactRepository("local", url,
repositoryLayout);
+    public GShellLoader() throws Exception {
+        this(new IO());
+    }
 
-        /*
-        boolean snapshotPolicySet = false;
+    public ArtifactRepository createLocalRepository(final File dir) throws ComponentLookupException,
MalformedURLException {
+        assert dir != null;
+        
+        ArtifactRepositoryLayout layout = container.lookupComponent(ArtifactRepositoryLayout.class,
"default");
+
+        DefaultArtifactRepository repo = new DefaultArtifactRepository("local",
+            dir.toURI().toURL().toExternalForm(),
+            layout,
+            new ArtifactRepositoryPolicy(),  // snapshots
+            new ArtifactRepositoryPolicy()); // releases
 
-        if (commandLine.hasOption(CLIManager.OFFLINE)) {
-            settings.setOffline(true);
+        repo.setBasedir(dir.getAbsolutePath());
 
-            snapshotPolicySet = true;
-        }
+        return repo;
+    }
 
-        if (!snapshotPolicySet && commandLine.hasOption(CLIManager.UPDATE_SNAPSHOTS))
{
-            artifactRepositoryFactory.setGlobalUpdatePolicy(ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS);
-        }
+    public GShell load() throws Exception {
+        return null;
+    }
 
-        if (commandLine.hasOption(CLIManager.CHECKSUM_FAILURE_POLICY)) {
-            System.out.println("+ Enabling strict checksum verification on all artifact downloads.");
+    public void test() throws Exception {
+        ContainerConfiguration config = new DefaultContainerConfiguration();
+        config.setName("gshell");
+        config.setClassWorld(classWorld);
+        // config.addComponentDiscoverer(new CommandDiscoverer());
+        // config.addComponentDiscoveryListener(new CommandDiscoveryListener());
 
-            artifactRepositoryFactory.setGlobalChecksumPolicy(ArtifactRepositoryPolicy.CHECKSUM_POLICY_FAIL);
-        } else if (commandLine.hasOption(CLIManager.CHECKSUM_WARNING_POLICY)) {
-            System.out.println("+ Disabling strict checksum verification on all artifact
downloads.");
+        container = new GShellPlexusContainer(config);
 
-            artifactRepositoryFactory.setGlobalChecksumPolicy(ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN);
-        }
-        */
+        File repositoryDir = new File(new File(System.getProperty("user.home")), ".gshell/repository");
+        ArtifactRepository repository = createLocalRepository(repositoryDir);
 
-        return localRepository;
+        System.out.println("Repository: " + repository);
     }
 
-    //
-    // Loading
-    //
-
-    public GShell load() throws Exception {
-        InteractiveShell shell = (InteractiveShell) container.lookup(InteractiveShell.class);
-
-        return null;
+    public static void main(final String[] args) throws Exception {
+        GShellLoader loader = new GShellLoader();
+        loader.test();
     }
 }

Added: geronimo/gshell/trunk/gshell-support/gshell-plexus/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-plexus/pom.xml?rev=641946&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-plexus/pom.xml (added)
+++ geronimo/gshell/trunk/gshell-support/gshell-plexus/pom.xml Thu Mar 27 12:02:58 2008
@@ -0,0 +1,52 @@
+<?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-plexus</artifactId>
+    <name>GShell Support :: Plexus</name>
+    
+    <description>
+        Customizations of Plexus for GShell.
+    </description>
+    
+    <dependencies>
+        <dependency>
+            <groupId>org.codehaus.plexus</groupId>
+            <artifactId>plexus-container-default</artifactId>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.codehaus.plexus</groupId>
+            <artifactId>plexus-utils</artifactId>
+        </dependency>
+    </dependencies>
+
+</project>
\ No newline at end of file

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

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

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

Added: geronimo/gshell/trunk/gshell-support/gshell-plexus/src/main/java/org/apache/geronimo/gshell/support/plexus/GShellPlexusContainer.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-plexus/src/main/java/org/apache/geronimo/gshell/support/plexus/GShellPlexusContainer.java?rev=641946&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-plexus/src/main/java/org/apache/geronimo/gshell/support/plexus/GShellPlexusContainer.java
(added)
+++ geronimo/gshell/trunk/gshell-support/gshell-plexus/src/main/java/org/apache/geronimo/gshell/support/plexus/GShellPlexusContainer.java
Thu Mar 27 12:02:58 2008
@@ -0,0 +1,61 @@
+/*
+ * 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.support.plexus;
+
+import org.codehaus.plexus.DefaultPlexusContainer;
+import org.codehaus.plexus.PlexusContainerException;
+import org.codehaus.plexus.ContainerConfiguration;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+
+/**
+ * And extention of the default Plexus container.
+ *
+ * @version $Rev$ $Date$
+ */
+public class GShellPlexusContainer
+    extends DefaultPlexusContainer
+{
+    public GShellPlexusContainer() throws PlexusContainerException {
+        super();
+    }
+
+    public GShellPlexusContainer(final ContainerConfiguration configuration) throws PlexusContainerException
{
+        super(configuration);
+    }
+    
+    @SuppressWarnings("unchecked")
+    public <T> T lookupComponent(final Class<T> role) throws ComponentLookupException
{
+        assert role != null;
+
+        return (T) super.lookup(role);
+    }
+
+    @SuppressWarnings("unchecked")
+    public <T> T lookupComponent(final Class<T> role, final String roleHint)
throws ComponentLookupException {
+        assert role != null;
+        assert roleHint != null;
+
+        return (T) super.lookup(role, roleHint);
+    }
+
+    //
+    // TODO: lookupComponentList, lookupComponentMap, createChildContainer
+    //
+}

Propchange: geronimo/gshell/trunk/gshell-support/gshell-plexus/src/main/java/org/apache/geronimo/gshell/support/plexus/GShellPlexusContainer.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

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

Modified: geronimo/gshell/trunk/gshell-support/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/pom.xml?rev=641946&r1=641945&r2=641946&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/pom.xml (original)
+++ geronimo/gshell/trunk/gshell-support/pom.xml Thu Mar 27 12:02:58 2008
@@ -45,6 +45,7 @@
         <module>gshell-common</module>
         <module>gshell-i18n</module>
         <module>gshell-prefs</module>
+        <module>gshell-plexus</module>
     </modules>
 
 </project>

Modified: geronimo/gshell/trunk/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/pom.xml?rev=641946&r1=641945&r2=641946&view=diff
==============================================================================
--- geronimo/gshell/trunk/pom.xml (original)
+++ geronimo/gshell/trunk/pom.xml Thu Mar 27 12:02:58 2008
@@ -80,6 +80,12 @@
             </dependency>
 
             <dependency>
+                <groupId>org.apache.geronimo.gshell.support</groupId>
+                <artifactId>gshell-plexus</artifactId>
+                <version>1.0-alpha-2-SNAPSHOT</version>
+            </dependency>
+
+            <dependency>
                 <groupId>org.apache.geronimo.gshell</groupId>
                 <artifactId>gshell-command-api</artifactId>
                 <version>1.0-alpha-2-SNAPSHOT</version>



Mime
View raw message