camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1327100 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/management/ components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/ components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/ ...
Date Tue, 17 Apr 2012 13:59:05 GMT
Author: davsclaus
Date: Tue Apr 17 13:59:04 2012
New Revision: 1327100

URL: http://svn.apache.org/viewvc?rev=1327100&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/camel-core/src/main/java/org/apache/camel/management/DefaultManagementLifecycleStrategy.java
    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/Main.java
    camel/trunk/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/MyMainAppTest.java
    camel/trunk/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/filterTest.xml

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementLifecycleStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementLifecycleStrategy.java?rev=1327100&r1=1327099&r2=1327100&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementLifecycleStrategy.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/management/DefaultManagementLifecycleStrategy.java
Tue Apr 17 13:59:04 2012
@@ -792,13 +792,18 @@ public class DefaultManagementLifecycleS
 
         LOG.trace("Checking whether to register {} from route: {}", service, route);
 
+        ManagementAgent agent = getManagementStrategy().getManagementAgent();
+        if (agent == null) {
+            // do not register if no agent
+            return false;
+        }
+
         // always register if we are starting CamelContext
         if (getCamelContext().getStatus().isStarting()) {
             return true;
         }
 
         // register if always is enabled
-        ManagementAgent agent = getManagementStrategy().getManagementAgent();
         if (agent.getRegisterAlways()) {
             return true;
         }

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=1327100&r1=1327099&r2=1327100&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
Tue Apr 17 13:59:04 2012
@@ -78,16 +78,22 @@ public final class CamelBlueprintHelper 
 
         // ensure pojosr stores bundles in an unique target directory
         System.setProperty("org.osgi.framework.storage", "target/bundles/" + System.currentTimeMillis());
+
+        // get the bundles
         List<BundleDescriptor> bundles = getBundleDescriptors();
-        TinyBundle bundle = createTestBundle(name, descriptors);
 
-        // add ourself as a bundle
-        String jarName = name.toLowerCase();
-        bundles.add(getBundleDescriptor("target/bundles/" + jarName + ".jar", bundle));
+        if (includeTestBundle) {
+            // add ourselves as a bundle
+            TinyBundle bundle = createTestBundle(name, descriptors);
+            String jarName = name.toLowerCase();
+            bundles.add(getBundleDescriptor("target/bundles/" + jarName + ".jar", bundle));
+        }
 
+        // setup pojosr to use our bundles
         Map<String, List<BundleDescriptor>> config = new HashMap<String, List<BundleDescriptor>>();
         config.put(PojoServiceRegistryFactory.BUNDLE_DESCRIPTORS, bundles);
 
+        // create pojorsr osgi service registry
         PojoServiceRegistry reg = new PojoServiceRegistryFactoryImpl().newPojoServiceRegistry(config);
         return reg.getBundleContext();
     }

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=1327100&r1=1327099&r2=1327100&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
Tue Apr 17 13:59:04 2012
@@ -37,6 +37,7 @@ public class Main extends MainSupport {
     private String descriptors = "OSGI-INF/blueprint/*.xml";
     private CamelContext camelContext;
     private String bundleName = "MyBundle";
+    private boolean includeSelfAsBundle;
 
     public Main() {
 
@@ -110,7 +111,7 @@ public class Main extends MainSupport {
     }
 
     protected BundleContext createBundleContext(String name) throws Exception {
-        return CamelBlueprintHelper.createBundleContext(name, descriptors, false);
+        return CamelBlueprintHelper.createBundleContext(name, descriptors, isIncludeSelfAsBundle());
     }
 
     @Override
@@ -142,4 +143,12 @@ public class Main extends MainSupport {
     public void setBundleName(String bundleName) {
         this.bundleName = bundleName;
     }
+
+    public boolean isIncludeSelfAsBundle() {
+        return includeSelfAsBundle;
+    }
+
+    public void setIncludeSelfAsBundle(boolean includeSelfAsBundle) {
+        this.includeSelfAsBundle = includeSelfAsBundle;
+    }
 }

Modified: camel/trunk/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/MyMainAppTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/MyMainAppTest.java?rev=1327100&r1=1327099&r2=1327100&view=diff
==============================================================================
--- camel/trunk/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/MyMainAppTest.java
(original)
+++ camel/trunk/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/MyMainAppTest.java
Tue Apr 17 13:59:04 2012
@@ -36,6 +36,8 @@ public class MyMainAppTest {
     public void run() throws Exception {
         Main main = new Main();
         main.setBundleName("MyMainBundle");
+        // as we run this test without packing ourselves as bundle, then include ourselves
+        main.setIncludeSelfAsBundle(true);
         // we support *.xml to find any blueprint xml files
         main.setDescriptors("org/apache/camel/test/blueprint/xpath/*.xml");
         main.enableHangupSupport();

Modified: camel/trunk/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/filterTest.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/filterTest.xml?rev=1327100&r1=1327099&r2=1327100&view=diff
==============================================================================
--- camel/trunk/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/filterTest.xml
(original)
+++ camel/trunk/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/filterTest.xml
Tue Apr 17 13:59:04 2012
@@ -21,7 +21,7 @@
            xsi:schemaLocation="
              http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
 
-  <camelContext xmlns="http://camel.apache.org/schema/blueprint">
+  <camelContext id="filterCamel" xmlns="http://camel.apache.org/schema/blueprint">
 
     <route>
       <from uri="direct:start"/>



Mime
View raw message