servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pdo...@apache.org
Subject svn commit: r429390 - in /incubator/servicemix/trunk: ./ apache-servicemix/ servicemix-common/ servicemix-common/src/main/java/org/apache/servicemix/common/packaging/ servicemix-common/src/main/java/org/apache/servicemix/common/xbean/ servicemix-eip/ s...
Date Mon, 07 Aug 2006 17:00:38 GMT
Author: pdodds
Date: Mon Aug  7 10:00:37 2006
New Revision: 429390

URL: http://svn.apache.org/viewvc?rev=429390&view=rev
Log:
Adding new shared library (SM-517) and framework classes for Service Unit analyzer generating
services element in jbi.xml

Added:
    incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/packaging/
    incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/packaging/Consumes.java
    incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/packaging/Provides.java
    incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/packaging/ServiceUnitAnalyzer.java
    incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/xbean/AbstractXBeanServiceUnitAnalzyer.java
    incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/packaging/
    incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/packaging/HttpServiceUnitAnalyzer.java
Modified:
    incubator/servicemix/trunk/apache-servicemix/pom.xml
    incubator/servicemix/trunk/pom.xml
    incubator/servicemix/trunk/servicemix-common/pom.xml
    incubator/servicemix/trunk/servicemix-eip/pom.xml
    incubator/servicemix/trunk/servicemix-http/pom.xml
    incubator/servicemix/trunk/servicemix-jsr181/pom.xml
    incubator/servicemix/trunk/servicemix-soap/pom.xml
    incubator/servicemix/trunk/tooling/jbi-maven-plugin/pom.xml
    incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateServiceUnitDescriptorMojo.java

Modified: incubator/servicemix/trunk/apache-servicemix/pom.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/apache-servicemix/pom.xml?rev=429390&r1=429389&r2=429390&view=diff
==============================================================================
--- incubator/servicemix/trunk/apache-servicemix/pom.xml (original)
+++ incubator/servicemix/trunk/apache-servicemix/pom.xml Mon Aug  7 10:00:37 2006
@@ -266,17 +266,10 @@
                   <version>3.0-incubating-SNAPSHOT</version>
                   <classifier>installer</classifier>
                   <type>zip</type>
-                </artifactItem>
+                </artifactItem>                
                 <artifactItem>
                   <groupId>${pom.groupId}</groupId>
-                  <artifactId>servicemix-common</artifactId>
-                  <version>3.0-incubating-SNAPSHOT</version>
-                  <classifier>installer</classifier>
-                  <type>zip</type>
-                </artifactItem>
-                <artifactItem>
-                  <groupId>${pom.groupId}</groupId>
-                  <artifactId>servicemix-soap</artifactId>
+                  <artifactId>servicemix-shared</artifactId>
                   <version>3.0-incubating-SNAPSHOT</version>
                   <classifier>installer</classifier>
                   <type>zip</type>

Modified: incubator/servicemix/trunk/pom.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/pom.xml?rev=429390&r1=429389&r2=429390&view=diff
==============================================================================
--- incubator/servicemix/trunk/pom.xml (original)
+++ incubator/servicemix/trunk/pom.xml Mon Aug  7 10:00:37 2006
@@ -224,6 +224,7 @@
                 <module>servicemix-components</module>
                 <module>servicemix-common</module>
                 <module>servicemix-soap</module>
+                <module>servicemix-shared</module>
                 <module>servicemix-console</module>
                 <module>servicemix-bpe</module>
                 <module>servicemix-jms</module>
@@ -441,8 +442,7 @@
             </dependency>
             <dependency>
                 <groupId>org.apache.servicemix</groupId>
-                <artifactId>servicemix-common</artifactId>
-                <type>jbi-shared-library</type>
+                <artifactId>servicemix-common</artifactId>                
                 <version>3.0-incubating-SNAPSHOT</version>
             </dependency>
             <dependency>
@@ -478,6 +478,11 @@
             <dependency>
                 <groupId>org.apache.servicemix</groupId>
                 <artifactId>servicemix-soap</artifactId>
+                <version>3.0-incubating-SNAPSHOT</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.servicemix</groupId>
+                <artifactId>servicemix-shared</artifactId>
                 <version>3.0-incubating-SNAPSHOT</version>
             </dependency>
             <dependency>

Modified: incubator/servicemix/trunk/servicemix-common/pom.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-common/pom.xml?rev=429390&r1=429389&r2=429390&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-common/pom.xml (original)
+++ incubator/servicemix/trunk/servicemix-common/pom.xml Mon Aug  7 10:00:37 2006
@@ -30,7 +30,7 @@
   </parent>
 
   <artifactId>servicemix-common</artifactId>
-  <packaging>jbi-shared-library</packaging>
+  <packaging>jar</packaging>
   <name>ServiceMix :: Common</name>
   <description>Common library for binding component and service engines</description>
   
@@ -77,13 +77,4 @@
     </dependency>
   </dependencies>
   
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.servicemix.tooling</groupId>
-        <artifactId>jbi-maven-plugin</artifactId>
-        <version>1.0-incubating-SNAPSHOT</version>
-      </plugin>
-    </plugins>
-  </build>
 </project>

Added: incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/packaging/Consumes.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/packaging/Consumes.java?rev=429390&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/packaging/Consumes.java
(added)
+++ incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/packaging/Consumes.java
Mon Aug  7 10:00:37 2006
@@ -0,0 +1,77 @@
+/*
+ * 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.common.packaging;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Provides a value object for gathering information on a consumes element from
+ * a ServiceUnitAnalyzer
+ * 
+ * @author Philip Dodds
+ * @version $Revision: 426415 $
+ * @since 3.0
+ * @see ServiceUnitAnalyzer
+ */
+public class Consumes {
+
+	public static final int LINKTYPE_STANDARD = 1;
+
+	public static final int LINKTYPE_HARD = 2;
+
+	public static final int LINKTYPE_SOFT = 3;
+
+	private QName interfaceName;
+
+	private QName serviceName;
+
+	private String endpointName;
+
+	private int linkType;
+
+	public String getEndpointName() {
+		return endpointName;
+	}
+
+	public void setEndpointName(String endpointName) {
+		this.endpointName = endpointName;
+	}
+
+	public QName getInterfaceName() {
+		return interfaceName;
+	}
+
+	public void setInterfaceName(QName interfaceName) {
+		this.interfaceName = interfaceName;
+	}
+
+	public int getLinkType() {
+		return linkType;
+	}
+
+	public void setLinkType(int linkType) {
+		this.linkType = linkType;
+	}
+
+	public QName getServiceName() {
+		return serviceName;
+	}
+
+	public void setServiceName(QName serviceName) {
+		this.serviceName = serviceName;
+	}
+}

Added: incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/packaging/Provides.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/packaging/Provides.java?rev=429390&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/packaging/Provides.java
(added)
+++ incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/packaging/Provides.java
Mon Aug  7 10:00:37 2006
@@ -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.servicemix.common.packaging;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Provides a value object for gathering information on a provides element from
+ * a ServiceUnitAnalyzer
+ * 
+ * @author Philip Dodds
+ * @version $Revision: 426415 $
+ * @since 3.0
+ * @see ServiceUnitAnalyzer
+ */
+public class Provides {	
+
+	private QName interfaceName;
+
+	private QName serviceName;
+
+	private String endpointName;	
+
+	public String getEndpointName() {
+		return endpointName;
+	}
+
+	public void setEndpointName(String endpointName) {
+		this.endpointName = endpointName;
+	}
+
+	public QName getInterfaceName() {
+		return interfaceName;
+	}
+
+	public void setInterfaceName(QName interfaceName) {
+		this.interfaceName = interfaceName;
+	}
+
+	public QName getServiceName() {
+		return serviceName;
+	}
+
+	public void setServiceName(QName serviceName) {
+		this.serviceName = serviceName;
+	}
+}

Added: incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/packaging/ServiceUnitAnalyzer.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/packaging/ServiceUnitAnalyzer.java?rev=429390&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/packaging/ServiceUnitAnalyzer.java
(added)
+++ incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/packaging/ServiceUnitAnalyzer.java
Mon Aug  7 10:00:37 2006
@@ -0,0 +1,60 @@
+/*
+ * 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.common.packaging;
+
+import java.io.File;
+import java.util.List;
+
+/**
+ * Provides a interface that components can implement, if they implement this
+ * interface and expose the name of the analyzer in their Maven Project Object
+ * Model then the tooling can use this to analyze a Service Unit for the
+ * component during packaging to generate the consumes and provides elements for
+ * the service unit's jbi.xml
+ * 
+ * @author Philip Dodds
+ * @version $Revision: 426415 $
+ * @since 3.0
+ * 
+ * @see Consumes, {@link Consumes}
+ * @see Provides, {@link Provides}
+ */
+public interface ServiceUnitAnalyzer {
+
+	/**
+	 * Initializes the analyzer based on the root directory of an exploded
+	 * service unit
+	 * 
+	 * @param explodedServiceUnitRoot
+	 */
+	public void init(File explodedServiceUnitRoot);
+
+	/**
+	 * Returns a list of Consumes representing the service unit being analyzed
+	 * 
+	 * @return A list of Consumes
+	 */
+	public List getConsumes();
+
+	/**
+	 * Returns a list of Provides representing the service unit being analyzed
+	 * 
+	 * @return A list of provides
+	 */
+	public List getProvides();
+
+}

Added: incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/xbean/AbstractXBeanServiceUnitAnalzyer.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/xbean/AbstractXBeanServiceUnitAnalzyer.java?rev=429390&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/xbean/AbstractXBeanServiceUnitAnalzyer.java
(added)
+++ incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/xbean/AbstractXBeanServiceUnitAnalzyer.java
Mon Aug  7 10:00:37 2006
@@ -0,0 +1,89 @@
+/*
+ * 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.common.xbean;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.servicemix.common.Endpoint;
+import org.apache.servicemix.common.packaging.Provides;
+import org.apache.servicemix.common.packaging.ServiceUnitAnalyzer;
+import org.springframework.beans.factory.xml.XmlBeanFactory;
+import org.springframework.core.io.FileSystemResource;
+
+public abstract class AbstractXBeanServiceUnitAnalzyer implements
+		ServiceUnitAnalyzer {
+
+	List consumes = new ArrayList();
+
+	List provides = new ArrayList();
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.servicemix.common.packaging.ServiceUnitAnalyzer#getConsumes()
+	 */
+	public List getConsumes() {
+		return consumes;
+	}
+
+	protected abstract List getConsumes(Endpoint endpoint);
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.servicemix.common.packaging.ServiceUnitAnalyzer#getProvides()
+	 */
+	public List getProvides() {
+		return provides;
+	}
+
+	protected Provides getProvides(Endpoint endpoint) {
+		Provides newProvide = new Provides();
+		newProvide.setEndpointName(endpoint.getEndpoint());
+		newProvide.setInterfaceName(endpoint.getInterfaceName());
+		newProvide.setServiceName(endpoint.getService());
+		return newProvide;
+	}
+
+	protected abstract String getXBeanFile();
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.servicemix.common.packaging.ServiceUnitAnalyzer#init(java.io.File)
+	 */
+	public void init(File explodedServiceUnitRoot) {
+		XmlBeanFactory factory = new XmlBeanFactory(new FileSystemResource(
+				new File(explodedServiceUnitRoot, getXBeanFile())));
+
+		for (int i = 0; i < factory.getBeanDefinitionNames().length; i++) {
+			Object bean = factory.getBean(factory.getBeanDefinitionNames()[i]);
+			if (isValidEndpoint(bean)) {
+				// The provides are generic while the consumes need to
+				// be handled by the implementation
+				Endpoint endpoint = (Endpoint) bean;
+				provides.add(getProvides(endpoint));
+				consumes.addAll(getConsumes(endpoint));
+			}
+		}
+	}
+
+	protected abstract boolean isValidEndpoint(Object bean);
+
+}

Modified: incubator/servicemix/trunk/servicemix-eip/pom.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-eip/pom.xml?rev=429390&r1=429389&r2=429390&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-eip/pom.xml (original)
+++ incubator/servicemix/trunk/servicemix-eip/pom.xml Mon Aug  7 10:00:37 2006
@@ -38,7 +38,7 @@
 
     <dependency>
       <groupId>${pom.groupId}</groupId>
-      <artifactId>servicemix-common</artifactId>
+      <artifactId>servicemix-shared</artifactId>
     </dependency>
     <dependency>
       <groupId>${pom.groupId}</groupId>

Modified: incubator/servicemix/trunk/servicemix-http/pom.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-http/pom.xml?rev=429390&r1=429389&r2=429390&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-http/pom.xml (original)
+++ incubator/servicemix/trunk/servicemix-http/pom.xml Mon Aug  7 10:00:37 2006
@@ -18,6 +18,7 @@
           <type>binding-component</type>
           <bootstrap>org.apache.servicemix.http.HttpBootstrap</bootstrap>
           <component>org.apache.servicemix.http.HttpComponent</component>
+          <serviceUnitAnalyzer>org.apache.servicemix.http.packaging.HttpServiceUnitAnalyzer</serviceUnitAnalyzer>
         </configuration>
       </plugin>
       <plugin>
@@ -54,7 +55,7 @@
   <dependencies>
     <dependency>
       <groupId>${pom.groupId}</groupId>
-      <artifactId>servicemix-soap</artifactId>
+      <artifactId>servicemix-shared</artifactId>
     </dependency>
     <dependency>
       <groupId>commons-httpclient</groupId>

Added: incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/packaging/HttpServiceUnitAnalyzer.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/packaging/HttpServiceUnitAnalyzer.java?rev=429390&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/packaging/HttpServiceUnitAnalyzer.java
(added)
+++ incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/packaging/HttpServiceUnitAnalyzer.java
Mon Aug  7 10:00:37 2006
@@ -0,0 +1,27 @@
+package org.apache.servicemix.http.packaging;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.servicemix.common.Endpoint;
+import org.apache.servicemix.common.xbean.AbstractXBeanServiceUnitAnalzyer;
+import org.apache.servicemix.http.HttpEndpoint;
+
+public class HttpServiceUnitAnalyzer extends AbstractXBeanServiceUnitAnalzyer {
+
+	protected List getConsumes(Endpoint endpoint) {
+		return new ArrayList();
+	}
+
+	protected String getXBeanFile() {
+		return "xbean.xml";
+	}
+
+	protected boolean isValidEndpoint(Object bean) {
+		if (bean instanceof HttpEndpoint)
+			return true;
+		else
+			return false;
+	}
+
+}

Modified: incubator/servicemix/trunk/servicemix-jsr181/pom.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-jsr181/pom.xml?rev=429390&r1=429389&r2=429390&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-jsr181/pom.xml (original)
+++ incubator/servicemix/trunk/servicemix-jsr181/pom.xml Mon Aug  7 10:00:37 2006
@@ -37,7 +37,7 @@
   <dependencies>
     <dependency>
       <groupId>${pom.groupId}</groupId>
-      <artifactId>servicemix-common</artifactId>
+      <artifactId>servicemix-shared</artifactId>
     </dependency>
     <dependency>
       <groupId>org.codehaus.xfire</groupId>

Modified: incubator/servicemix/trunk/servicemix-soap/pom.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-soap/pom.xml?rev=429390&r1=429389&r2=429390&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-soap/pom.xml (original)
+++ incubator/servicemix/trunk/servicemix-soap/pom.xml Mon Aug  7 10:00:37 2006
@@ -30,7 +30,7 @@
   </parent>
 
   <artifactId>servicemix-soap</artifactId>
-  <packaging>jbi-shared-library</packaging>
+  <packaging>jar</packaging>
   <name>ServiceMix :: SOAP</name>
   <description>SOAP Stack</description>
 

Modified: incubator/servicemix/trunk/tooling/jbi-maven-plugin/pom.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/tooling/jbi-maven-plugin/pom.xml?rev=429390&r1=429389&r2=429390&view=diff
==============================================================================
--- incubator/servicemix/trunk/tooling/jbi-maven-plugin/pom.xml (original)
+++ incubator/servicemix/trunk/tooling/jbi-maven-plugin/pom.xml Mon Aug  7 10:00:37 2006
@@ -75,6 +75,11 @@
             <version>3.0-incubating-SNAPSHOT</version>          
         </dependency>
         <dependency>
+            <groupId>org.apache.servicemix</groupId>
+            <artifactId>servicemix-common</artifactId>
+            <version>3.0-incubating-SNAPSHOT</version>          
+        </dependency>
+        <dependency>
             <groupId>org.apache.geronimo.specs</groupId>
             <artifactId>geronimo-javamail_1.3.1_spec</artifactId>           
         </dependency>

Modified: incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateServiceUnitDescriptorMojo.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateServiceUnitDescriptorMojo.java?rev=429390&r1=429389&r2=429390&view=diff
==============================================================================
--- incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateServiceUnitDescriptorMojo.java
(original)
+++ incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateServiceUnitDescriptorMojo.java
Mon Aug  7 10:00:37 2006
@@ -17,17 +17,19 @@
 package org.apache.servicemix.maven.plugin.jbi;
 
 import java.io.File;
-import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 
 import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
-import org.codehaus.plexus.util.FileUtils;
+import org.apache.servicemix.common.packaging.ServiceUnitAnalyzer;
 
 /**
  * A Mojo used to build the jbi.xml file for a service unit.
@@ -99,7 +101,7 @@
 
 		// Generate jbi descriptor and copy it to the build directory
 		getLog().info("Generating jbi.xml");
-		try {			
+		try {
 			generateJbiDescriptor();
 		} catch (JbiPluginException e) {
 			throw new MojoExecutionException("Failed to generate jbi.xml", e);
@@ -107,6 +109,49 @@
 
 	}
 
+	private void buildConnections() {
+
+	}
+
+	/**
+	 * Set up a classloader for the execution of the main class.
+	 * 
+	 * @return
+	 * @throws MojoExecutionException
+	 */
+	private URLClassLoader getClassLoader() throws MojoExecutionException {
+		try {
+			Set urls = new HashSet();
+
+			URL mainClasses = new File(project.getBuild().getOutputDirectory())
+					.toURL();
+			getLog().debug("Adding to classpath : " + mainClasses);
+			urls.add(mainClasses);
+
+			URL testClasses = new File(project.getBuild()
+					.getTestOutputDirectory()).toURL();
+			getLog().debug("Adding to classpath : " + testClasses);
+			urls.add(testClasses);
+
+			Set dependencies = project.getArtifacts();
+			Iterator iter = dependencies.iterator();
+			while (iter.hasNext()) {
+				Artifact classPathElement = (Artifact) iter.next();
+				getLog().debug(
+						"Adding artifact: " + classPathElement.getArtifactId()
+								+ " to classpath");
+				urls.add(classPathElement.getFile().toURL());
+			}
+			URLClassLoader appClassloader = new URLClassLoader((URL[]) urls
+					.toArray(new URL[urls.size()]), this.getClass()
+					.getClassLoader());
+			return appClassloader;
+		} catch (MalformedURLException e) {
+			throw new MojoExecutionException(
+					"Error during setting up classpath", e);
+		}
+	}
+
 	/**
 	 * Generates the deployment descriptor if necessary.
 	 */
@@ -118,10 +163,24 @@
 
 		File descriptor = new File(outputDir, JBI_DESCRIPTOR);
 
-		List uris = new ArrayList();		
+		List uris = new ArrayList();
 
 		JbiServiceUnitDescriptorWriter writer = new JbiServiceUnitDescriptorWriter(
 				encoding);
+
+		ServiceUnitAnalyzer serviceUnitAnalyzer = getServiceUnitAnalyzer();
+		List consumes = new ArrayList();
+		List provides = new ArrayList();
+		if (serviceUnitAnalyzer != null) {
+			consumes.addAll(serviceUnitAnalyzer.getConsumes());
+			provides.addAll(serviceUnitAnalyzer.getProvides());
+		}
+
 		writer.write(descriptor, name, description, uris);
+	}
+
+	private ServiceUnitAnalyzer getServiceUnitAnalyzer() {
+		// TODO Auto-generated method stub
+		return null;
 	}
 }



Mime
View raw message