geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r377136 [3/3] - in /geronimo/branches/configid: modules/client-builder/src/java/org/apache/geronimo/client/builder/ modules/client-builder/src/schema/ modules/client-builder/src/test-resources/plans/ modules/client-builder/src/test/org/apac...
Date Sun, 12 Feb 2006 05:51:43 GMT
Modified: geronimo/branches/configid/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/RepoConfigInstaller.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/RepoConfigInstaller.java?rev=377136&r1=377135&r2=377136&view=diff
==============================================================================
--- geronimo/branches/configid/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/RepoConfigInstaller.java
(original)
+++ geronimo/branches/configid/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/RepoConfigInstaller.java
Sat Feb 11 21:51:39 2006
@@ -22,10 +22,12 @@
 import java.io.ObjectInputStream;
 import java.net.URI;
 import java.net.URL;
+import java.net.URISyntaxException;
 
 import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.kernel.config.InvalidConfigException;
 import org.apache.geronimo.kernel.repository.Repository;
+import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.system.repository.FileSystemRepository;
 
 /**
@@ -59,17 +61,23 @@
             this.targetRepo = targetRepo;
         }
 
-        public GBeanData install(Repository sourceRepo, URI configId) throws IOException,
InvalidConfigException {
-            URL sourceURL = sourceRepo.getURL(configId);
+        public GBeanData install(Repository sourceRepo, Artifact configId) throws IOException,
InvalidConfigException {
+            URI sourceURI;
+            try {
+                sourceURI = configId.toURI();
+            } catch (URISyntaxException e) {
+                throw new InvalidConfigException(e);
+            }
+            URL sourceURL = sourceRepo.getURL(sourceURI);
             InputStream in = sourceURL.openStream();
             try {
-                if (!targetRepo.hasURI(configId)) {
-                    targetRepo.copyToRepository(in, configId, new StartFileWriteMonitor());
+                if (!targetRepo.hasURI(sourceURI)) {
+                    targetRepo.copyToRepository(in, sourceURI, new StartFileWriteMonitor());
                 }
             } finally {
                 in.close();
             }
-            URL targetURL = targetRepo.getURL(configId);
+            URL targetURL = targetRepo.getURL(sourceURI);
             GBeanData config = new GBeanData();
             URL baseURL = new URL("jar:" + targetURL.toString() + "!/");
             InputStream jis = null;
@@ -88,8 +96,12 @@
             return config;
         }
 
-        public boolean containsConfiguration(URI configID) {
-            return targetRepo.hasURI(configID);
+        public boolean containsConfiguration(Artifact configID) {
+            try {
+                return targetRepo.hasURI(configID.toURI());
+            } catch (URISyntaxException e) {
+                throw (IllegalArgumentException)new IllegalArgumentException("bad artifact").initCause(e);
+            }
         }
     }
 

Modified: geronimo/branches/configid/plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/StartServer.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/StartServer.java?rev=377136&r1=377135&r2=377136&view=diff
==============================================================================
--- geronimo/branches/configid/plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/StartServer.java
(original)
+++ geronimo/branches/configid/plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/StartServer.java
Sat Feb 11 21:51:39 2006
@@ -30,6 +30,7 @@
 import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.KernelFactory;
+import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.kernel.config.Configuration;
 import org.apache.geronimo.kernel.config.ConfigurationManager;
 import org.apache.geronimo.kernel.config.ConfigurationUtil;
@@ -120,10 +121,10 @@
         ConfigurationManager configurationManager = ConfigurationUtil.getConfigurationManager(kernel);
         try {
             for (Iterator i = configList.iterator(); i.hasNext();) {
-                URI configID = (URI) i.next();
+                Artifact configID = (Artifact) i.next();
                 List list = configurationManager.loadRecursive(configID);
                 for (Iterator iterator = list.iterator(); iterator.hasNext();) {
-                    URI name = (URI) iterator.next();
+                    Artifact name = (Artifact) iterator.next();
                     configurationManager.loadGBeans(name);
                     configurationManager.start(name);
                     System.out.println("started gbean: " + name);

Modified: geronimo/branches/configid/plugins/geronimo-packaging-plugin/plugin.jelly
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/plugins/geronimo-packaging-plugin/plugin.jelly?rev=377136&r1=377135&r2=377136&view=diff
==============================================================================
--- geronimo/branches/configid/plugins/geronimo-packaging-plugin/plugin.jelly (original)
+++ geronimo/branches/configid/plugins/geronimo-packaging-plugin/plugin.jelly Sat Feb 11 21:51:39
2006
@@ -42,6 +42,9 @@
 
     <goal name="car:prepare-plan" description="Add dependencies to a plan and process
with velocity">
         <car:dependencies
+                groupId="${pom.groupId}"
+                artifactId="${pom.artifactId}"
+                version="${pom.currentVersion}"
             artifacts="${pom.artifacts}"
             targetDir="${geronimo.packaging.buildDir}"
             sourceDir="${geronimo.packaging.srcDir}"

Modified: geronimo/branches/configid/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/MavenConfigStore.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/MavenConfigStore.java?rev=377136&r1=377135&r2=377136&view=diff
==============================================================================
--- geronimo/branches/configid/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/MavenConfigStore.java
(original)
+++ geronimo/branches/configid/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/MavenConfigStore.java
Sat Feb 11 21:51:39 2006
@@ -138,8 +138,13 @@
         if (!source.isDirectory()) {
             throw new InvalidConfigException("Source must be a directory: source=" + source);
         }
-        URI configId = configurationData.getId();
-        URL targetURL = repository.getURL(configId);
+        Artifact configId = configurationData.getId();
+        URL targetURL = null;
+        try {
+            targetURL = repository.getURL(configId.toURI());
+        } catch (URISyntaxException e) {
+            throw new InvalidConfigException(e);
+        }
         File targetFile;
         if (targetURL.getProtocol().equalsIgnoreCase("file")) {
             try {

Modified: geronimo/branches/configid/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilder.java?rev=377136&r1=377135&r2=377136&view=diff
==============================================================================
--- geronimo/branches/configid/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilder.java
(original)
+++ geronimo/branches/configid/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilder.java
Sat Feb 11 21:51:39 2006
@@ -16,32 +16,32 @@
  */
 package org.apache.geronimo.plugin.packaging;
 
-import java.io.File;
-import java.net.URI;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.geronimo.gbean.GBeanData;
-import org.apache.geronimo.gbean.GReferenceInfo;
 import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GReferenceInfo;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.KernelFactory;
 import org.apache.geronimo.kernel.KernelRegistry;
 import org.apache.geronimo.kernel.config.ConfigurationManager;
 import org.apache.geronimo.kernel.config.ConfigurationManagerImpl;
 import org.apache.geronimo.kernel.config.ConfigurationUtil;
+import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.log4j.BasicConfigurator;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+import java.io.File;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
 
 /**
  * JellyBean that builds a Geronimo Configuration using the local Mavem
  * infrastructure.
  *
- * @version $Rev: 355876 $ $Date$
+ * @version $Rev$ $Date$
  */
 public class PackageBuilder {
 
@@ -101,7 +101,7 @@
 
     private File repository;
     private String deploymentConfigString;
-    private URI[] deploymentConfig;
+    private Artifact[] deploymentConfig;
     private ObjectName deployerName;
 
     private File planFile;
@@ -154,10 +154,10 @@
     public void setDeploymentConfig(String deploymentConfigString) {
         this.deploymentConfigString = deploymentConfigString;
         String[] configNames = deploymentConfigString.split(",");
-        deploymentConfig = new URI[configNames.length];
+        deploymentConfig = new Artifact[configNames.length];
         for (int i = 0; i < configNames.length; i++) {
             String configName = configNames[i];
-            deploymentConfig[i] = URI.create(configName);
+            deploymentConfig[i] = Artifact.create(configName);
         }
     }
 
@@ -262,11 +262,11 @@
             ConfigurationManager configurationManager = ConfigurationUtil.getConfigurationManager(kernel);
             try {
                 for (int i = 0; i < deploymentConfig.length; i++) {
-                    URI configName = deploymentConfig[i];
+                    Artifact configName = deploymentConfig[i];
                     if (!configurationManager.isLoaded(configName)) {
                         List configs = configurationManager.loadRecursive(configName);
                         for (Iterator iterator = configs.iterator(); iterator.hasNext();
) {
-                            URI ancestorConfigName = (URI) iterator.next();
+                            Artifact ancestorConfigName = (Artifact) iterator.next();
                             try {
                                 configurationManager.loadGBeans(ancestorConfigName);
                             } catch (Throwable e) {

Modified: geronimo/branches/configid/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PlanProcessor.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PlanProcessor.java?rev=377136&r1=377135&r2=377136&view=diff
==============================================================================
--- geronimo/branches/configid/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PlanProcessor.java
(original)
+++ geronimo/branches/configid/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PlanProcessor.java
Sat Feb 11 21:51:39 2006
@@ -35,6 +35,9 @@
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.XmlOptions;
+import org.apache.geronimo.deployment.xbeans.EnvironmentType;
+import org.apache.geronimo.deployment.xbeans.ArtifactType;
+import org.apache.geronimo.deployment.xbeans.ClassloaderType;
 
 /**
  * @version $Rev$ $Date$
@@ -43,11 +46,9 @@
     private static Log log = LogFactory.getLog(PlanProcessor.class);
 
     private static final String IMPORT_PROPERTY = "geronimo.import";
-    private static final QName IMPORT_QNAME = new QName("http://geronimo.apache.org/xml/ns/deployment-1.0",
"import");
     private static final String INCLUDE_PROPERTY = "geronimo.include";
-    private static final QName INCLUDE_QNAME = new QName("http://geronimo.apache.org/xml/ns/deployment-1.0",
"include");
     private static final String DEPENDENCY_PROPERTY = "geronimo.dependency";
-    private static final QName DEPENDENCY_QNAME = new QName("http://geronimo.apache.org/xml/ns/deployment-1.0",
"dependency");
+    private static final QName ENVIRONMENT_QNAME = new QName("http://geronimo.apache.org/xml/ns/deployment-1.1",
"environment");
 
     private List artifacts;
     private String sourceDir;
@@ -55,6 +56,9 @@
     private String planFile;
     private String targetFile;
     private Context context;
+    private String groupId;
+    private String artifactId;
+    private String version;
 
     public List getArtifacts() {
         return artifacts;
@@ -100,6 +104,30 @@
         this.context = new JellyContextAdapter(context);
     }
 
+    public String getGroupId() {
+        return groupId;
+    }
+
+    public void setGroupId(String groupId) {
+        this.groupId = groupId;
+    }
+
+    public String getArtifactId() {
+        return artifactId;
+    }
+
+    public void setArtifactId(String artifactId) {
+        this.artifactId = artifactId;
+    }
+
+    public String getVersion() {
+        return version;
+    }
+
+    public void setVersion(String version) {
+        this.version = version;
+    }
+
     public void execute() throws Exception, XmlException {
         try {
             if (artifacts == null) {
@@ -131,11 +159,60 @@
 
                 xmlCursor.toFirstContentToken();
                 xmlCursor.toFirstChild();
+                QName childName = xmlCursor.getName();
+                EnvironmentType environmentType;
+                if (childName.equals(ENVIRONMENT_QNAME)) {
+                    environmentType = (EnvironmentType) xmlCursor.getObject();
+                } else {
+                    environmentType = EnvironmentType.Factory.newInstance();
+                    xmlCursor.beginElement(ENVIRONMENT_QNAME);
+                    XmlCursor element = environmentType.newCursor();
+                    try {
+                        element.copyXmlContents(xmlCursor);
+                    } finally {
+                        element.dispose();
+                    }
+                }
+
+                ArtifactType configId = environmentType.getConfigId();
+                if (configId == null) {
+                    configId = environmentType.addNewConfigId();
+                    configId.setGroupId(groupId);
+                    configId.setArtifactId(artifactId);
+                    configId.setVersion(version);
+                    configId.setType("car");
+                }
+
+                insertPlanElements(environmentType, IMPORT_PROPERTY, new Inserter() {
 
+                    public ArtifactType insert(EnvironmentType environmentType) {
+                        ClassloaderType classloaderType = environmentType.getClassloader();
+                        if (classloaderType == null) {
+                            classloaderType = environmentType.addNewClassloader();
+                        }
+                        return classloaderType.addNewImport();
+                    }
+                });
+                insertPlanElements(environmentType, INCLUDE_PROPERTY, new Inserter() {
+
+                    public ArtifactType insert(EnvironmentType environmentType) {
+                        ClassloaderType classloaderType = environmentType.getClassloader();
+                        if (classloaderType == null) {
+                            classloaderType = environmentType.addNewClassloader();
+                        }
+                        return classloaderType.addNewInclude();
+                    }
+                });
+                insertPlanElements(environmentType, DEPENDENCY_PROPERTY, new Inserter() {
 
-                insertPlanElements(xmlCursor, IMPORT_PROPERTY, IMPORT_QNAME);
-                insertPlanElements(xmlCursor, INCLUDE_PROPERTY, INCLUDE_QNAME);
-                insertPlanElements(xmlCursor, DEPENDENCY_PROPERTY, DEPENDENCY_QNAME);
+                    public ArtifactType insert(EnvironmentType environmentType) {
+                        ClassloaderType classloaderType = environmentType.getClassloader();
+                        if (classloaderType == null) {
+                            classloaderType = environmentType.addNewClassloader();
+                        }
+                        return classloaderType.addNewDependency();
+                    }
+                });
 
                 File targetDir = new File(this.targetDir);
                 if (targetDir.exists()) {
@@ -158,37 +235,30 @@
         }
     }
 
-    private void insertPlanElements(XmlCursor xmlCursor, String artifactProperty, QName elementQName)
{
-        if (xmlCursor.toNextSibling(elementQName)) {
-            while(xmlCursor.toNextSibling(elementQName));
-            xmlCursor.toEndToken();
-            xmlCursor.toNextToken();
-        }
+    private void insertPlanElements(EnvironmentType environmentType, String artifactProperty,
Inserter inserter) {
         for (Iterator iterator = artifacts.iterator(); iterator.hasNext();) {
             Artifact artifact = (Artifact) iterator.next();
-            Dependency dependency = (Dependency) artifact.getDependency();
+            Dependency dependency = artifact.getDependency();
             if ("true".equals(dependency.getProperty(artifactProperty))) {
                 String groupId = dependency.getGroupId();
                 String artifactId = dependency.getArtifactId();
                 String version = dependency.getVersion();
                 String type = dependency.getType();
-                org.apache.geronimo.deployment.xbeans.DependencyType dependencyType = org.apache.geronimo.deployment.xbeans.DependencyType.Factory.newInstance();
-                dependencyType.setGroupId(groupId);
-                dependencyType.setArtifactId(artifactId);
-                dependencyType.setVersion(version);
+                ArtifactType artifactType = inserter.insert(environmentType);
+                artifactType.setGroupId(groupId);
+                artifactType.setArtifactId(artifactId);
+                artifactType.setVersion(version);
                 if (type != null && !"jar".equals(type)) {
-                    dependencyType.setType(type);
+                    artifactType.setType(type);
                 }
 
-                xmlCursor.beginElement(elementQName);
-                XmlCursor element = dependencyType.newCursor();
-                try {
-                    element.copyXmlContents(xmlCursor);
-                } finally {
-                    element.dispose();
-                }
-                xmlCursor.toNextToken();
             }
         }
     }
+
+    interface Inserter {
+        ArtifactType insert(EnvironmentType environmentType);
+    }
+
+
 }



Mime
View raw message