Author: gnodet
Date: Sun Oct 21 13:39:30 2007
New Revision: 586952

URL: http://svn.apache.org/viewvc?rev=586952&view=rev
Log:
SM-1085: Additional geronimo deployment plan support

Added:
    
incubator/servicemix/trunk/platforms/geronimo/deployer-service/src/main/java/org/apache/servicemix/geronimo/DeploymentPlanWrapper.java
    incubator/servicemix/trunk/platforms/geronimo/deployer-service/src/main/xsd/
    
incubator/servicemix/trunk/platforms/geronimo/deployer-service/src/main/xsd/geronimo-jbi-1.0.xsd
    
incubator/servicemix/trunk/platforms/geronimo/deployer-service/src/main/xsdconfig/
    
incubator/servicemix/trunk/platforms/geronimo/deployer-service/src/main/xsdconfig/xmlconfig.xml
    incubator/servicemix/trunk/platforms/geronimo/deployer-service/src/test/
    
incubator/servicemix/trunk/platforms/geronimo/deployer-service/src/test/java/
    
incubator/servicemix/trunk/platforms/geronimo/deployer-service/src/test/java/org/
    
incubator/servicemix/trunk/platforms/geronimo/deployer-service/src/test/java/org/apache/
    
incubator/servicemix/trunk/platforms/geronimo/deployer-service/src/test/java/org/apache/servicemix/
    
incubator/servicemix/trunk/platforms/geronimo/deployer-service/src/test/java/org/apache/servicemix/geronimo/
    
incubator/servicemix/trunk/platforms/geronimo/deployer-service/src/test/java/org/apache/servicemix/geronimo/DeploymentPlanWrapperTest.java
    
incubator/servicemix/trunk/platforms/geronimo/deployer-service/src/test/resources/
    
incubator/servicemix/trunk/platforms/geronimo/deployer-service/src/test/resources/geronimo-jbi.xml
Modified:
    incubator/servicemix/trunk/platforms/geronimo/deployer-service/pom.xml
    
incubator/servicemix/trunk/platforms/geronimo/deployer-service/src/main/java/org/apache/servicemix/geronimo/ServiceMixConfigBuilder.java

Modified: incubator/servicemix/trunk/platforms/geronimo/deployer-service/pom.xml
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/platforms/geronimo/deployer-service/pom.xml?rev=586952&r1=586951&r2=586952&view=diff
==============================================================================
--- incubator/servicemix/trunk/platforms/geronimo/deployer-service/pom.xml 
(original)
+++ incubator/servicemix/trunk/platforms/geronimo/deployer-service/pom.xml Sun 
Oct 21 13:39:30 2007
@@ -67,4 +67,58 @@
 
     </dependencies>
 
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>xmlbeans-maven-plugin</artifactId>
+
+                    <executions>
+                        <execution>
+                            <goals>
+                                <goal>xmlbeans</goal>
+                            </goals>
+                        </execution>
+                    </executions>
+
+                    <configuration>
+                        <download>true</download>
+                        <quiet>false</quiet>
+                    </configuration>
+
+
+            </plugin>
+            
+            <!--
+            HACK: Copy XmlBeans generated schemas.
+            -->
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>groovy-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <phase>generate-resources</phase>
+                        <goals>
+                            <goal>execute</goal>
+                        </goals>
+                        <configuration>
+                            <classpath>
+                                <element>
+                                    
<groupId>org.apache.geronimo.buildsupport</groupId>
+                                    
<artifactId>groovy-build-library</artifactId>
+                                    <version>${geronimoVersion}</version>
+                                </element>
+                            </classpath>
+                            <source>
+                                <body>
+                                    
org.apache.geronimo.buildsupport.CopyXmlBeansSchemas.execute(this)
+                                </body>
+                            </source>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
 </project>

Added: 
incubator/servicemix/trunk/platforms/geronimo/deployer-service/src/main/java/org/apache/servicemix/geronimo/DeploymentPlanWrapper.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/platforms/geronimo/deployer-service/src/main/java/org/apache/servicemix/geronimo/DeploymentPlanWrapper.java?rev=586952&view=auto
==============================================================================
--- 
incubator/servicemix/trunk/platforms/geronimo/deployer-service/src/main/java/org/apache/servicemix/geronimo/DeploymentPlanWrapper.java
 (added)
+++ 
incubator/servicemix/trunk/platforms/geronimo/deployer-service/src/main/java/org/apache/servicemix/geronimo/DeploymentPlanWrapper.java
 Sun Oct 21 13:39:30 2007
@@ -0,0 +1,49 @@
+/*
+ * 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.servicemix.geronimo;
+
+import org.apache.servicemix.geronimo.deployment.SMJbiDocument;
+import org.apache.servicemix.jbi.deployment.Descriptor;
+
+public class DeploymentPlanWrapper {
+
+       private Descriptor servicemixDescriptor;
+       
+       private SMJbiDocument geronimoPlan;
+
+       public DeploymentPlanWrapper(Descriptor descriptor, SMJbiDocument 
geronimoPlan) {
+               this.geronimoPlan = geronimoPlan;
+               this.servicemixDescriptor = descriptor;
+       }
+       
+       public Descriptor getServicemixDescriptor() {
+               return servicemixDescriptor;
+       }
+
+       public void setServicemixDescriptor(Descriptor servicemixDescriptor) {
+               this.servicemixDescriptor = servicemixDescriptor;
+       }
+
+       public SMJbiDocument getGeronimoPlan() {
+               return geronimoPlan;
+       }
+
+       public void setGeronimoPlan(SMJbiDocument geronimoPlan) {
+               this.geronimoPlan = geronimoPlan;
+       }
+       
+}

Modified: 
incubator/servicemix/trunk/platforms/geronimo/deployer-service/src/main/java/org/apache/servicemix/geronimo/ServiceMixConfigBuilder.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/platforms/geronimo/deployer-service/src/main/java/org/apache/servicemix/geronimo/ServiceMixConfigBuilder.java?rev=586952&r1=586951&r2=586952&view=diff
==============================================================================
--- 
incubator/servicemix/trunk/platforms/geronimo/deployer-service/src/main/java/org/apache/servicemix/geronimo/ServiceMixConfigBuilder.java
 (original)
+++ 
incubator/servicemix/trunk/platforms/geronimo/deployer-service/src/main/java/org/apache/servicemix/geronimo/ServiceMixConfigBuilder.java
 Sun Oct 21 13:39:30 2007
@@ -25,7 +25,6 @@
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
-import java.util.Set;
 import java.util.jar.JarFile;
 import java.util.zip.ZipEntry;
 
@@ -41,6 +40,7 @@
 import org.apache.geronimo.deployment.ModuleIDBuilder;
 import org.apache.geronimo.deployment.service.EnvironmentBuilder;
 import org.apache.geronimo.deployment.util.DeploymentUtil;
+import org.apache.geronimo.deployment.xbeans.EnvironmentType;
 import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.apache.geronimo.gbean.GBeanData;
@@ -58,10 +58,12 @@
 import org.apache.geronimo.kernel.repository.Environment;
 import org.apache.geronimo.kernel.repository.ImportType;
 import org.apache.geronimo.kernel.repository.Repository;
+import org.apache.servicemix.geronimo.deployment.SMJbiDocument;
 import org.apache.servicemix.jbi.deployment.Descriptor;
 import org.apache.servicemix.jbi.deployment.DescriptorFactory;
 import org.apache.servicemix.jbi.deployment.ServiceUnit;
 import org.apache.servicemix.jbi.deployment.SharedLibraryList;
+import org.apache.xmlbeans.XmlObject;
 
 public class ServiceMixConfigBuilder implements ConfigurationBuilder {
 
@@ -127,7 +129,33 @@
                 return null;
             }
             DescriptorFactory.checkDescriptor(descriptor);
-            return descriptor;
+            
+            XmlObject object = null;
+                       SMJbiDocument geronimoPlan = null;
+                       
+                       try {
+                               if (planFile != null) {
+                                       object = 
XmlObject.Factory.parse(planFile);
+                               }
+                       } catch (Exception e) {
+                               log.info("error " + e);
+                       }
+                       
+                       if (object != null) {
+                               try {
+                                       
+                                       if (object instanceof SMJbiDocument) {
+                                               geronimoPlan = (SMJbiDocument) 
object;  
+                                       } else {
+                                               geronimoPlan = (SMJbiDocument) 
object.changeType(SMJbiDocument.type);
+                                       }
+                                       
+                               } catch (Exception e) {
+                                       throw new DeploymentException("Geronimo 
Plan found but wrong format!" + e.getMessage());
+                               }
+                       }
+                                               
+            return new DeploymentPlanWrapper(descriptor, geronimoPlan);
         } catch (Exception e) {
             log.debug("Not a ServiceMix deployment: no jbi.xml found.", e);
             // no jbi.xml, not for us
@@ -150,7 +178,8 @@
      */
     public Artifact getConfigurationID(Object plan, JarFile module, 
ModuleIDBuilder idBuilder) throws IOException,
                     DeploymentException {
-        Descriptor descriptor = (Descriptor) plan;
+        DeploymentPlanWrapper wrapper = (DeploymentPlanWrapper) plan;
+        Descriptor descriptor = wrapper.getServicemixDescriptor();
         if (descriptor.getComponent() != null) {
             return new Artifact("servicemix-components", 
descriptor.getComponent().getIdentification().getName(),
                             "0.0", "car");
@@ -189,10 +218,14 @@
             log.warn("Expected a Descriptor but received null");
             return null;
         }
-        if (plan instanceof Descriptor == false) {
+        if (plan instanceof DeploymentPlanWrapper == false) {
             log.warn("Expected a Descriptor but received a " + 
plan.getClass().getName());
             return null;
         }
+        if (((DeploymentPlanWrapper)plan).getServicemixDescriptor() == null) {
+            log.warn("Expected a SM Descriptor but received null");
+            return null;
+        }
         File configurationDir;
         try {
             configurationDir = 
targetConfigurationStore.createNewConfigurationDir(configId);
@@ -204,9 +237,24 @@
         environment.setConfigId(configId);
         EnvironmentBuilder.mergeEnvironments(environment, defaultEnvironment);
 
+        DeploymentPlanWrapper wrapper = (DeploymentPlanWrapper) plan;
+        if (wrapper.getGeronimoPlan() != null) {
+                       
+               if (wrapper.getGeronimoPlan().getJbi() != null) {
+                       EnvironmentType environmentType = 
wrapper.getGeronimoPlan().getJbi().getEnvironment();
+                       if (environmentType != null) {
+                               log.debug("Environment found in Geronimo Plan 
for Servicemix " + environmentType);
+                               Environment geronimoPlanEnvironment = 
EnvironmentBuilder.buildEnvironment(environmentType);
+                               
EnvironmentBuilder.mergeEnvironments(environment, geronimoPlanEnvironment);
+                       } else {
+                               log.debug("no additional environment entry 
found in deployment plan for JBI component");
+                       }
+               }
+        }
+
         DeploymentContext context = null;
         try {
-            Descriptor descriptor = (Descriptor) plan;
+            Descriptor descriptor = wrapper.getServicemixDescriptor();
             Map name = new HashMap();
             name.put("Config", configId.toString());
             context = new DeploymentContext(configurationDir,

Added: 
incubator/servicemix/trunk/platforms/geronimo/deployer-service/src/main/xsd/geronimo-jbi-1.0.xsd
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/platforms/geronimo/deployer-service/src/main/xsd/geronimo-jbi-1.0.xsd?rev=586952&view=auto
==============================================================================
--- 
incubator/servicemix/trunk/platforms/geronimo/deployer-service/src/main/xsd/geronimo-jbi-1.0.xsd
 (added)
+++ 
incubator/servicemix/trunk/platforms/geronimo/deployer-service/src/main/xsd/geronimo-jbi-1.0.xsd
 Sun Oct 21 13:39:30 2007
@@ -0,0 +1,36 @@
+<?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.
+-->
+
+<xs:schema 
+    targetNamespace="http://servicemix.apache.org/xml/ns/jbi-1.0";
+    xmlns:sjbi="http://servicemix.apache.org/xml/ns/jbi-1.0";
+    xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.2";
+    xmlns:xs="http://www.w3.org/2001/XMLSchema"; 
+    elementFormDefault="qualified"
+    attributeFormDefault="unqualified" version="1.0" >
+
+    <xs:complexType name="jbi-type">
+        <xs:sequence>
+            <xs:element ref="sys:environment" minOccurs="0"/>
+        </xs:sequence>
+    </xs:complexType>
+    
+    <xs:element name="jbi" type="sjbi:jbi-type">
+    </xs:element>
+    
+</xs:schema>

Added: 
incubator/servicemix/trunk/platforms/geronimo/deployer-service/src/main/xsdconfig/xmlconfig.xml
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/platforms/geronimo/deployer-service/src/main/xsdconfig/xmlconfig.xml?rev=586952&view=auto
==============================================================================
--- 
incubator/servicemix/trunk/platforms/geronimo/deployer-service/src/main/xsdconfig/xmlconfig.xml
 (added)
+++ 
incubator/servicemix/trunk/platforms/geronimo/deployer-service/src/main/xsdconfig/xmlconfig.xml
 Sun Oct 21 13:39:30 2007
@@ -0,0 +1,24 @@
+<!--
+   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.
+-->
+<xb:config xmlns:xb="http://www.bea.com/2002/09/xbean/config";>
+
+    <xb:namespace uri="http://servicemix.apache.org/xml/ns/jbi-1.0";>
+        <xb:package>org.apache.servicemix.geronimo.deployment</xb:package>
+        <xb:prefix>SM</xb:prefix>
+    </xb:namespace>
+
+</xb:config>

Added: 
incubator/servicemix/trunk/platforms/geronimo/deployer-service/src/test/java/org/apache/servicemix/geronimo/DeploymentPlanWrapperTest.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/platforms/geronimo/deployer-service/src/test/java/org/apache/servicemix/geronimo/DeploymentPlanWrapperTest.java?rev=586952&view=auto
==============================================================================
--- 
incubator/servicemix/trunk/platforms/geronimo/deployer-service/src/test/java/org/apache/servicemix/geronimo/DeploymentPlanWrapperTest.java
 (added)
+++ 
incubator/servicemix/trunk/platforms/geronimo/deployer-service/src/test/java/org/apache/servicemix/geronimo/DeploymentPlanWrapperTest.java
 Sun Oct 21 13:39:30 2007
@@ -0,0 +1,33 @@
+/*
+ * 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.servicemix.geronimo;
+
+import java.io.File;
+
+import org.apache.servicemix.geronimo.deployment.SMJbiDocument;
+
+import junit.framework.TestCase;
+
+public class DeploymentPlanWrapperTest extends TestCase {
+
+       public void testSimpleParsing() throws Exception {
+               
+               SMJbiDocument jbiDocument = SMJbiDocument.Factory.parse(new 
File("src/test/resources/geronimo-jbi.xml"));
+                               
+       }
+       
+}

Added: 
incubator/servicemix/trunk/platforms/geronimo/deployer-service/src/test/resources/geronimo-jbi.xml
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/platforms/geronimo/deployer-service/src/test/resources/geronimo-jbi.xml?rev=586952&view=auto
==============================================================================
--- 
incubator/servicemix/trunk/platforms/geronimo/deployer-service/src/test/resources/geronimo-jbi.xml
 (added)
+++ 
incubator/servicemix/trunk/platforms/geronimo/deployer-service/src/test/resources/geronimo-jbi.xml
 Sun Oct 21 13:39:30 2007
@@ -0,0 +1,4 @@
+<?xml version="1.0"?>
+
+<sjbi:jbi xmlns:sjbi="http://servicemix.apache.org/xml/ns/jbi-1.0";>
+</sjbi:jbi>


Reply via email to