camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r658389 - in /activemq/camel/trunk: camel-core/src/main/java/org/apache/camel/impl/ camel-core/src/main/java/org/apache/camel/management/ camel-core/src/main/java/org/apache/camel/model/ camel-core/src/main/java/org/apache/camel/processor/i...
Date Tue, 20 May 2008 18:51:10 GMT
Author: jstrachan
Date: Tue May 20 11:51:10 2008
New Revision: 658389

URL: http://svn.apache.org/viewvc?rev=658389&view=rev
Log:
added an initial implementation of a debugging interceptor along with integration with the
spring based Main for https://issues.apache.org/activemq/browse/CAMEL-531

Added:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Breakpoint.java
  (with props)
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/DebugInterceptor.java
  (with props)
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Debugger.java
  (with props)
    activemq/camel/trunk/components/camel-spring/src/main/resources/META-INF/services/org/apache/camel/spring/
    activemq/camel/trunk/components/camel-spring/src/main/resources/META-INF/services/org/apache/camel/spring/debug.xml
  (with props)
Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/RouteContext.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationLifecycleStrategy.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/OptionalIdentifiedType.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/Main.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java?rev=658389&r1=658388&r2=658389&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
Tue May 20 11:51:10 2008
@@ -47,6 +47,7 @@
 import org.apache.camel.spi.LanguageResolver;
 import org.apache.camel.spi.LifecycleStrategy;
 import org.apache.camel.spi.Registry;
+import org.apache.camel.spi.InterceptStrategy;
 import org.apache.camel.util.FactoryFinder;
 import org.apache.camel.util.NoFactoryAvailableException;
 import org.apache.camel.util.ObjectHelper;
@@ -79,6 +80,7 @@
     private Registry registry;
     private LifecycleStrategy lifecycleStrategy = new DefaultLifecycleStrategy();
     private List<RouteType> routeDefinitions = new ArrayList<RouteType>();
+    private List<InterceptStrategy> interceptStrategies = new ArrayList<InterceptStrategy>();
 
     public DefaultCamelContext() {
         name = NAME_PREFIX + ++nameSuffix;
@@ -416,6 +418,17 @@
         return routeDefinitions;
     }
 
+    public List<InterceptStrategy> getInterceptStrategies() {
+        return interceptStrategies;
+    }
+
+    public void setInterceptStrategies(List<InterceptStrategy> interceptStrategies)
{
+        this.interceptStrategies = interceptStrategies;
+    }
+
+    public void addInterceptStrategy(InterceptStrategy interceptStrategy) {
+        getInterceptStrategies().add(interceptStrategy);
+    }
 
     // Implementation methods
     // -----------------------------------------------------------------------

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/RouteContext.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/RouteContext.java?rev=658389&r1=658388&r2=658389&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/RouteContext.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/RouteContext.java
Tue May 20 11:51:10 2008
@@ -50,7 +50,7 @@
     private List<Processor> eventDrivenProcessors = new ArrayList<Processor>();
     private Interceptor lastInterceptor;
     private CamelContext camelContext;
-    private InterceptStrategy interceptStrategy;
+    private List<InterceptStrategy> interceptStrategies = new ArrayList<InterceptStrategy>();
 
     public RouteContext(RouteType route, FromType from, Collection<Route> routes) {
         this.route = route;
@@ -181,20 +181,24 @@
     }
 
     /**
-     * This method retrieves the InterceptStrategy on this route context.
+     * This method retrieves the InterceptStrategy instances this route context.
      *
      * @return InterceptStrategy
      */
-    public InterceptStrategy getInterceptStrategy() {
-        return interceptStrategy;
+    public List<InterceptStrategy> getInterceptStrategies() {
+        return interceptStrategies;
     }
 
     /**
-     * This method sets the InterceptStrategy on this route context.
+     * This method sets the InterceptStrategy instances on this route context.
      *
-     * @param strategy
+     * @param interceptStrategies
      */
-    public void setInterceptStrategy(InterceptStrategy strategy) {
-        interceptStrategy = strategy;
+    public void setInterceptStrategies(List<InterceptStrategy> interceptStrategies)
{
+        this.interceptStrategies = interceptStrategies;
+    }
+
+    public void addInterceptStrategy(InterceptStrategy interceptStrategy) {
+        getInterceptStrategies().add(interceptStrategy);
     }
 }

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationLifecycleStrategy.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationLifecycleStrategy.java?rev=658389&r1=658388&r2=658389&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationLifecycleStrategy.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationLifecycleStrategy.java
Tue May 20 11:51:10 2008
@@ -129,8 +129,7 @@
             counterMap.put(processor, pc);
         }
 
-        routeContext.setInterceptStrategy(
-                new InstrumentationInterceptStrategy(counterMap));
+        routeContext.addInterceptStrategy(new InstrumentationInterceptStrategy(counterMap));
 
         // Add an InstrumentationProcessor at the beginning of each route and
         // set up the interceptorMap for onRoutesAdd() method to register the

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/OptionalIdentifiedType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/OptionalIdentifiedType.java?rev=658389&r1=658388&r2=658389&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/OptionalIdentifiedType.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/OptionalIdentifiedType.java
Tue May 20 11:51:10 2008
@@ -16,12 +16,15 @@
  */
 package org.apache.camel.model;
 
+import java.util.concurrent.atomic.AtomicInteger;
+
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlAttribute;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlID;
 import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlTransient;
 import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 
@@ -39,6 +42,8 @@
     private String id;
     @XmlElement(required = false)
     private Description description;
+    @XmlTransient
+    protected static AtomicInteger nodeCounter = new AtomicInteger(1);
 
     /**
      * Gets the value of the id property.
@@ -88,4 +93,11 @@
         setId(id);
         return (T) this;
     }
+
+    public String idOrCreate() {
+        if (id == null) {
+            setId("node" + nodeCounter.incrementAndGet());
+        }
+        return getId();
+    }
 }
\ No newline at end of file

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java?rev=658389&r1=658388&r2=658389&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java
Tue May 20 11:51:10 2008
@@ -38,6 +38,7 @@
 import org.apache.camel.Processor;
 import org.apache.camel.Route;
 import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.CamelContext;
 import org.apache.camel.builder.DataFormatClause;
 import org.apache.camel.builder.DeadLetterChannelBuilder;
 import org.apache.camel.builder.ErrorHandlerBuilder;
@@ -45,6 +46,7 @@
 import org.apache.camel.builder.NoErrorHandlerBuilder;
 import org.apache.camel.builder.ProcessorBuilder;
 import org.apache.camel.impl.RouteContext;
+import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.model.dataformat.DataFormatType;
 import org.apache.camel.model.language.ExpressionType;
 import org.apache.camel.model.language.LanguageExpression;
@@ -1473,9 +1475,18 @@
             throw new RuntimeCamelException("target provided.");
         }
 
-        InterceptStrategy strategy = routeContext.getInterceptStrategy();
-        if (strategy != null) {
-            target = strategy.wrapProcessorInInterceptors(this, target);
+
+        List<InterceptStrategy> strategies = new ArrayList<InterceptStrategy>();
+        CamelContext camelContext = routeContext.getCamelContext();
+        if (camelContext instanceof DefaultCamelContext) {
+            DefaultCamelContext defaultCamelContext = (DefaultCamelContext) camelContext;
+            strategies.addAll(defaultCamelContext.getInterceptStrategies());
+        }
+        strategies.addAll(routeContext.getInterceptStrategies());
+        for (InterceptStrategy strategy : strategies) {
+            if (strategy != null) {
+                target = strategy.wrapProcessorInInterceptors(this, target);
+            }
         }
 
         List<InterceptorType> list = routeContext.getRoute().getInterceptors();

Added: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Breakpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Breakpoint.java?rev=658389&view=auto
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Breakpoint.java
(added)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Breakpoint.java
Tue May 20 11:51:10 2008
@@ -0,0 +1,30 @@
+/**
+ *
+ * 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.camel.processor.interceptor;
+
+import org.apache.camel.Exchange;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public class Breakpoint {
+    public void waitForBreakpoint(Exchange exchange) {
+        // TODO
+
+    }
+}

Propchange: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Breakpoint.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/DebugInterceptor.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/DebugInterceptor.java?rev=658389&view=auto
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/DebugInterceptor.java
(added)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/DebugInterceptor.java
Tue May 20 11:51:10 2008
@@ -0,0 +1,102 @@
+/**
+ *
+ * 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.camel.processor.interceptor;
+
+import java.util.List;
+
+import org.apache.camel.model.ProcessorType;
+import org.apache.camel.Processor;
+import org.apache.camel.Exchange;
+import org.apache.camel.Predicate;
+
+/**
+ * An interceptor for debugging and tracing routes
+ * 
+ * @version $Revision: 1.1 $
+ */
+public class DebugInterceptor implements Processor {
+    private final ProcessorType node;
+    private final Processor target;
+    private final List<Exchange> exchanges;
+    private Predicate traceFilter;
+    private Breakpoint breakpoint = new Breakpoint();
+
+    public DebugInterceptor(ProcessorType node, Processor target, List<Exchange> exchanges)
{
+        this.node = node;
+        this.target = target;
+        this.exchanges = exchanges;
+    }
+
+    @Override
+    public String toString() {
+        return "DebugInterceptor[" + node + "]";
+    }
+
+    public void process(Exchange exchange) throws Exception {
+        checkForBreakpoint(exchange);        
+        addTraceExchange(exchange);
+        target.process(exchange);
+    }
+
+    public ProcessorType getNode() {
+        return node;
+    }
+
+    public Processor getTarget() {
+        return target;
+    }
+
+    public List<Exchange> getExchanges() {
+        return exchanges;
+    }
+
+    public Breakpoint getBreakpoint() {
+        return breakpoint;
+    }
+
+    public Predicate getTraceFilter() {
+        return traceFilter;
+    }
+
+    public void setTraceFilter(Predicate traceFilter) {
+        this.traceFilter = traceFilter;
+    }
+
+    /**
+     * Stategy method to wait for a breakpoint if one is set
+     */
+    protected void checkForBreakpoint(Exchange exchange) {
+        breakpoint.waitForBreakpoint(exchange);
+    }
+
+    /**
+     * Strategy method to store the exchange in a trace log if it is enabled
+     */
+    protected void addTraceExchange(Exchange exchange) {
+        if (shouldTraceExchange(exchange)) {
+            exchanges.add(exchange);
+        }
+    }
+
+    /**
+     * Returns true if the given exchange should be logged in the trace list
+     */
+    protected boolean shouldTraceExchange(Exchange exchange) {
+        return traceFilter == null || traceFilter.matches(exchange) ;
+    }
+}

Propchange: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/DebugInterceptor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Debugger.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Debugger.java?rev=658389&view=auto
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Debugger.java
(added)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Debugger.java
Tue May 20 11:51:10 2008
@@ -0,0 +1,96 @@
+/**
+ *
+ * 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.camel.processor.interceptor;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.List;
+import java.util.ArrayList;
+
+import org.apache.camel.Processor;
+import org.apache.camel.Exchange;
+import org.apache.camel.model.ProcessorType;
+import org.apache.camel.spi.InterceptStrategy;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * An interceptor strategy for debugging and tracing routes
+ *
+ * @version $Revision: 1.1 $
+ */
+public class Debugger implements InterceptStrategy {
+    private static final transient Log LOG = LogFactory.getLog(Debugger.class);
+
+    private int exchangeBufferSize = -1;
+    private Map<String, DebugInterceptor> interceptors = new HashMap<String, DebugInterceptor>();
+
+    public DebugInterceptor getInterceptor(String id) {
+        return interceptors.get(id);
+    }
+
+    /**
+     * Returns the list of exchanges sent to the given node in the DSL
+     */
+    public List<Exchange> getExchanges(String id) {
+        DebugInterceptor interceptor = getInterceptor(id);
+        if (interceptor == null) {
+            return null;
+        }
+        else {
+            return interceptor.getExchanges();
+        }
+    }
+
+    /**
+     * Returns the breakpoint object for the given node in the DSL
+     */
+    public Breakpoint getBreakpoint(String id) {
+        DebugInterceptor interceptor = getInterceptor(id);
+        if (interceptor == null) {
+            return null;
+        }
+        else {
+            return interceptor.getBreakpoint();
+        }
+    }
+
+
+    public Processor wrapProcessorInInterceptors(ProcessorType processorType, Processor target)
throws Exception {
+        String id = processorType.idOrCreate();
+        DebugInterceptor interceptor = new DebugInterceptor(processorType, target, createExchangeList());
+        interceptors.put(id, interceptor);
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("adding interceptor: " + interceptor);
+        }
+        return interceptor;
+    }
+
+    protected List<Exchange> createExchangeList() {
+        if (exchangeBufferSize == 0) {
+            return null;
+        }
+        else if (exchangeBufferSize > 0) {
+            // TODO lets create a non blocking fixed size queue
+            return new ArrayList<Exchange>();
+        }
+        else {
+             return new ArrayList<Exchange>();
+        }
+    }
+}

Propchange: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Debugger.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java?rev=658389&r1=658388&r2=658389&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
(original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
Tue May 20 11:51:10 2008
@@ -31,6 +31,7 @@
 import javax.xml.bind.annotation.XmlTransient;
 
 import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.processor.interceptor.Debugger;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.model.IdentifiedType;
 import org.apache.camel.model.RouteBuilderRef;
@@ -121,6 +122,26 @@
     }
 
     public void afterPropertiesSet() throws Exception {
+        // lets see if we can find a debugger to add
+        // TODO there should be a neater way to do this!
+        Debugger debugger = null;
+        String[] names = getApplicationContext().getBeanNamesForType(Debugger.class, true,
true);
+        if (names.length == 1) {
+             debugger = (Debugger) getApplicationContext().getBean(names[0], Debugger.class);
+        }
+        if (debugger == null) {
+            ApplicationContext parentContext = getApplicationContext().getParent();
+            if (parentContext != null) {
+                names = parentContext.getBeanNamesForType(Debugger.class, true, true);
+                if (names.length == 1) {
+                    debugger = (Debugger) parentContext.getBean(names[0], Debugger.class);
+                }
+            }
+        }
+        if (debugger != null) {
+            getContext().addInterceptStrategy(debugger);
+        }
+
         // Set the application context and camelContext for the beanPostProcessor
         if (beanPostProcessor != null) {
             if (beanPostProcessor instanceof ApplicationContextAware) {

Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/Main.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/Main.java?rev=658389&r1=658388&r2=658389&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/Main.java
(original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/Main.java
Tue May 20 11:51:10 2008
@@ -55,8 +55,11 @@
     private TimeUnit timeUnit = TimeUnit.MILLISECONDS;
     private String dotOutputDir;
     private boolean aggregateDot;
+    private boolean debug = false;
     private List<RouteBuilder> routeBuilders = new ArrayList<RouteBuilder>();
     private List<SpringCamelContext> camelContexts = new ArrayList<SpringCamelContext>();
+    private AbstractApplicationContext parentApplicationContext;
+    private String parentApplicationContextUri;
 
     public Main() {
         addOption(new Option("h", "help", "Displays the help screen") {
@@ -72,6 +75,11 @@
                 setApplicationContextUri(parameter);
             }
         });
+        addOption(new Option("d", "debug", "Enables the debugger") {
+            protected void doProcess(String arg, LinkedList<String> remainingArgs)
{
+                setDebug(true);
+            }
+        });
         addOption(new ParameterOption("o", "outdir",
                 "Sets the DOT output directory where the visual representations of the routes
are generated",
                 "dot") {
@@ -188,6 +196,7 @@
         options.add(option);
     }
 
+
     public abstract class Option {
         private String abbreviation;
         private String fullName;
@@ -255,6 +264,7 @@
         this.applicationContext = applicationContext;
     }
 
+
     public String getApplicationContextUri() {
         return applicationContextUri;
     }
@@ -262,6 +272,27 @@
     public void setApplicationContextUri(String applicationContextUri) {
         this.applicationContextUri = applicationContextUri;
     }
+    public AbstractApplicationContext getParentApplicationContext() {
+        if (parentApplicationContext == null) {
+            if (parentApplicationContextUri != null) {
+                parentApplicationContext = new ClassPathXmlApplicationContext(parentApplicationContextUri);
+                parentApplicationContext.start();
+            }
+        }
+        return parentApplicationContext;
+    }
+
+    public void setParentApplicationContext(AbstractApplicationContext parentApplicationContext)
{
+        this.parentApplicationContext = parentApplicationContext;
+    }
+
+    public String getParentApplicationContextUri() {
+        return parentApplicationContextUri;
+    }
+
+    public void setParentApplicationContextUri(String parentApplicationContextUri) {
+        this.parentApplicationContextUri = parentApplicationContextUri;
+    }
 
     public List<SpringCamelContext> getCamelContexts() {
         return camelContexts;
@@ -321,6 +352,17 @@
         return aggregateDot;
     }
 
+    public boolean isDebug() {
+        return debug;
+    }
+
+    public void setDebug(boolean debug) {
+        this.debug = debug;
+        if (debug) {
+            setParentApplicationContextUri("/META-INF/services/org/apache/camel/spring/debug.xml");
+        }
+    }
+
     // Implementation methods
     // -------------------------------------------------------------------------
     protected void doStart() throws Exception {
@@ -335,7 +377,13 @@
 
     protected AbstractApplicationContext createDefaultApplicationContext() {
         String[] args = getApplicationContextUri().split(";");
-        return new ClassPathXmlApplicationContext(args);
+        ApplicationContext parentContext = getParentApplicationContext();
+        if (parentContext != null ) {
+            return new ClassPathXmlApplicationContext(args, parentContext);
+        }
+        else {
+            return new ClassPathXmlApplicationContext(args);
+        }
     }
 
     protected void doStop() throws Exception {

Added: activemq/camel/trunk/components/camel-spring/src/main/resources/META-INF/services/org/apache/camel/spring/debug.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/resources/META-INF/services/org/apache/camel/spring/debug.xml?rev=658389&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/resources/META-INF/services/org/apache/camel/spring/debug.xml
(added)
+++ activemq/camel/trunk/components/camel-spring/src/main/resources/META-INF/services/org/apache/camel/spring/debug.xml
Tue May 20 11:51:10 2008
@@ -0,0 +1,27 @@
+<?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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+       http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
+    ">
+
+  <!-- lets define a debugger -->
+  <bean id="camelDebugger" class="org.apache.camel.processor.interceptor.Debugger"/>
+</beans>

Propchange: activemq/camel/trunk/components/camel-spring/src/main/resources/META-INF/services/org/apache/camel/spring/debug.xml
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message