activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r521274 - in /activemq/camel/trunk: ./ camel-jbi/ camel-jbi/src/main/java/org/apache/camel/component/ camel-jbi/src/main/java/org/apache/camel/component/jbi/ camel-jbi/src/main/java/org/apache/camel/jbi/ camel-jbi/src/test/java/org/apache/c...
Date Thu, 22 Mar 2007 13:59:36 GMT
Author: jstrachan
Date: Thu Mar 22 06:59:34 2007
New Revision: 521274

URL: http://svn.apache.org/viewvc?view=rev&rev=521274
Log:
more tidying up of the Exchange/Message APIs and an initial JBI implementation

Added:
    activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/
    activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/
    activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/JbiBinding.java
  (with props)
    activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/JbiEndpoint.java
  (with props)
    activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/JbiExchange.java
  (with props)
    activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/JbiMessage.java
  (with props)
    activemq/camel/trunk/camel-jbi/src/test/java/org/apache/camel/component/
    activemq/camel/trunk/camel-jbi/src/test/java/org/apache/camel/component/jbi/
Removed:
    activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/jbi/
    activemq/camel/trunk/camel-jbi/src/test/java/org/apache/camel/jbi/
Modified:
    activemq/camel/trunk/camel-jbi/pom.xml
    activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/component/jms/JmsExchange.java
    activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessage.java
    activemq/camel/trunk/pom.xml

Modified: activemq/camel/trunk/camel-jbi/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-jbi/pom.xml?view=diff&rev=521274&r1=521273&r2=521274
==============================================================================
--- activemq/camel/trunk/camel-jbi/pom.xml (original)
+++ activemq/camel/trunk/camel-jbi/pom.xml Thu Mar 22 06:59:34 2007
@@ -18,7 +18,7 @@
 -->
 
 <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">
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
 
   <modelVersion>4.0.0</modelVersion>
 

Added: activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/JbiBinding.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/JbiBinding.java?view=auto&rev=521274
==============================================================================
--- activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/JbiBinding.java
(added)
+++ activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/JbiBinding.java
Thu Mar 22 06:59:34 2007
@@ -0,0 +1,35 @@
+/**
+ *
+ * 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.component.jbi;
+
+import javax.jbi.messaging.NormalizedMessage;
+
+/**
+ * The binding of how Camel messages get mapped to JBI and back again
+ *
+ * @version $Revision$
+ */
+public class JbiBinding {
+    /**
+     * Extracts the body from the given normalized message
+     */
+    public Object extractBodyFromJbi(JbiExchange exchange, NormalizedMessage normalizedMessage)
{
+        // TODO we may wish to turn this into a POJO such as a JAXB/DOM
+        return normalizedMessage.getContent();
+    }
+}

Propchange: activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/JbiBinding.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/JbiBinding.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/JbiBinding.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/JbiEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/JbiEndpoint.java?view=auto&rev=521274
==============================================================================
--- activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/JbiEndpoint.java
(added)
+++ activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/JbiEndpoint.java
Thu Mar 22 06:59:34 2007
@@ -0,0 +1,70 @@
+/**
+ *
+ * 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.component.jbi;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.Processor;
+import org.apache.camel.impl.DefaultEndpoint;
+
+/**
+ * Represents an {@link Endpoint} for interacting with JBI
+ *
+ * @version $Revision$
+ */
+public class JbiEndpoint extends DefaultEndpoint<JbiExchange> {
+    private JbiBinding binding;
+
+    protected JbiEndpoint(String endpointUri, CamelContext container) {
+        super(endpointUri, container);
+    }
+
+    public void onExchange(JbiExchange exchange) {
+        // TODO
+        // lets create a JBI MessageExchange and dispatch into JBI...
+    }
+
+    @Override
+    protected void doActivate() {
+        super.doActivate();
+
+        Processor<JbiExchange> processor = getInboundProcessor();
+
+        // lets now wire up the processor to the JBI stuff...
+    }
+
+    public JbiExchange createExchange() {
+        return new JbiExchange(getContext(), getBinding());
+    }
+
+    public JbiBinding getBinding() {
+        if (binding == null) {
+            binding = new JbiBinding();
+        }
+        return binding;
+    }
+
+    /**
+     * Sets the binding on how Camel messages get mapped to JBI
+     *
+     * @param binding the new binding to use
+     */
+    public void setBinding(JbiBinding binding) {
+        this.binding = binding;
+    }
+}

Propchange: activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/JbiEndpoint.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/JbiEndpoint.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/JbiEndpoint.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/JbiExchange.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/JbiExchange.java?view=auto&rev=521274
==============================================================================
--- activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/JbiExchange.java
(added)
+++ activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/JbiExchange.java
Thu Mar 22 06:59:34 2007
@@ -0,0 +1,93 @@
+/**
+ *
+ * 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.component.jbi;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.impl.DefaultExchange;
+
+import javax.jbi.messaging.MessageExchange;
+
+/**
+ * An {@link Exchange} working with JBI which exposes the underlying JBI features such as
the 
+ * JBI {@link #getMessageExchange()}
+ *
+ * @version $Revision$
+ */
+public class JbiExchange extends DefaultExchange {
+    private final JbiBinding binding;
+    private MessageExchange messageExchange;
+
+    public JbiExchange(CamelContext context, JbiBinding binding) {
+        super(context);
+        this.binding = binding;
+    }
+
+    public JbiExchange(CamelContext context, JbiBinding binding, MessageExchange messageExchange)
{
+        super(context);
+        this.binding = binding;
+        this.messageExchange = messageExchange;
+
+        // TODO we could maybe use the typesafe APIs of different derived APIs from JBI 
+        setIn(new JbiMessage(messageExchange.getMessage("in")));
+        setOut(new JbiMessage(messageExchange.getMessage("out")));
+        setFault(new JbiMessage(messageExchange.getMessage("fault")));
+    }
+
+    /**
+     * Returns the underlying JBI message exchange for an inbound exchange
+     * or null for outbound messages
+     *
+     * @return the inbound message exchange
+     */
+    public MessageExchange getMessageExchange() {
+        return messageExchange;
+    }
+
+    @Override
+    public JbiMessage getIn() {
+        return (JbiMessage) super.getIn();
+    }
+
+    @Override
+    public JbiMessage getOut() {
+        return (JbiMessage) super.getOut();
+    }
+
+    @Override
+    public JbiMessage getFault() {
+        return (JbiMessage) super.getFault();
+    }
+
+    /**
+     * @return the Camel <-> JBI binding
+     */
+    public JbiBinding getBinding() {
+        return binding;
+    }
+
+    @Override
+    protected JbiMessage createInMessage() {
+        return new JbiMessage();
+    }
+
+    @Override
+    protected JbiMessage createOutMessage() {
+        return new JbiMessage();
+    }
+}

Propchange: activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/JbiExchange.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/JbiExchange.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/JbiExchange.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/JbiMessage.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/JbiMessage.java?view=auto&rev=521274
==============================================================================
--- activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/JbiMessage.java
(added)
+++ activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/JbiMessage.java
Thu Mar 22 06:59:34 2007
@@ -0,0 +1,95 @@
+/**
+ *
+ * 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.component.jbi;
+
+import org.apache.camel.impl.DefaultMessage;
+import org.apache.camel.Message;
+
+import javax.jbi.messaging.NormalizedMessage;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * A JBI {@link Message} which provides access to the underlying JBI features such as {@link
#getNormalizedMessage()}
+ *
+ * @version $Revision$
+ */
+public class JbiMessage extends DefaultMessage {
+    private NormalizedMessage normalizedMessage;
+
+    public JbiMessage() {
+    }
+
+    public JbiMessage(NormalizedMessage normalizedMessage) {
+        this.normalizedMessage = normalizedMessage;
+    }
+
+    @Override
+    public JbiExchange getExchange() {
+        return (JbiExchange) super.getExchange();
+    }
+
+    /**
+     * Returns the underlying JBI message
+     *
+     * @return the underlying JBI message
+     */
+    public NormalizedMessage getNormalizedMessage() {
+        return normalizedMessage;
+    }
+
+    public void setNormalizedMessage(NormalizedMessage normalizedMessage) {
+        this.normalizedMessage = normalizedMessage;
+    }
+
+    public Object getHeader(String name) {
+        Object answer = null;
+        if (normalizedMessage != null) {
+            answer = normalizedMessage.getProperty(name);
+        }
+        if (answer == null) {
+            answer = super.getHeader(name);
+        }
+        return answer;
+    }
+
+    @Override
+    public JbiMessage newInstance() {
+        return new JbiMessage();
+    }
+
+    @Override
+    protected Object createBody() {
+        if (normalizedMessage != null) {
+            return getExchange().getBinding().extractBodyFromJbi(getExchange(), normalizedMessage);
+        }
+        return null;
+    }
+
+    @Override
+    protected void populateInitialHeaders(Map<String, Object> map) {
+        if (normalizedMessage != null) {
+            Iterator iter = normalizedMessage.getPropertyNames().iterator();
+            while (iter.hasNext()) {
+                String name = iter.next().toString();
+                Object value = normalizedMessage.getProperty(name);
+                map.put(name, value);
+            }
+        }
+    }
+}

Propchange: activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/JbiMessage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/JbiMessage.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: activemq/camel/trunk/camel-jbi/src/main/java/org/apache/camel/component/jbi/JbiMessage.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/component/jms/JmsExchange.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/component/jms/JmsExchange.java?view=diff&rev=521274&r1=521273&r2=521274
==============================================================================
--- activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/component/jms/JmsExchange.java
(original)
+++ activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/component/jms/JmsExchange.java
Thu Mar 22 06:59:34 2007
@@ -65,12 +65,12 @@
     }
 
     @Override
-    protected org.apache.camel.Message createInMessage() {
+    protected JmsMessage createInMessage() {
         return new JmsMessage();
     }
 
     @Override
-    protected org.apache.camel.Message createOutMessage() {
+    protected JmsMessage createOutMessage() {
         return new JmsMessage();
     }
 }

Modified: activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessage.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessage.java?view=diff&rev=521274&r1=521273&r2=521274
==============================================================================
--- activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessage.java
(original)
+++ activemq/camel/trunk/camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessage.java
Thu Mar 22 06:59:34 2007
@@ -45,6 +45,11 @@
         return (JmsExchange) super.getExchange();
     }
 
+    /**
+     * Returns the underlying JMS message
+     *
+     * @return the underlying JMS message
+     */
     public Message getJmsMessage() {
         return jmsMessage;
     }

Modified: activemq/camel/trunk/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/pom.xml?view=diff&rev=521274&r1=521273&r2=521274
==============================================================================
--- activemq/camel/trunk/pom.xml (original)
+++ activemq/camel/trunk/pom.xml Thu Mar 22 06:59:34 2007
@@ -189,6 +189,8 @@
         <scope>runtime</scope>
         <optional>true</optional>
       </dependency>
+
+
       <!-- Optional Spring Support -->
       <dependency>
         <groupId>org.springframework</groupId>
@@ -241,6 +243,14 @@
         <groupId>org.slf4j</groupId>
         <artifactId>slf4j-simple</artifactId>
         <version>1.2</version>
+      </dependency>
+
+
+      <!-- optional jetty support -->
+      <dependency>
+        <groupId>org.mortbay.jetty</groupId>
+        <artifactId>jetty</artifactId>
+        <version>6.1.2rc1</version>
       </dependency>
 
       <dependency>



Mime
View raw message