You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by pd...@apache.org on 2006/08/04 20:07:36 UTC

svn commit: r428805 - in /incubator/servicemix/trunk/tooling: jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/ servicemix-embedded-simple/ servicemix-embedded-simple/src/ servicemix-embedded-simple/src/main/ servicemix-embedded-si...

Author: pdodds
Date: Fri Aug  4 11:07:35 2006
New Revision: 428805

URL: http://svn.apache.org/viewvc?rev=428805&view=rev
Log:
Extended the Maven plugin for the jbi:embeddedServicemix goal and also added in an archetype to give you an example of a project that can be run in embedded mode.

Added:
    incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/ServiceMixEmbeddedMojo.java
    incubator/servicemix/trunk/tooling/servicemix-embedded-simple/
    incubator/servicemix/trunk/tooling/servicemix-embedded-simple/pom.xml
    incubator/servicemix/trunk/tooling/servicemix-embedded-simple/src/
    incubator/servicemix/trunk/tooling/servicemix-embedded-simple/src/main/
    incubator/servicemix/trunk/tooling/servicemix-embedded-simple/src/main/resources/
    incubator/servicemix/trunk/tooling/servicemix-embedded-simple/src/main/resources/META-INF/
    incubator/servicemix/trunk/tooling/servicemix-embedded-simple/src/main/resources/META-INF/maven/
    incubator/servicemix/trunk/tooling/servicemix-embedded-simple/src/main/resources/META-INF/maven/archetype.xml
    incubator/servicemix/trunk/tooling/servicemix-embedded-simple/src/main/resources/archetype-resources/
    incubator/servicemix/trunk/tooling/servicemix-embedded-simple/src/main/resources/archetype-resources/pom.xml
    incubator/servicemix/trunk/tooling/servicemix-embedded-simple/src/main/resources/archetype-resources/src/
    incubator/servicemix/trunk/tooling/servicemix-embedded-simple/src/main/resources/archetype-resources/src/main/
    incubator/servicemix/trunk/tooling/servicemix-embedded-simple/src/main/resources/archetype-resources/src/main/resources/
    incubator/servicemix/trunk/tooling/servicemix-embedded-simple/src/main/resources/archetype-resources/src/main/resources/servicemix.xml
Modified:
    incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/ServiceMixMojo.java

Added: incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/ServiceMixEmbeddedMojo.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/ServiceMixEmbeddedMojo.java?rev=428805&view=auto
==============================================================================
--- incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/ServiceMixEmbeddedMojo.java (added)
+++ incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/ServiceMixEmbeddedMojo.java Fri Aug  4 11:07:35 2006
@@ -0,0 +1,86 @@
+/*
+ * 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.maven.plugin.jbi;
+
+import java.io.File;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.servicemix.jbi.container.SpringJBIContainer;
+import org.apache.xbean.spring.context.FileSystemXmlApplicationContext;
+import org.springframework.beans.factory.DisposableBean;
+
+/**
+ * Starts a ServiceMix JBI container in embedded mode using the servicemix.xml
+ * 
+ * @author <a href="pdodds@apache.org">Philip Dodds</a>
+ * @version $Id: GenerateComponentDescriptorMojo 314956 2005-10-12 16:27:15Z
+ *          brett $
+ * @goal embeddedServicemix
+ * @requiresDependencyResolution runtime
+ * @description Starts a local servicemix instance using the servicemix config
+ *              provided
+ */
+public class ServiceMixEmbeddedMojo extends AbstractJbiMojo {
+
+	/**
+	 * @parameter default-value="${basedir}/src/main/resources/servicemix.xml"
+	 */
+	private File servicemixConfig;
+
+	private FileSystemXmlApplicationContext context;
+
+	private SpringJBIContainer container;
+
+	public void execute() throws MojoExecutionException, MojoFailureException {
+
+		try {
+			startServiceMix();
+
+			Object lock = new Object();
+			container.setShutdownLock(lock);
+
+			// lets wait until we're killed.
+			synchronized (lock) {
+				lock.wait();
+			}
+		} catch (Exception e) {
+			throw new MojoExecutionException(
+					"Apache ServiceMix was able to deploy project", e);
+		} finally {
+			if (context instanceof DisposableBean) {
+				try {
+					((DisposableBean) context).destroy();
+				} catch (Exception e) {
+					// Ignore
+				}
+			}
+		}
+
+	}
+
+	private void startServiceMix() throws MojoExecutionException {
+		try {
+			context = new FileSystemXmlApplicationContext(servicemixConfig
+					.getAbsolutePath());
+			container = (SpringJBIContainer) context.getBean("jbi");
+		} catch (Exception e) {
+			throw new MojoExecutionException(
+					"Unable to start the ServiceMix container", e);
+		}
+	}
+}

Modified: incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/ServiceMixMojo.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/ServiceMixMojo.java?rev=428805&r1=428804&r2=428805&view=diff
==============================================================================
--- incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/ServiceMixMojo.java (original)
+++ incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/ServiceMixMojo.java Fri Aug  4 11:07:35 2006
@@ -77,9 +77,11 @@
 			startServiceMix();
 			deployProject();
 
-			getLog().info("Project deployed");
-			while (true)
-				;
+			getLog().info("Project deployed");			
+
+			while (true) {
+				Thread.sleep(1000);
+			}
 		} catch (Exception e) {
 			stopServiceMix();
 			throw new MojoExecutionException(

Added: incubator/servicemix/trunk/tooling/servicemix-embedded-simple/pom.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/tooling/servicemix-embedded-simple/pom.xml?rev=428805&view=auto
==============================================================================
--- incubator/servicemix/trunk/tooling/servicemix-embedded-simple/pom.xml (added)
+++ incubator/servicemix/trunk/tooling/servicemix-embedded-simple/pom.xml Fri Aug  4 11:07:35 2006
@@ -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.
+-->
+<!-- $Rev: 365333 $ $Date: 2006-01-02 12:21:09 +0100 (lun., 02 janv. 2006) $ -->
+<project 
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" 
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
+    xmlns="http://maven.apache.org/POM/4.0.0">
+    
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.servicemix.tooling</groupId>
+    <artifactId>tooling</artifactId>
+    <version>1.0-incubating-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>servicemix-embedded-simple</artifactId>
+  <name>ServiceMix :: Maven2 :: Archetypes :: EmbeddedSimple</name>
+
+</project>
\ No newline at end of file

Added: incubator/servicemix/trunk/tooling/servicemix-embedded-simple/src/main/resources/META-INF/maven/archetype.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/tooling/servicemix-embedded-simple/src/main/resources/META-INF/maven/archetype.xml?rev=428805&view=auto
==============================================================================
--- incubator/servicemix/trunk/tooling/servicemix-embedded-simple/src/main/resources/META-INF/maven/archetype.xml (added)
+++ incubator/servicemix/trunk/tooling/servicemix-embedded-simple/src/main/resources/META-INF/maven/archetype.xml Fri Aug  4 11:07:35 2006
@@ -0,0 +1,6 @@
+<archetype>
+  <id>servicemix-su</id>
+   <resources>
+    <resource>src/main/resources/servicemix.xml</resource>
+  </resources>
+</archetype>

Added: incubator/servicemix/trunk/tooling/servicemix-embedded-simple/src/main/resources/archetype-resources/pom.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/tooling/servicemix-embedded-simple/src/main/resources/archetype-resources/pom.xml?rev=428805&view=auto
==============================================================================
--- incubator/servicemix/trunk/tooling/servicemix-embedded-simple/src/main/resources/archetype-resources/pom.xml (added)
+++ incubator/servicemix/trunk/tooling/servicemix-embedded-simple/src/main/resources/archetype-resources/pom.xml Fri Aug  4 11:07:35 2006
@@ -0,0 +1,58 @@
+<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>
+  <groupId>${groupId}</groupId>
+  <artifactId>${artifactId}</artifactId>
+  <version>${version}</version>
+  <name>A custom project</name>
+  <url>http://www.myorganization.org</url>
+  <pluginRepositories>
+    <pluginRepository>
+      <id>apache.snapshots</id>
+      <name>Maven Central Plugins Development Repository</name>
+      <url>http://cvs.apache.org/maven-snapshot-repository</url>
+      <snapshots>
+        <enabled>true</enabled>
+      </snapshots>
+      <releases>
+         <enabled>false</enabled>
+      </releases>
+    </pluginRepository>
+  </pluginRepositories>
+  <repositories>
+    <repository>
+      <id>apache.snapshots</id>
+      <name>Maven Central Plugins Development Repository</name>
+      <url>http://cvs.apache.org/maven-snapshot-repository</url>
+      <snapshots>
+        <enabled>true</enabled>
+      </snapshots>
+      <releases>
+         <enabled>false</enabled>
+      </releases>
+    </repository>
+  </repositories>
+  <properties>    
+    <servicemixJbiPluginVersion>1.0-incubating-SNAPSHOT</servicemixJbiPluginVersion>    
+  </properties>
+  <dependencies>   
+  </dependencies>
+  <build>
+  	<resources>
+      <resource>
+        <directory>src/main/resources</directory>
+        <includes>
+          <include>**/*</include>
+        </includes>
+      </resource>    
+    </resources>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.servicemix.tooling</groupId>
+        <artifactId>jbi-maven-plugin</artifactId>
+        <version>${servicemixJbiPluginVersion}</version>
+        <extensions>true</extensions>
+      </plugin>     
+    </plugins>
+  </build>
+</project>

Added: incubator/servicemix/trunk/tooling/servicemix-embedded-simple/src/main/resources/archetype-resources/src/main/resources/servicemix.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/tooling/servicemix-embedded-simple/src/main/resources/archetype-resources/src/main/resources/servicemix.xml?rev=428805&view=auto
==============================================================================
--- incubator/servicemix/trunk/tooling/servicemix-embedded-simple/src/main/resources/archetype-resources/src/main/resources/servicemix.xml (added)
+++ incubator/servicemix/trunk/tooling/servicemix-embedded-simple/src/main/resources/archetype-resources/src/main/resources/servicemix.xml Fri Aug  4 11:07:35 2006
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns:sm="http://servicemix.apache.org/config/1.0">
+
+  <!-- the JBI container -->
+  <sm:container id="jbi" 
+                rootDir="./target/servicemix/data/smx"                 
+                installationDirPath="./target/servicemix/install"
+                deploymentDirPath="./target/servicemix/deploy"
+                dumpStats="true"
+                statsInterval="10" 
+                flowName="seda">                   
+    <sm:activationSpecs>
+				<!-- Place your activation specs here -->
+    </sm:activationSpecs>
+  </sm:container>
+
+</beans>