camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1325307 - in /camel/trunk: components/camel-test-blueprint/ components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/ tooling/maven/camel-maven-plugin/ tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/ma...
Date Thu, 12 Apr 2012 15:06:29 GMT
Author: davsclaus
Date: Thu Apr 12 15:06:29 2012
New Revision: 1325307

URL: http://svn.apache.org/viewvc?rev=1325307&view=rev
Log:
CAMEL-5168: Added Main class in camel-test-blueprint, to make it easier to run Camel Blueprint
out of container.

Modified:
    camel/trunk/components/camel-test-blueprint/pom.xml
    camel/trunk/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java
    camel/trunk/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintTestSupport.java
    camel/trunk/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/Main.java
    camel/trunk/tooling/maven/camel-maven-plugin/pom.xml
    camel/trunk/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/RunMojo.java

Modified: camel/trunk/components/camel-test-blueprint/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-blueprint/pom.xml?rev=1325307&r1=1325306&r2=1325307&view=diff
==============================================================================
--- camel/trunk/components/camel-test-blueprint/pom.xml (original)
+++ camel/trunk/components/camel-test-blueprint/pom.xml Thu Apr 12 15:06:29 2012
@@ -83,6 +83,10 @@
             <version>${pax-tiny-bundle-version}</version>
         </dependency>
         <dependency>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+        </dependency>
+        <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
         </dependency>

Modified: camel/trunk/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java?rev=1325307&r1=1325306&r2=1325307&view=diff
==============================================================================
--- camel/trunk/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java
(original)
+++ camel/trunk/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java
Thu Apr 12 15:06:29 2012
@@ -67,7 +67,7 @@ public final class CamelBlueprintHelper 
     private CamelBlueprintHelper() {
     }
 
-    public static BundleContext createBundleContext(String name, String descriptors) throws
Exception {
+    public static BundleContext createBundleContext(String name, String descriptors, boolean
includeTestBundle) throws Exception {
         deleteDirectory("target/bundles");
         createDirectory("target/bundles");
 

Modified: camel/trunk/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintTestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintTestSupport.java?rev=1325307&r1=1325306&r2=1325307&view=diff
==============================================================================
--- camel/trunk/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintTestSupport.java
(original)
+++ camel/trunk/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintTestSupport.java
Thu Apr 12 15:06:29 2012
@@ -32,7 +32,7 @@ public abstract class CamelBlueprintTest
     @Before
     @Override
     public void setUp() throws Exception {
-        bundleContext = CamelBlueprintHelper.createBundleContext(getClass().getSimpleName(),
getBlueprintDescriptor());
+        bundleContext = CamelBlueprintHelper.createBundleContext(getClass().getSimpleName(),
getBlueprintDescriptor(), true);
         super.setUp();
     }
 

Modified: camel/trunk/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/Main.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/Main.java?rev=1325307&r1=1325306&r2=1325307&view=diff
==============================================================================
--- camel/trunk/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/Main.java
(original)
+++ camel/trunk/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/Main.java
Thu Apr 12 15:06:29 2012
@@ -17,6 +17,7 @@
 package org.apache.camel.test.blueprint;
 
 import java.util.HashMap;
+import java.util.LinkedList;
 import java.util.Map;
 import javax.xml.bind.JAXBException;
 
@@ -31,11 +32,45 @@ import org.osgi.framework.BundleContext;
  */
 public class Main extends MainSupport {
 
+    protected static Main instance;
     private BundleContext bundleContext;
     private String descriptors = "OSGI-INF/blueprint/*.xml";
     private CamelContext camelContext;
     private String bundleName = "MyBundle";
 
+    public Main() {
+
+        addOption(new ParameterOption("ac", "applicationContext",
+                "Sets the classpath based OSGi Blueprint", "applicationContext") {
+            protected void doProcess(String arg, String parameter, LinkedList<String>
remainingArgs) {
+                setDescriptors(parameter);
+            }
+        });
+
+        addOption(new ParameterOption("fa", "fileApplicationContext",
+                "Sets the filesystem based OSGi Blueprint", "fileApplicationContext") {
+            protected void doProcess(String arg, String parameter, LinkedList<String>
remainingArgs) {
+                setDescriptors(parameter);
+            }
+        });
+
+    }
+
+    public static void main(String... args) throws Exception {
+        Main main = new Main();
+        main.enableHangupSupport();
+        main.run(args);
+    }
+
+    /**
+     * Returns the currently executing main
+     *
+     * @return the current running instance
+     */
+    public static Main getInstance() {
+        return instance;
+    }
+
     @Override
     protected void doStart() throws Exception {
         super.doStart();
@@ -75,7 +110,7 @@ public class Main extends MainSupport {
     }
 
     protected BundleContext createBundleContext(String name) throws Exception {
-        return CamelBlueprintHelper.createBundleContext(name, descriptors);
+        return CamelBlueprintHelper.createBundleContext(name, descriptors, false);
     }
 
     @Override

Modified: camel/trunk/tooling/maven/camel-maven-plugin/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/tooling/maven/camel-maven-plugin/pom.xml?rev=1325307&r1=1325306&r2=1325307&view=diff
==============================================================================
--- camel/trunk/tooling/maven/camel-maven-plugin/pom.xml (original)
+++ camel/trunk/tooling/maven/camel-maven-plugin/pom.xml Thu Apr 12 15:06:29 2012
@@ -43,6 +43,11 @@
       <groupId>org.apache.camel</groupId>
       <artifactId>camel-spring-javaconfig</artifactId>
     </dependency>
+    <!-- camel-test-blueprint has Main class for running blueprint out of container -->
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-test-blueprint</artifactId>
+    </dependency>
     <dependency>
       <groupId>org.codehaus.mojo</groupId>
       <artifactId>exec-maven-plugin</artifactId>

Modified: camel/trunk/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/RunMojo.java
URL: http://svn.apache.org/viewvc/camel/trunk/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/RunMojo.java?rev=1325307&r1=1325306&r2=1325307&view=diff
==============================================================================
--- camel/trunk/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/RunMojo.java
(original)
+++ camel/trunk/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/RunMojo.java
Thu Apr 12 15:06:29 2012
@@ -54,9 +54,9 @@ import org.codehaus.mojo.exec.Executable
 import org.codehaus.mojo.exec.Property;
 
 /**
- * Runs a CamelContext using any Spring XML configuration files found in
- * <code>META-INF/spring/*.xml</code> and <code>camel-*.xml</code>
and
- * starting up the context.
+ * Runs a CamelContext using any Spring or Blueprint XML configuration files found in
+ * <code>META-INF/spring/*.xml</code>, and <code>OSGI-INF/blueprint/*.xml</code>,
+ * and <code>camel-*.xml</code> and starting up the context.
  *
  * @goal run
  * @requiresDependencyResolution runtime
@@ -64,7 +64,6 @@ import org.codehaus.mojo.exec.Property;
  */
 public class RunMojo extends AbstractExecMojo {
 
-    // TODO
     // this code is based on a copy-and-paste of maven-exec-plugin
     //
     // If we could avoid the mega-cut-n-paste it would really really help!
@@ -108,6 +107,13 @@ public class RunMojo extends AbstractExe
     protected boolean useDot;
 
     /**
+     * Whether to log the classpath when starting
+     *
+     * @parameter expression="false"
+     */
+    protected boolean logClasspath;
+
+    /**
      * @component
      */
     private ArtifactResolver artifactResolver;
@@ -618,7 +624,9 @@ public class RunMojo extends AbstractExe
         this.addRelevantPluginDependenciesToClasspath(classpathURLs);
         this.addRelevantProjectDependenciesToClasspath(classpathURLs);
 
-        getLog().info("Classpath = " + classpathURLs);
+        if (logClasspath) {
+            getLog().info("Classpath = " + classpathURLs);
+        }
         return new URLClassLoader(classpathURLs.toArray(new URL[classpathURLs.size()]));
     }
 



Mime
View raw message