You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by dk...@apache.org on 2014/01/06 19:54:37 UTC
[5/9] git commit: Start investigating what it will take to get Camel
working with CXF 3. camel-cxf-transport now works with either 2.7 or 3
Start investigating what it will take to get Camel working with CXF 3. camel-cxf-transport now works with either 2.7 or 3
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/ec2f4c31
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/ec2f4c31
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/ec2f4c31
Branch: refs/heads/master
Commit: ec2f4c31c1bd833b947d1a0dc1125dde0c8b7ac8
Parents: 6f74500
Author: Daniel Kulp <dk...@apache.org>
Authored: Fri Jan 3 16:30:03 2014 -0500
Committer: Daniel Kulp <dk...@apache.org>
Committed: Mon Jan 6 10:14:15 2014 -0500
----------------------------------------------------------------------
components/camel-cxf-transport/pom.xml | 5 --
.../cxf/transport/CamelDestination.java | 5 +-
.../cxf/transport/CamelTransportFactory.java | 87 +++++++++++++++++---
.../cxf/transport/CamelDestinationTest.java | 8 +-
parent/pom.xml | 4 +-
5 files changed, 85 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/ec2f4c31/components/camel-cxf-transport/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-cxf-transport/pom.xml b/components/camel-cxf-transport/pom.xml
index 138a582..966e5e7 100644
--- a/components/camel-cxf-transport/pom.xml
+++ b/components/camel-cxf-transport/pom.xml
@@ -64,11 +64,6 @@
<artifactId>camel-core</artifactId>
</dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-core</artifactId>
- </dependency>
-
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-bindings-soap</artifactId>
http://git-wip-us.apache.org/repos/asf/camel/blob/ec2f4c31/components/camel-cxf-transport/src/main/java/org/apache/camel/component/cxf/transport/CamelDestination.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf-transport/src/main/java/org/apache/camel/component/cxf/transport/CamelDestination.java b/components/camel-cxf-transport/src/main/java/org/apache/camel/component/cxf/transport/CamelDestination.java
index 4b3d142..7dbc65d 100644
--- a/components/camel-cxf-transport/src/main/java/org/apache/camel/component/cxf/transport/CamelDestination.java
+++ b/components/camel-cxf-transport/src/main/java/org/apache/camel/component/cxf/transport/CamelDestination.java
@@ -45,7 +45,6 @@ import org.apache.cxf.transport.Conduit;
import org.apache.cxf.transport.ConduitInitiator;
import org.apache.cxf.transport.MessageObserver;
import org.apache.cxf.ws.addressing.EndpointReferenceType;
-import org.apache.cxf.wsdl.EndpointReferenceUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -195,13 +194,13 @@ public class CamelDestination extends AbstractDestination implements Configurabl
}
// this should deal with the cxf message
- protected class BackChannelConduit extends AbstractConduit {
+ protected class BackChannelConduit extends AbstractBackChannelConduit {
protected Message inMessage;
Exchange camelExchange;
org.apache.cxf.message.Exchange cxfExchange;
BackChannelConduit(Message message) {
- super(EndpointReferenceUtils.getAnonymousEndpointReference());
+ super();
inMessage = message;
cxfExchange = inMessage.getExchange();
camelExchange = cxfExchange.get(Exchange.class);
http://git-wip-us.apache.org/repos/asf/camel/blob/ec2f4c31/components/camel-cxf-transport/src/main/java/org/apache/camel/component/cxf/transport/CamelTransportFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf-transport/src/main/java/org/apache/camel/component/cxf/transport/CamelTransportFactory.java b/components/camel-cxf-transport/src/main/java/org/apache/camel/component/cxf/transport/CamelTransportFactory.java
index d95e28a..06250d8 100644
--- a/components/camel-cxf-transport/src/main/java/org/apache/camel/component/cxf/transport/CamelTransportFactory.java
+++ b/components/camel-cxf-transport/src/main/java/org/apache/camel/component/cxf/transport/CamelTransportFactory.java
@@ -22,26 +22,27 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import javax.annotation.Resource;
-
import org.apache.camel.CamelContext;
import org.apache.camel.CamelContextAware;
import org.apache.camel.component.cxf.common.header.CxfHeaderFilterStrategy;
import org.apache.camel.spi.HeaderFilterStrategy;
import org.apache.cxf.Bus;
+import org.apache.cxf.BusException;
import org.apache.cxf.common.injection.NoJSR250Annotations;
import org.apache.cxf.service.model.EndpointInfo;
import org.apache.cxf.transport.AbstractTransportFactory;
import org.apache.cxf.transport.Conduit;
import org.apache.cxf.transport.ConduitInitiator;
+import org.apache.cxf.transport.ConduitInitiatorManager;
import org.apache.cxf.transport.Destination;
import org.apache.cxf.transport.DestinationFactory;
+import org.apache.cxf.transport.DestinationFactoryManager;
import org.apache.cxf.ws.addressing.EndpointReferenceType;
/**
* @version
*/
-@NoJSR250Annotations(unlessNull = "bus")
+@NoJSR250Annotations
public class CamelTransportFactory extends AbstractTransportFactory implements ConduitInitiator, DestinationFactory, CamelContextAware {
public static final String TRANSPORT_ID = "http://cxf.apache.org/transports/camel";
@@ -50,6 +51,7 @@ public class CamelTransportFactory extends AbstractTransportFactory implements C
private HeaderFilterStrategy headerFilterStrategy;
private boolean checkException;
+ private Bus bus;
static {
URI_PREFIXES.add("camel://");
@@ -64,18 +66,16 @@ public class CamelTransportFactory extends AbstractTransportFactory implements C
headerFilterStrategy = defaultHeaderFilterStrategy;
}
public CamelTransportFactory(Bus b) {
- super(DEFAULT_NAMESPACES, b);
+ super(DEFAULT_NAMESPACES);
+ bus = b;
+ registerFactory();
+
CxfHeaderFilterStrategy defaultHeaderFilterStrategy = new CxfHeaderFilterStrategy();
// Doesn't filter the camel relates headers by default
defaultHeaderFilterStrategy.setOutFilterPattern(null);
headerFilterStrategy = defaultHeaderFilterStrategy;
}
- @Resource(name = "cxf")
- public void setBus(Bus b) {
- super.setBus(b);
- }
-
public void setCheckException(boolean check) {
checkException = check;
}
@@ -85,15 +85,15 @@ public class CamelTransportFactory extends AbstractTransportFactory implements C
}
public Conduit getConduit(EndpointInfo targetInfo) throws IOException {
- return getConduit(targetInfo, null);
+ return getConduit(targetInfo, null, bus);
}
public Conduit getConduit(EndpointInfo endpointInfo, EndpointReferenceType target) throws IOException {
- return new CamelConduit(camelContext, bus, endpointInfo, target, headerFilterStrategy);
+ return getConduit(endpointInfo, target, bus);
}
public Destination getDestination(EndpointInfo endpointInfo) throws IOException {
- return new CamelDestination(camelContext, bus, this, endpointInfo, headerFilterStrategy, checkException);
+ return getDestination(endpointInfo, bus);
}
public Set<String> getUriPrefixes() {
@@ -114,7 +114,70 @@ public class CamelTransportFactory extends AbstractTransportFactory implements C
public void setCamelContext(CamelContext c) {
camelContext = c;
}
+ public Destination getDestination(EndpointInfo ei, Bus b) throws IOException {
+ return new CamelDestination(camelContext, b, this, ei, headerFilterStrategy, checkException);
+ }
+ public Conduit getConduit(EndpointInfo targetInfo, Bus b) throws IOException {
+ return getConduit(targetInfo, null, b);
+ }
+ public Conduit getConduit(EndpointInfo localInfo, EndpointReferenceType target, Bus b)
+ throws IOException {
+ return new CamelConduit(camelContext, b, localInfo, target, headerFilterStrategy);
+ }
+ // CXF 2.x support methods
+ public void setBus(Bus b) {
+ unregisterFactory();
+ bus = b;
+ registerFactory();
+ }
+ public final void registerFactory() {
+ if (null == bus) {
+ return;
+ }
+ DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
+ if (null != dfm && getTransportIds() != null) {
+ for (String ns : getTransportIds()) {
+ dfm.registerDestinationFactory(ns, (DestinationFactory)this);
+ }
+ }
+ ConduitInitiatorManager cim = bus.getExtension(ConduitInitiatorManager.class);
+ if (cim != null && getTransportIds() != null) {
+ for (String ns : getTransportIds()) {
+ cim.registerConduitInitiator(ns, (ConduitInitiator)this);
+ }
+ }
+ }
+
+ public final void unregisterFactory() {
+ if (null == bus) {
+ return;
+ }
+ DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
+ if (null != dfm && getTransportIds() != null) {
+ for (String ns : getTransportIds()) {
+ try {
+ if (dfm.getDestinationFactory(ns) == this) {
+ dfm.deregisterDestinationFactory(ns);
+ }
+ } catch (BusException e) {
+ //ignore
+ }
+ }
+ }
+ ConduitInitiatorManager cim = bus.getExtension(ConduitInitiatorManager.class);
+ if (cim != null && getTransportIds() != null) {
+ for (String ns : getTransportIds()) {
+ try {
+ if (cim.getConduitInitiator(ns) == this) {
+ cim.deregisterConduitInitiator(ns);
+ }
+ } catch (BusException e) {
+ //ignore
+ }
+ }
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/camel/blob/ec2f4c31/components/camel-cxf-transport/src/test/java/org/apache/camel/component/cxf/transport/CamelDestinationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf-transport/src/test/java/org/apache/camel/component/cxf/transport/CamelDestinationTest.java b/components/camel-cxf-transport/src/test/java/org/apache/camel/component/cxf/transport/CamelDestinationTest.java
index fa16524..7adcbcd 100644
--- a/components/camel-cxf-transport/src/test/java/org/apache/camel/component/cxf/transport/CamelDestinationTest.java
+++ b/components/camel-cxf-transport/src/test/java/org/apache/camel/component/cxf/transport/CamelDestinationTest.java
@@ -172,7 +172,7 @@ public class CamelDestinationTest extends CamelTransportTestSupport {
//verifyHeaders(m, outMessage);
// setup the message for
Conduit backConduit;
- backConduit = destination.getBackChannel(m, null, null);
+ backConduit = getBackChannel(destination, m);
// wait for the message to be got from the conduit
Message replyMessage = new MessageImpl();
sendoutMessage(backConduit, replyMessage, true, "HelloWorld Response");
@@ -221,7 +221,7 @@ public class CamelDestinationTest extends CamelTransportTestSupport {
//verifyHeaders(m, outMessage);
// setup the message for
Conduit backConduit;
- backConduit = destination.getBackChannel(m, null, null);
+ backConduit = getBackChannel(destination, m);
// wait for the message to be got from the conduit
Message replyMessage = new MessageImpl();
replyMessage.setContent(Exception.class, new RuntimeCamelException());
@@ -249,6 +249,10 @@ public class CamelDestinationTest extends CamelTransportTestSupport {
destination.shutdown();
}
+ private Conduit getBackChannel(CamelDestination destination, Message m) throws IOException {
+ return destination.getInbuiltBackChannel(m);
+ }
+
@Test
public void testExceptionForwardedToExchange() throws IOException {
final RuntimeException expectedException = new RuntimeException("We simulate an exception in CXF processing");
http://git-wip-us.apache.org/repos/asf/camel/blob/ec2f4c31/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index f45664a..4e4e544 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -107,8 +107,8 @@
<concurrentlinkedhashmap.version>1.4</concurrentlinkedhashmap.version>
<cobertura-maven-plugin-version>2.5.2</cobertura-maven-plugin-version>
<cxf-version>2.7.8</cxf-version>
- <cxf-version-range>[2.6,2.9)</cxf-version-range>
- <cxf-xjc-utils-version>2.6.2</cxf-xjc-utils-version>
+ <cxf-version-range>[2.6,4.0)</cxf-version-range>
+ <cxf-xjc-utils-version>2.7.0</cxf-xjc-utils-version>
<deltaspike-version>0.3-incubating</deltaspike-version>
<derby-version>10.10.1.1</derby-version>
<disruptor-version>3.2.0</disruptor-version>