camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r615759 - in /activemq/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel: ./ transport/
Date Mon, 28 Jan 2008 08:37:57 GMT
Author: ningjiang
Date: Mon Jan 28 00:37:55 2008
New Revision: 615759

URL: http://svn.apache.org/viewvc?rev=615759&view=rev
Log:
CAMEL-259 Added an example to show how to use camel transport

Added:
    activemq/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/
    activemq/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/
    activemq/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/CamelDestination.xml
  (with props)
    activemq/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/CamelTransportExample.java
  (with props)
    activemq/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/Client.java
  (with props)
    activemq/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/GreeterImpl.java
  (with props)
    activemq/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/ReaderToStringProcessor.java
  (with props)
    activemq/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/Server.java
  (with props)

Added: activemq/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/CamelDestination.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/CamelDestination.xml?rev=615759&view=auto
==============================================================================
--- activemq/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/CamelDestination.xml
(added)
+++ activemq/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/CamelDestination.xml
Mon Jan 28 00:37:55 2008
@@ -0,0 +1,46 @@
+<?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"
+       xmlns:camel="http://cxf.apache.org/transports/camel"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans
+       http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+       http://cxf.apache.org/transports/camel http://cxf.apache.org/transports/camel.xsd
+       http://activemq.apache.org/camel/schema/cxfEndpoint
+       http://activemq.apache.org/camel/schema/cxf/cxfEndpoint.xsd
+       http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
+    ">
+
+   <bean id = "roundRobinRef" class="org.apache.camel.processor.loadbalancer.RoundRobinLoadBalancer"
/>
+
+   <camelContext id="dest_context" xmlns="http://activemq.apache.org/camel/schema/spring">
+       <route>
+            <from uri="jetty:http://localhost:9090/GreeterContext/GreeterPort"/>
+            <loadBalance ref="roundRobinRef">
+              <to uri="direct:EndpointA"/>
+              <to uri="direct:EndpointB"/>
+            </loadBalance>
+        </route>
+   </camelContext>
+
+   <camel:destination name="{http://apache.org/hello_world_soap_http}CamelPort.camel-destination">
+        <camel:camelContextRef>dest_context</camel:camelContextRef>
+   </camel:destination>
+
+</beans>

Propchange: activemq/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/CamelDestination.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/CamelDestination.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: activemq/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/CamelDestination.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: activemq/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/CamelTransportExample.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/CamelTransportExample.java?rev=615759&view=auto
==============================================================================
--- activemq/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/CamelTransportExample.java
(added)
+++ activemq/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/CamelTransportExample.java
Mon Jan 28 00:37:55 2008
@@ -0,0 +1,49 @@
+/**
+ * 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.example.camel.transport;
+
+
+public class CamelTransportExample {
+    private CamelTransportExample() {
+    }
+
+    public static void main(String args[]) throws Exception {
+
+        //Server server = new Server();
+
+        try {
+            // setup the camel context for the camel transport
+            //server.prepare();
+            // start the endpoints
+            //server.start();
+            // set the client's service access point
+            Client client = new Client("http://localhost:9090/GreeterContext/GreeterPort");
+            // invoking the services
+            client.invock();
+
+            Thread.sleep(1000);
+
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        } finally {
+            //server.stop();
+            System.exit(0);
+        }
+
+    }
+
+}

Propchange: activemq/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/CamelTransportExample.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/CamelTransportExample.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: activemq/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/Client.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/Client.java?rev=615759&view=auto
==============================================================================
--- activemq/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/Client.java
(added)
+++ activemq/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/Client.java
Mon Jan 28 00:37:55 2008
@@ -0,0 +1,88 @@
+/**
+ * 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.example.camel.transport;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import javax.xml.namespace.QName;
+import javax.xml.ws.ProtocolException;
+import javax.xml.ws.Service;
+
+import org.apache.hello_world_soap_http.Greeter;
+import org.apache.hello_world_soap_http.PingMeFault;
+import org.apache.hello_world_soap_http.SOAPService;
+import org.apache.hello_world_soap_http.types.FaultDetail;
+
+public final class Client {
+
+    private static final QName SERVICE_NAME
+        = new QName("http://apache.org/hello_world_soap_http", "CamelService");
+    private static final QName PORT_NAME
+        = new QName("http://apache.org/hello_world_soap_http", "CamelPort");
+    private Service service;
+
+
+    public Client(String address) throws MalformedURLException {
+        // create the client from the SEI
+        service = Service.create(SERVICE_NAME);
+        service.addPort(PORT_NAME, javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_BINDING,
+                        address);
+
+    }
+
+
+
+    public void invock() throws Exception {
+
+        System.out.println("Acquiring router port ...");
+        Greeter port = service.getPort(PORT_NAME, Greeter.class);
+        String resp;
+
+        System.out.println("Invoking sayHi...");
+        resp = port.sayHi();
+        System.out.println("Server responded with: " + resp);
+        System.out.println();
+
+        System.out.println("Invoking greetMe... with Mike");
+        resp = port.greetMe("Mike");
+        System.out.println("Server responded with: " + resp);
+        System.out.println();
+
+        System.out.println("Invoking greetMe... with James");
+        resp = port.greetMe("James");
+        System.out.println("Server responded with: " + resp);
+        System.out.println();
+
+        System.out.println("Invoking greetMeOneWay...");
+        port.greetMeOneWay(System.getProperty("user.name"));
+        System.out.println("No response from server as method is OneWay");
+        System.out.println();
+
+        try {
+            System.out.println("Invoking pingMe, expecting exception...");
+            port.pingMe("hello");
+        } catch (PingMeFault ex) {
+            System.out.println("Expected exception: PingMeFault has occurred: " + ex.getMessage());
+            FaultDetail detail = ex.getFaultInfo();
+            System.out.println("FaultDetail major:" + detail.getMajor());
+            System.out.println("FaultDetail minor:" + detail.getMinor());
+        }
+
+    }
+
+}

Propchange: activemq/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/Client.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/Client.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: activemq/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/GreeterImpl.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/GreeterImpl.java?rev=615759&view=auto
==============================================================================
--- activemq/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/GreeterImpl.java
(added)
+++ activemq/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/GreeterImpl.java
Mon Jan 28 00:37:55 2008
@@ -0,0 +1,78 @@
+/**
+ * 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.example.camel.transport;
+
+import java.util.logging.Logger;
+import org.apache.hello_world_soap_http.Greeter;
+import org.apache.hello_world_soap_http.PingMeFault;
+import org.apache.hello_world_soap_http.types.FaultDetail;
+
+@javax.jws.WebService(portName = "CamelPort", serviceName = "CamelService",
+                      targetNamespace = "http://apache.org/hello_world_soap_http",
+                      endpointInterface = "org.apache.hello_world_soap_http.Greeter")
+
+ public class GreeterImpl implements Greeter {
+
+    private String suffix;
+
+    public GreeterImpl(String suffix) {
+        this.suffix = suffix;
+    }
+
+    private static final Logger LOG =
+        Logger.getLogger(GreeterImpl.class.getPackage().getName());
+
+    /* (non-Javadoc)
+     * @see org.apache.hello_world_soap_http.Greeter#greetMe(java.lang.String)
+     */
+    public String greetMe(String me) {
+        LOG.info("Executing operation greetMe");
+        System.out.println("Executing operation greetMe");
+        System.out.println("Message received: " + me + "\n");
+        return "Hello " + me + "form " + suffix ;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.hello_world_soap_http.Greeter#greetMeOneWay(java.lang.String)
+     */
+    public void greetMeOneWay(String me) {
+        LOG.info("Executing operation greetMeOneWay");
+        System.out.println("Executing operation greetMeOneWay\n");
+        System.out.println("Hello there " + me);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.hello_world_soap_http.Greeter#sayHi()
+     */
+    public String sayHi() {
+        LOG.info("Executing operation sayHi");
+        System.out.println("Executing operation sayHi\n");
+        return "Bonjour from" + suffix;
+    }
+
+    public void pingMe(String messageIn) throws PingMeFault {
+        FaultDetail faultDetail = new FaultDetail();
+        faultDetail.setMajor((short)2);
+        faultDetail.setMinor((short)1);
+        LOG.info("Executing operation pingMe, throwing PingMeFault exception, message = "
+                 + messageIn);
+        System.out.println("Executing operation pingMe, throwing PingMeFault exception\n");
+        throw new PingMeFault("PingMeFault raised by server" + suffix, faultDetail);
+    }
+
+
+}

Propchange: activemq/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/GreeterImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/GreeterImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: activemq/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/ReaderToStringProcessor.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/ReaderToStringProcessor.java?rev=615759&view=auto
==============================================================================
--- activemq/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/ReaderToStringProcessor.java
(added)
+++ activemq/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/ReaderToStringProcessor.java
Mon Jan 28 00:37:55 2008
@@ -0,0 +1,33 @@
+/**
+ * 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.example.camel.transport;
+
+import java.io.Reader;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.cxf.helpers.IOUtils;
+
+public class ReaderToStringProcessor implements Processor {
+
+    public void process(Exchange exchange) throws Exception {
+        String result = IOUtils.toString((Reader)exchange.getIn().getBody());
+        System.out.println("get the request message" + result);
+        // need to turn this thing into stream
+        exchange.getIn().setBody("");
+    }
+}

Propchange: activemq/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/ReaderToStringProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/ReaderToStringProcessor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: activemq/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/Server.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/Server.java?rev=615759&view=auto
==============================================================================
--- activemq/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/Server.java
(added)
+++ activemq/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/Server.java
Mon Jan 28 00:37:55 2008
@@ -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.example.camel.transport;
+
+import javax.xml.ws.Endpoint;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+
+public class Server {
+    Endpoint endpointA;
+    Endpoint endpointB;
+
+    public void prepare() throws Exception {
+        // setup the camel context for the camel transport
+        SpringBusFactory bf = new SpringBusFactory();
+        BusFactory.setDefaultBus(null);
+        Bus bus = bf.createBus("/org/apache/camel/example/camel/transport/CamelDestination.xml");
+        BusFactory.setDefaultBus(bus);
+    }
+
+    public void start() throws Exception {
+        // start the endpoints
+        System.out.println("Starting Server");
+        Object implementor = new GreeterImpl("EndpointA");
+        String address = "camel://direct:EndpointA";
+        endpointA = Endpoint.publish(address, implementor);
+
+        implementor = new GreeterImpl("EndpointB");
+        address = "camel://direct:EndpointB";
+        endpointB = Endpoint.publish(address, implementor);
+    }
+
+    public void stop() {
+        if (endpointA != null) {
+            endpointA.stop();
+        }
+        if (endpointB != null) {
+            endpointB.stop();
+        }
+    }
+
+
+    public static void main(String args[]) throws Exception {
+        Server server = new Server();
+        server.prepare();
+        server.start();
+        System.out.println("Server ready...");
+
+        Thread.sleep(5 * 60 * 1000);
+        System.out.println("Server exiting");
+        server.stop();
+        System.exit(0);
+    }
+}

Propchange: activemq/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/Server.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/camel/transport/Server.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message