You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ff...@apache.org on 2011/12/22 04:06:01 UTC
svn commit: r1222013 [1/2] - in
/servicemix/components/trunk/engines/servicemix-cxf-se: ./
src/main/java/org/apache/servicemix/cxf/
src/main/java/org/apache/servicemix/cxf/binding/
src/main/java/org/apache/servicemix/cxf/binding/jbi/ src/main/java/org/...
Author: ffang
Date: Thu Dec 22 03:06:00 2011
New Revision: 1222013
URL: http://svn.apache.org/viewvc?rev=1222013&view=rev
Log:
[SMXCOMP-917]upgrade to cxf 2.5.1
Added:
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/JBIBinding.java
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/JBIBindingConfiguration.java
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/JBIBindingFactory.java
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/JBIBindingInfo.java
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/JBIConstants.java
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/JBIFault.java
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/JBIMessage.java
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/interceptor/
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/interceptor/JBIFaultInInterceptor.java
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/interceptor/JBIFaultOutInterceptor.java
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/interceptor/JBIOperationInInterceptor.java
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/interceptor/JBIWrapperInInterceptor.java
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/interceptor/JBIWrapperOutInterceptor.java
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/spring/
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/spring/JBIBindingInfoConfigBeanDefinitionParser.java
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/spring/NamespaceHandler.java
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/transport/
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/transport/jbi/
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/transport/jbi/JBIConduit.java
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/transport/jbi/JBIConduitOutputStream.java
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/transport/jbi/JBIDestination.java
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/transport/jbi/JBIDestinationOutputStream.java
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/transport/jbi/JBIDispatcherUtil.java
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/transport/jbi/JBIMessageHelper.java
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/transport/jbi/JBITransportFactory.java
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/resources/META-INF/cxf/
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/resources/META-INF/cxf/binding/
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/resources/META-INF/cxf/binding/jbi/
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/resources/META-INF/cxf/binding/jbi/cxf-binding-jbi.xml
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/resources/META-INF/cxf/transport/
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/resources/META-INF/cxf/transport/jbi/
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/resources/META-INF/cxf/transport/jbi/cxf-transport-jbi.xml
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/resources/org/
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/resources/org/apache/
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/resources/org/apache/servicemix/
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/resources/org/apache/servicemix/cxf/
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/resources/org/apache/servicemix/cxf/binding/
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/resources/org/apache/servicemix/cxf/binding/jbi/
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/resources/org/apache/servicemix/cxf/binding/jbi/interceptor/
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/resources/org/apache/servicemix/cxf/binding/jbi/interceptor/Messages.properties
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/resources/org/apache/servicemix/cxf/transport/
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/resources/org/apache/servicemix/cxf/transport/jbi/
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/resources/org/apache/servicemix/cxf/transport/jbi/Messages.properties
Modified:
servicemix/components/trunk/engines/servicemix-cxf-se/pom.xml
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxfse/CxfSeComponent.java
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxfse/CxfSeEndpoint.java
servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxfse/CxfSeProxyFactoryBean.java
servicemix/components/trunk/engines/servicemix-cxf-se/src/test/java/org/apache/servicemix/cxfse/CxfSeClientProxyTest.java
servicemix/components/trunk/engines/servicemix-cxf-se/src/test/java/org/apache/servicemix/cxfse/GreetMeResponse.java
servicemix/components/trunk/engines/servicemix-cxf-se/src/test/java/org/apache/servicemix/cxfse/SayHiResponse.java
Modified: servicemix/components/trunk/engines/servicemix-cxf-se/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/components/trunk/engines/servicemix-cxf-se/pom.xml?rev=1222013&r1=1222012&r2=1222013&view=diff
==============================================================================
--- servicemix/components/trunk/engines/servicemix-cxf-se/pom.xml (original)
+++ servicemix/components/trunk/engines/servicemix-cxf-se/pom.xml Thu Dec 22 03:06:00 2011
@@ -41,7 +41,6 @@
!META-INF.services.org.apache.xbean.spring.http.servicemix.apache.org.cxfse,
javax.jws,
javax.xml.bind.annotation,
- org.apache.cxf.binding.jbi;version="[2.1.0,3.0.0)",
org.apache.cxf*;version="[2.1.0,3.0.0)",
org.apache.servicemix.common,
org.apache.servicemix.common.osgi,
@@ -55,8 +54,6 @@
org.springframework.beans.factory.config,
sun.misc;resolution:=optional,
META-INF.cxf,
- META-INF.cxf.transport.jbi,
- META-INF.cxf.binding.jbi,
*
</servicemix.osgi.import>
<servicemix.osgi.export>
@@ -65,8 +62,6 @@
</servicemix.osgi.export>
<servicemix.osgi.bundles>
org.apache.cxf.bundle,
- org.apache.cxf.rt-bindings-jbi,
- org.apache.cxf.rt-transports-jbi,
org.springframework.core,
org.springframework.beans,
org.springframework.context,
@@ -80,17 +75,6 @@
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-bindings-jbi</artifactId>
- <version>${cxf.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.apache.servicemix</groupId>
- <artifactId>servicemix-jbi</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-databinding-aegis</artifactId>
<version>${cxf.version}</version>
</dependency>
@@ -106,17 +90,6 @@
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-transports-jbi</artifactId>
- <version>${cxf.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.apache.servicemix</groupId>
- <artifactId>servicemix-jbi</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf.version}</version>
</dependency>
Added: servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/JBIBinding.java
URL: http://svn.apache.org/viewvc/servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/JBIBinding.java?rev=1222013&view=auto
==============================================================================
--- servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/JBIBinding.java (added)
+++ servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/JBIBinding.java Thu Dec 22 03:06:00 2011
@@ -0,0 +1,50 @@
+/**
+ * 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.servicemix.cxf.binding.jbi;
+
+import org.apache.cxf.binding.Binding;
+import org.apache.cxf.interceptor.AbstractBasicInterceptorProvider;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageImpl;
+import org.apache.cxf.service.model.BindingInfo;
+
+public class JBIBinding extends AbstractBasicInterceptorProvider implements Binding {
+
+ private JBIBindingInfo bindingInfo;
+
+ public JBIBinding(JBIBindingInfo bindingInfo) {
+ this.bindingInfo = bindingInfo;
+ }
+
+ public Message createMessage() {
+ return createMessage(new MessageImpl());
+ }
+
+ public Message createMessage(Message m) {
+ if (!m.containsKey(Message.CONTENT_TYPE)) {
+ m.put(Message.CONTENT_TYPE, "text/xml");
+ }
+ return new JBIMessage(m);
+ }
+
+ public BindingInfo getBindingInfo() {
+ return bindingInfo;
+ }
+
+}
Added: servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/JBIBindingConfiguration.java
URL: http://svn.apache.org/viewvc/servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/JBIBindingConfiguration.java?rev=1222013&view=auto
==============================================================================
--- servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/JBIBindingConfiguration.java (added)
+++ servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/JBIBindingConfiguration.java Thu Dec 22 03:06:00 2011
@@ -0,0 +1,41 @@
+/**
+ * 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.servicemix.cxf.binding.jbi;
+
+import org.apache.cxf.binding.BindingConfiguration;
+
+public class JBIBindingConfiguration extends BindingConfiguration {
+
+ // set the MTOM and other configuration here
+ private boolean mtomEnabled;
+
+ @Override
+ public String getBindingId() {
+ return JBIConstants.NS_JBI_BINDING;
+ }
+
+ public boolean isMtomEnabled() {
+ return mtomEnabled;
+ }
+
+ public void setMtomEnabled(boolean flag) {
+ mtomEnabled = flag;
+ }
+
+}
Added: servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/JBIBindingFactory.java
URL: http://svn.apache.org/viewvc/servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/JBIBindingFactory.java?rev=1222013&view=auto
==============================================================================
--- servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/JBIBindingFactory.java (added)
+++ servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/JBIBindingFactory.java Thu Dec 22 03:06:00 2011
@@ -0,0 +1,98 @@
+/**
+ * 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.servicemix.cxf.binding.jbi;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.binding.AbstractBindingFactory;
+import org.apache.cxf.binding.Binding;
+import org.apache.servicemix.cxf.binding.jbi.interceptor.JBIFaultInInterceptor;
+import org.apache.servicemix.cxf.binding.jbi.interceptor.JBIFaultOutInterceptor;
+import org.apache.servicemix.cxf.binding.jbi.interceptor.JBIOperationInInterceptor;
+import org.apache.servicemix.cxf.binding.jbi.interceptor.JBIWrapperInInterceptor;
+import org.apache.servicemix.cxf.binding.jbi.interceptor.JBIWrapperOutInterceptor;
+import org.apache.cxf.common.injection.NoJSR250Annotations;
+import org.apache.cxf.interceptor.AttachmentInInterceptor;
+import org.apache.cxf.interceptor.AttachmentOutInterceptor;
+import org.apache.cxf.interceptor.StaxInInterceptor;
+import org.apache.cxf.interceptor.StaxOutInterceptor;
+import org.apache.cxf.service.model.BindingInfo;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.service.model.OperationInfo;
+import org.apache.cxf.service.model.ServiceInfo;
+
+@NoJSR250Annotations(unlessNull = { "bus" })
+public class JBIBindingFactory extends AbstractBindingFactory {
+ public static final Collection<String> DEFAULT_NAMESPACES
+ = Arrays.asList("http://cxf.apache.org/bindings/jbi",
+ "http://java.sun.com/xml/ns/jbi/binding/service+engine");
+
+ public JBIBindingFactory() {
+ }
+ public JBIBindingFactory(Bus b) {
+ super(b, DEFAULT_NAMESPACES);
+ }
+
+ public Binding createBinding(BindingInfo binding) {
+ JBIBindingInfo bindingInfo = (JBIBindingInfo) binding;
+ JBIBinding jb = new JBIBinding(bindingInfo);
+
+ jb.getInInterceptors().add(new StaxInInterceptor());
+ jb.getInInterceptors().add(new JBIOperationInInterceptor());
+ jb.getInInterceptors().add(new JBIWrapperInInterceptor());
+ jb.getOutInterceptors().add(new StaxOutInterceptor());
+ jb.getOutInterceptors().add(new JBIWrapperOutInterceptor());
+ jb.getOutFaultInterceptors().add(new StaxOutInterceptor());
+ jb.getOutFaultInterceptors().add(new JBIFaultOutInterceptor());
+
+ jb.getInFaultInterceptors().add(new JBIFaultInInterceptor());
+
+ if (bindingInfo.getJBIBindingConfiguration().isMtomEnabled()) {
+ jb.getInInterceptors().add(new AttachmentInInterceptor());
+ jb.getOutInterceptors().add(new AttachmentOutInterceptor());
+ }
+ return jb;
+ }
+
+ public BindingInfo createBindingInfo(ServiceInfo service, String namespace, Object config) {
+ JBIBindingConfiguration configuration;
+ if (config instanceof JBIBindingConfiguration) {
+ configuration = (JBIBindingConfiguration) config;
+ } else {
+ configuration = new JBIBindingConfiguration();
+ }
+ JBIBindingInfo info = new JBIBindingInfo(service, JBIConstants.NS_JBI_BINDING);
+ info.setJBIBindingConfiguration(configuration);
+ info.setName(new QName(service.getName().getNamespaceURI(),
+ service.getName().getLocalPart() + "JBIBinding"));
+
+ for (OperationInfo op : service.getInterface().getOperations()) {
+ BindingOperationInfo bop =
+ info.buildOperation(op.getName(), op.getInputName(), op.getOutputName());
+ info.addOperation(bop);
+ }
+
+ return info;
+ }
+
+}
Added: servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/JBIBindingInfo.java
URL: http://svn.apache.org/viewvc/servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/JBIBindingInfo.java?rev=1222013&view=auto
==============================================================================
--- servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/JBIBindingInfo.java (added)
+++ servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/JBIBindingInfo.java Thu Dec 22 03:06:00 2011
@@ -0,0 +1,42 @@
+/**
+ * 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.servicemix.cxf.binding.jbi;
+
+import org.apache.cxf.service.model.BindingInfo;
+import org.apache.cxf.service.model.ServiceInfo;
+
+public class JBIBindingInfo extends BindingInfo {
+ private JBIBindingConfiguration configuration;
+
+ public JBIBindingInfo(ServiceInfo service, String bindingId) {
+ super(service, bindingId);
+ }
+
+ public void setJBIBindingConfiguration(JBIBindingConfiguration conf) {
+ configuration = conf;
+ }
+
+ public JBIBindingConfiguration getJBIBindingConfiguration() {
+ if (configuration == null) {
+ configuration = new JBIBindingConfiguration();
+ }
+ return configuration;
+ }
+
+}
Added: servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/JBIConstants.java
URL: http://svn.apache.org/viewvc/servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/JBIConstants.java?rev=1222013&view=auto
==============================================================================
--- servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/JBIConstants.java (added)
+++ servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/JBIConstants.java Thu Dec 22 03:06:00 2011
@@ -0,0 +1,37 @@
+/**
+ * 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.servicemix.cxf.binding.jbi;
+
+import javax.xml.namespace.QName;
+
+
+public final class JBIConstants {
+
+ public static final String NS_JBI_BINDING = "http://cxf.apache.org/bindings/jbi";
+
+ public static final String NS_JBI_WRAPPER = "http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper";
+
+ public static final QName JBI_WRAPPER_MESSAGE = new QName(NS_JBI_WRAPPER, "message");
+
+ public static final QName JBI_WRAPPER_PART = new QName(NS_JBI_WRAPPER, "part");
+
+ private JBIConstants() {
+ //utility class
+ }
+}
Added: servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/JBIFault.java
URL: http://svn.apache.org/viewvc/servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/JBIFault.java?rev=1222013&view=auto
==============================================================================
--- servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/JBIFault.java (added)
+++ servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/JBIFault.java Thu Dec 22 03:06:00 2011
@@ -0,0 +1,64 @@
+/**
+ * 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.servicemix.cxf.binding.jbi;
+
+import java.util.ResourceBundle;
+
+import org.apache.cxf.common.i18n.Message;
+import org.apache.cxf.interceptor.Fault;
+
+public class JBIFault extends Fault {
+ public static final String JBI_FAULT_PREFIX = "jfns";
+
+ public static final String JBI_FAULT_ROOT = "JBIFault";
+ public static final String JBI_FAULT_STRING = "faultstring";
+
+ public static final String JBI_FAULT_DETAIL = "detail";
+
+ public static final String JBI_FAULT_CODE_SERVER = "SERVER";
+
+ public static final String JBI_FAULT_CODE_CLIENT = "CLIENT";
+
+
+ static final long serialVersionUID = 100000;
+
+ public JBIFault(Message message, Throwable throwable) {
+ super(message, throwable);
+ }
+
+ public JBIFault(Message message) {
+ super(message);
+ }
+
+ public JBIFault(String message) {
+ super(new Message(message, (ResourceBundle) null));
+ }
+
+ public static JBIFault createFault(Fault f) {
+ if (f instanceof JBIFault) {
+ return (JBIFault) f;
+ }
+ Throwable th = f.getCause();
+ JBIFault jbiFault = new JBIFault(new Message(f.getMessage(), (ResourceBundle) null), th);
+ jbiFault.setDetail(f.getDetail());
+ return jbiFault;
+ }
+
+}
Added: servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/JBIMessage.java
URL: http://svn.apache.org/viewvc/servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/JBIMessage.java?rev=1222013&view=auto
==============================================================================
--- servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/JBIMessage.java (added)
+++ servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/JBIMessage.java Thu Dec 22 03:06:00 2011
@@ -0,0 +1,36 @@
+/**
+ * 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.servicemix.cxf.binding.jbi;
+
+import javax.jbi.messaging.MessageExchange;
+
+import org.apache.cxf.message.AbstractWrappedMessage;
+import org.apache.cxf.message.Message;
+
+public class JBIMessage extends AbstractWrappedMessage {
+
+ public JBIMessage(Message msg) {
+ super(msg);
+ }
+
+ public MessageExchange getJbiExchange() {
+ return get(MessageExchange.class);
+ }
+
+}
Added: servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/interceptor/JBIFaultInInterceptor.java
URL: http://svn.apache.org/viewvc/servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/interceptor/JBIFaultInInterceptor.java?rev=1222013&view=auto
==============================================================================
--- servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/interceptor/JBIFaultInInterceptor.java (added)
+++ servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/interceptor/JBIFaultInInterceptor.java Thu Dec 22 03:06:00 2011
@@ -0,0 +1,75 @@
+/**
+ * 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.servicemix.cxf.binding.jbi.interceptor;
+
+import java.util.ResourceBundle;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.w3c.dom.Element;
+
+
+
+import org.apache.servicemix.cxf.binding.jbi.JBIFault;
+import org.apache.servicemix.cxf.binding.jbi.JBIMessage;
+import org.apache.cxf.common.i18n.BundleUtils;
+
+
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.staxutils.DepthXMLStreamReader;
+import org.apache.cxf.staxutils.FragmentStreamReader;
+import org.apache.cxf.staxutils.StaxUtils;
+
+
+public class JBIFaultInInterceptor extends AbstractPhaseInterceptor<JBIMessage> {
+
+ private static final ResourceBundle BUNDLE = BundleUtils.getBundle(JBIFaultInInterceptor.class);
+ public JBIFaultInInterceptor() {
+ super(Phase.UNMARSHAL);
+ addBefore("*");
+ }
+
+ public void handleMessage(JBIMessage message) throws Fault {
+ XMLStreamReader xsr = message.getContent(XMLStreamReader.class);
+ DepthXMLStreamReader reader = new DepthXMLStreamReader(xsr);
+
+ try {
+
+ if (!StaxUtils.toNextElement(reader)) {
+ throw new Fault(new org.apache.cxf.common.i18n.Message("ILLEGAL_JBIFAULT_FORMAT", BUNDLE));
+ }
+ Fault fault = new JBIFault(new org.apache.cxf.common.i18n.Message(JBIFault.JBI_FAULT_STRING,
+ (ResourceBundle) null));
+
+ if (StaxUtils.toNextElement(reader)) {
+ // handling detail
+ Element detail = StaxUtils.read(new FragmentStreamReader(reader)).getDocumentElement();
+ fault.setDetail(detail);
+ }
+ message.setContent(Exception.class, fault);
+ } catch (XMLStreamException xse) {
+ throw new Fault(new org.apache.cxf.common.i18n.Message("STAX_READ_EXC", BUNDLE));
+ }
+
+ }
+}
Added: servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/interceptor/JBIFaultOutInterceptor.java
URL: http://svn.apache.org/viewvc/servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/interceptor/JBIFaultOutInterceptor.java?rev=1222013&view=auto
==============================================================================
--- servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/interceptor/JBIFaultOutInterceptor.java (added)
+++ servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/interceptor/JBIFaultOutInterceptor.java Thu Dec 22 03:06:00 2011
@@ -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.servicemix.cxf.binding.jbi.interceptor;
+
+import java.util.ResourceBundle;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.w3c.dom.Element;
+
+import org.apache.servicemix.cxf.binding.jbi.JBIConstants;
+import org.apache.servicemix.cxf.binding.jbi.JBIFault;
+import org.apache.servicemix.cxf.binding.jbi.JBIMessage;
+import org.apache.cxf.common.i18n.BundleUtils;
+import org.apache.cxf.common.i18n.Message;
+import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.helpers.NSStack;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.staxutils.StaxUtils;
+
+public class JBIFaultOutInterceptor extends AbstractPhaseInterceptor<JBIMessage> {
+
+ private static final ResourceBundle BUNDLE = BundleUtils.getBundle(JBIFaultOutInterceptor.class);
+
+ public JBIFaultOutInterceptor() {
+ super(Phase.MARSHAL);
+ }
+
+ public void handleMessage(JBIMessage message) throws Fault {
+ message.put(org.apache.cxf.message.Message.RESPONSE_CODE, new Integer(500));
+ NSStack nsStack = new NSStack();
+ nsStack.push();
+
+
+
+ try {
+ XMLStreamWriter writer = getWriter(message);
+ Fault fault = getFault(message);
+ JBIFault jbiFault = JBIFault.createFault(fault);
+ nsStack.add(JBIConstants.NS_JBI_BINDING);
+ String prefix = nsStack.getPrefix(JBIConstants.NS_JBI_BINDING);
+ StaxUtils.writeStartElement(writer, prefix, JBIFault.JBI_FAULT_ROOT,
+ JBIConstants.NS_JBI_BINDING);
+ if (!jbiFault.hasDetails()) {
+ Element faultString = DOMUtils.createDocument().createElement("fault");
+ faultString.setTextContent(jbiFault.getCause().getMessage());
+ StaxUtils.writeNode(faultString, writer, true);
+ } else {
+ Element detail = jbiFault.getDetail();
+ Element elem = DOMUtils.getFirstElement(detail);
+ if (elem != null) {
+ StaxUtils.writeNode(elem, writer, true);
+ }
+ }
+ writer.writeEndElement();
+ writer.flush();
+
+ } catch (XMLStreamException xe) {
+ throw new Fault(new Message("XML_WRITE_EXC", BUNDLE), xe);
+ }
+ }
+
+ protected Fault getFault(JBIMessage message) {
+ Exception e = message.getContent(Exception.class);
+ Fault fault;
+ if (e == null) {
+ throw new IllegalStateException(new Message("NO_EXCEPTION", BUNDLE).toString());
+ } else if (e instanceof Fault) {
+ fault = (Fault) e;
+ } else {
+ fault = new Fault(e);
+ }
+ return fault;
+ }
+
+ protected XMLStreamWriter getWriter(JBIMessage message) {
+ XMLStreamWriter writer = message.getContent(XMLStreamWriter.class);
+ if (writer == null) {
+ throw new IllegalStateException(new Message("NO_XML_STREAM_WRITER", BUNDLE).toString());
+ }
+ return writer;
+ }
+}
Added: servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/interceptor/JBIOperationInInterceptor.java
URL: http://svn.apache.org/viewvc/servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/interceptor/JBIOperationInInterceptor.java?rev=1222013&view=auto
==============================================================================
--- servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/interceptor/JBIOperationInInterceptor.java (added)
+++ servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/interceptor/JBIOperationInInterceptor.java Thu Dec 22 03:06:00 2011
@@ -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.servicemix.cxf.binding.jbi.interceptor;
+
+import java.util.ResourceBundle;
+import java.util.logging.Logger;
+
+import javax.xml.namespace.QName;
+
+import org.apache.servicemix.cxf.binding.jbi.JBIMessage;
+import org.apache.cxf.common.i18n.Message;
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.service.model.BindingInfo;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.service.model.MessageInfo;
+import org.apache.cxf.service.model.OperationInfo;
+
+public class JBIOperationInInterceptor extends AbstractPhaseInterceptor<JBIMessage> {
+
+ private static final Logger LOG = LogUtils.getL7dLogger(JBIOperationInInterceptor.class);
+
+ private static final ResourceBundle BUNDLE = LOG.getResourceBundle();
+
+ public JBIOperationInInterceptor() {
+ super(Phase.PRE_PROTOCOL_FRONTEND);
+ }
+
+ public void handleMessage(JBIMessage message) throws Fault {
+ Exchange ex = message.getExchange();
+ Endpoint ep = ex.get(Endpoint.class);
+ BindingOperationInfo boi = ex.get(BindingOperationInfo.class);
+ if (boi == null) {
+ if (message.getJbiExchange().getOperation() != null) {
+ BindingInfo service = ep.getEndpointInfo().getBinding();
+ boi = getBindingOperationInfo(service, message.getJbiExchange().getOperation());
+ if (boi == null) {
+ throw new Fault(new Message("UNKNOWN_OPERATION", BUNDLE,
+ message.getJbiExchange().getOperation().toString()));
+ }
+
+ } else {
+ throw new Fault(new Message("UNKNOWN_OPERATION", BUNDLE,
+ message.getJbiExchange().getInterfaceName().toString()));
+ }
+ ex.put(BindingOperationInfo.class, boi);
+ ex.put(OperationInfo.class, boi.getOperationInfo());
+ ex.setOneWay(boi.getOperationInfo().isOneWay());
+ message.put(MessageInfo.class, boi.getInput().getMessageInfo());
+ }
+
+ }
+
+ protected BindingOperationInfo getBindingOperationInfo(BindingInfo service, QName operation) {
+ return service.getOperation(operation);
+ }
+
+}
Added: servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/interceptor/JBIWrapperInInterceptor.java
URL: http://svn.apache.org/viewvc/servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/interceptor/JBIWrapperInInterceptor.java?rev=1222013&view=auto
==============================================================================
--- servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/interceptor/JBIWrapperInInterceptor.java (added)
+++ servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/interceptor/JBIWrapperInInterceptor.java Thu Dec 22 03:06:00 2011
@@ -0,0 +1,246 @@
+/**
+ * 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.servicemix.cxf.binding.jbi.interceptor;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.List;
+import java.util.ResourceBundle;
+import java.util.logging.Logger;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.servicemix.cxf.binding.jbi.JBIBindingInfo;
+import org.apache.servicemix.cxf.binding.jbi.JBIConstants;
+import org.apache.servicemix.cxf.binding.jbi.JBIFault;
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.databinding.DataReader;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.interceptor.AbstractInDatabindingInterceptor;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageContentsList;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.service.model.BindingInfo;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.service.model.MessageInfo;
+import org.apache.cxf.service.model.MessagePartInfo;
+import org.apache.cxf.service.model.OperationInfo;
+import org.apache.cxf.service.model.ServiceInfo;
+import org.apache.cxf.staxutils.DepthXMLStreamReader;
+import org.apache.cxf.staxutils.StaxUtils;
+
+public class JBIWrapperInInterceptor extends AbstractInDatabindingInterceptor {
+
+ private static final Logger LOG = LogUtils
+ .getL7dLogger(JBIWrapperInInterceptor.class);
+
+ private static final ResourceBundle BUNDLE = LOG.getResourceBundle();
+
+ public JBIWrapperInInterceptor() {
+ super(Phase.UNMARSHAL);
+ }
+
+ public void handleMessage(Message message) throws Fault {
+ if (isGET(message)) {
+ LOG.fine("JbiMessageInInterceptor skipped in HTTP GET method");
+ return;
+ }
+ XMLStreamReader xsr = message.getContent(XMLStreamReader.class);
+
+ DepthXMLStreamReader reader = new DepthXMLStreamReader(xsr);
+
+ Endpoint ep = message.getExchange().get(Endpoint.class);
+ BindingInfo binding = ep.getEndpointInfo().getBinding();
+ if (!(binding instanceof JBIBindingInfo)) {
+ throw new IllegalStateException(
+ new org.apache.cxf.common.i18n.Message("NEED_JBIBINDING",
+ BUNDLE).toString());
+ }
+
+ if (!StaxUtils.toNextElement(reader)) {
+ throw new Fault(new org.apache.cxf.common.i18n.Message(
+ "NO_OPERATION_ELEMENT", BUNDLE));
+ }
+
+ Exchange ex = message.getExchange();
+ QName startQName = reader.getName();
+
+ // handling jbi fault message
+ if (startQName.getLocalPart().equals(JBIFault.JBI_FAULT_ROOT)) {
+ message.getInterceptorChain().abort();
+
+ if (ep.getInFaultObserver() != null) {
+ ep.getInFaultObserver().onMessage(message);
+ return;
+ }
+ }
+
+ // handling xml normal inbound message
+ if (!startQName.equals(JBIConstants.JBI_WRAPPER_MESSAGE)) {
+ throw new Fault(new org.apache.cxf.common.i18n.Message(
+ "NO_JBI_MESSAGE_ELEMENT", BUNDLE));
+ }
+
+ try {
+
+ BindingOperationInfo bop = ex.get(BindingOperationInfo.class);
+ DataReader<XMLStreamReader> dr = getDataReader(message);
+ boolean requestor = isRequestor(message);
+ MessageContentsList parameters = new MessageContentsList();
+ reader.next();
+ ServiceInfo si = bop.getBinding().getService();
+ MessageInfo msgInfo = setMessage(message, bop, requestor, si);
+
+ message.put(MessageInfo.class, msgInfo);
+ if (!bop.isUnwrappedCapable()) {
+ for (MessagePartInfo part : msgInfo.getMessageParts()) {
+ readJBIWrapper(reader);
+ if (part.isElement()) {
+ reader.next();
+ if (!StaxUtils.toNextElement(reader)) {
+ throw new Fault(
+ new org.apache.cxf.common.i18n.Message(
+ "EXPECTED_ELEMENT_IN_PART", BUNDLE));
+ }
+ }
+ parameters.put(part, dr.read(part, reader));
+ // skip end element
+ if (part.isElement()) {
+ reader.next();
+ }
+ }
+ int ev = reader.getEventType();
+ while (ev != XMLStreamConstants.END_ELEMENT
+ && ev != XMLStreamConstants.START_ELEMENT
+ && ev != XMLStreamConstants.END_DOCUMENT) {
+ ev = reader.next();
+ }
+ } else if (bop.isUnwrappedCapable()
+ && msgInfo.getMessageParts().get(0).getTypeClass() != null) {
+ readJBIWrapper(reader);
+ if (msgInfo.getMessageParts().get(0).isElement()) {
+ reader.next();
+ if (!StaxUtils.toNextElement(reader)) {
+ throw new Fault(
+ new org.apache.cxf.common.i18n.Message(
+ "EXPECTED_ELEMENT_IN_PART", BUNDLE));
+ }
+ }
+ Object wrappedObject = dr.read(
+ msgInfo.getMessageParts().get(0), xsr);
+ parameters.put(msgInfo.getMessageParts().get(0), wrappedObject);
+
+ } else {
+ if (bop.isUnwrappedCapable()) {
+ bop = bop.getUnwrappedOperation();
+ }
+
+ msgInfo = setMessage(message, bop, requestor, si);
+ message.put(MessageInfo.class, msgInfo);
+ for (MessagePartInfo part : msgInfo.getMessageParts()) {
+ readJBIWrapper(reader);
+ if (part.isElement()) {
+ reader.next();
+ reader.next();
+ if (!StaxUtils.toNextElement(reader)) {
+ throw new Fault(
+ new org.apache.cxf.common.i18n.Message(
+ "EXPECTED_ELEMENT_IN_PART", BUNDLE));
+ }
+ }
+ parameters.put(part, dr.read(part, reader));
+ // skip end element
+ if (part.isElement()) {
+ reader.next();
+ }
+ }
+ int ev = reader.getEventType();
+ while (ev != XMLStreamConstants.END_ELEMENT
+ && ev != XMLStreamConstants.START_ELEMENT
+ && ev != XMLStreamConstants.END_DOCUMENT) {
+ ev = reader.next();
+ }
+ }
+ message.setContent(List.class, parameters);
+ } catch (XMLStreamException e) {
+ throw new Fault(new org.apache.cxf.common.i18n.Message(
+ "STAX_READ_EXC", BUNDLE), e);
+ }
+
+ }
+
+ private void readJBIWrapper(DepthXMLStreamReader reader) throws XMLStreamException {
+ QName startQName;
+ if (!StaxUtils.skipToStartOfElement(reader)) {
+ throw new Fault(new org.apache.cxf.common.i18n.Message(
+ "NOT_ENOUGH_PARTS", BUNDLE));
+ }
+ startQName = reader.getName();
+ if (!startQName.equals(JBIConstants.JBI_WRAPPER_PART)) {
+ throw new Fault(new org.apache.cxf.common.i18n.Message(
+ "NO_JBI_PART_ELEMENT", BUNDLE));
+ }
+ }
+
+
+
+ private MessageInfo setMessage(Message message,
+ BindingOperationInfo operation, boolean requestor, ServiceInfo si) {
+ MessageInfo msgInfo = getMessageInfo(message, operation, requestor);
+ message.put(MessageInfo.class, msgInfo);
+
+ message.getExchange().put(BindingOperationInfo.class, operation);
+ message.getExchange().put(OperationInfo.class,
+ operation.getOperationInfo());
+ message.getExchange()
+ .setOneWay(operation.getOperationInfo().isOneWay());
+
+ // Set standard MessageContext properties required by JAX_WS, but not
+ // specific to JAX_WS.
+ message.put(Message.WSDL_OPERATION, operation.getName());
+
+ QName serviceQName = si.getName();
+ message.put(Message.WSDL_SERVICE, serviceQName);
+
+ QName interfaceQName = si.getInterface().getName();
+ message.put(Message.WSDL_INTERFACE, interfaceQName);
+
+ EndpointInfo endpointInfo = message.getExchange().get(Endpoint.class)
+ .getEndpointInfo();
+ QName portQName = endpointInfo.getName();
+ message.put(Message.WSDL_PORT, portQName);
+
+ String address = endpointInfo.getAddress();
+ URI wsdlDescription = null;
+ try {
+ wsdlDescription = new URI(address + "?wsdl");
+ } catch (URISyntaxException e) {
+ // do nothing
+ }
+ message.put(Message.WSDL_DESCRIPTION, wsdlDescription);
+
+ return msgInfo;
+ }
+}
Added: servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/interceptor/JBIWrapperOutInterceptor.java
URL: http://svn.apache.org/viewvc/servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/interceptor/JBIWrapperOutInterceptor.java?rev=1222013&view=auto
==============================================================================
--- servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/interceptor/JBIWrapperOutInterceptor.java (added)
+++ servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/interceptor/JBIWrapperOutInterceptor.java Thu Dec 22 03:06:00 2011
@@ -0,0 +1,175 @@
+/**
+ * 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.servicemix.cxf.binding.jbi.interceptor;
+
+import java.util.List;
+import java.util.ResourceBundle;
+import java.util.logging.Logger;
+
+import javax.xml.XMLConstants;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.servicemix.cxf.binding.jbi.JBIConstants;
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.databinding.DataWriter;
+import org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.service.Service;
+import org.apache.cxf.service.model.BindingMessageInfo;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.service.model.MessageInfo;
+import org.apache.cxf.service.model.MessagePartInfo;
+import org.apache.cxf.staxutils.StaxUtils;
+
+public class JBIWrapperOutInterceptor extends AbstractOutDatabindingInterceptor {
+
+ private static final Logger LOG = LogUtils.getL7dLogger(JBIWrapperOutInterceptor.class);
+
+ private static final ResourceBundle BUNDLE = LOG.getResourceBundle();
+
+ public JBIWrapperOutInterceptor() {
+ super(Phase.MARSHAL);
+ }
+
+ public void handleMessage(Message message) throws Fault {
+ BindingOperationInfo bop = message.getExchange().get(BindingOperationInfo.class);
+ XMLStreamWriter xmlWriter = getXMLStreamWriter(message);
+ Service service = message.getExchange().get(Service.class);
+
+ DataWriter<XMLStreamWriter> dataWriter = getDataWriter(message, service, XMLStreamWriter.class);
+
+ try {
+ xmlWriter.setPrefix("jbi", JBIConstants.NS_JBI_WRAPPER);
+ xmlWriter.writeStartElement(JBIConstants.NS_JBI_WRAPPER,
+ JBIConstants.JBI_WRAPPER_MESSAGE.getLocalPart());
+ xmlWriter.writeNamespace("jbi", JBIConstants.NS_JBI_WRAPPER);
+ setTypeAttr(xmlWriter, message);
+ List<MessagePartInfo> parts = null;
+
+ if (!isRequestor(message)) {
+ parts = bop.getOutput().getMessageParts();
+ } else {
+ parts = bop.getInput().getMessageParts();
+ }
+ List<?> objs = (List<?>) message.getContent(List.class);
+ if (objs.size() < parts.size()) {
+ throw new Fault(new org.apache.cxf.common.i18n.Message(
+ "NOT_EQUAL_ARG_NUM", BUNDLE));
+ }
+ for (int idx = 0; idx < parts.size(); idx++) {
+ MessagePartInfo part = parts.get(idx);
+ Object obj = objs.get(part.getIndex());
+ if (!part.isElement()) {
+ if (part.getTypeClass() == String.class) {
+ xmlWriter.writeStartElement(JBIConstants.NS_JBI_WRAPPER,
+ JBIConstants.JBI_WRAPPER_PART.getLocalPart());
+ writeWrapper(message, bop, xmlWriter);
+ xmlWriter.writeCharacters(obj.toString());
+ writeWrapperEnding(bop, xmlWriter);
+ xmlWriter.writeEndElement();
+ } else {
+ part = new MessagePartInfo(part.getName(), part.getMessageInfo());
+ part.setElement(false);
+ part.setConcreteName(JBIConstants.JBI_WRAPPER_PART);
+ dataWriter.write(obj, part, xmlWriter);
+ }
+ } else {
+ xmlWriter.writeStartElement(JBIConstants.NS_JBI_WRAPPER,
+ JBIConstants.JBI_WRAPPER_PART.getLocalPart());
+ writeWrapper(message, bop, xmlWriter);
+ dataWriter.write(obj, part, xmlWriter);
+ writeWrapperEnding(bop, xmlWriter);
+ xmlWriter.writeEndElement();
+ }
+ }
+ xmlWriter.writeEndElement();
+
+
+ } catch (XMLStreamException e) {
+ throw new Fault(new org.apache.cxf.common.i18n.Message("STAX_WRITE_EXC", BUNDLE), e);
+ }
+ }
+
+ private void writeWrapperEnding(BindingOperationInfo bop, XMLStreamWriter xmlWriter)
+ throws XMLStreamException {
+ if (bop.isUnwrapped()) {
+ xmlWriter.writeEndElement();
+ }
+ }
+
+ private void writeWrapper(Message message, BindingOperationInfo bop, XMLStreamWriter xmlWriter) {
+ if (bop.isUnwrapped()) {
+ MessageInfo messageInfo;
+ if (isRequestor(message)) {
+ messageInfo = bop.getWrappedOperation().getOperationInfo().getInput();
+ } else {
+ messageInfo = bop.getWrappedOperation().getOperationInfo().getOutput();
+ }
+
+ MessagePartInfo outPart = messageInfo.getMessageParts().get(0);
+ QName name = outPart.getConcreteName();
+
+ try {
+ String pfx = StaxUtils.getUniquePrefix(xmlWriter, name.getNamespaceURI());
+ xmlWriter.setPrefix(pfx, name.getNamespaceURI());
+ xmlWriter.writeStartElement(pfx, name.getLocalPart(), name.getNamespaceURI());
+ xmlWriter.writeNamespace(pfx, name.getNamespaceURI());
+ } catch (XMLStreamException e) {
+ throw new Fault(new org.apache.cxf.common.i18n.Message("STAX_WRITE_EXC", BUNDLE), e);
+ }
+ }
+ }
+
+ private void setTypeAttr(XMLStreamWriter xmlWriter, Message message) throws XMLStreamException {
+ BindingOperationInfo wsdlOperation = getOperation(message);
+ BindingMessageInfo wsdlMessage = isRequestor(message)
+ ? wsdlOperation.getInput() : wsdlOperation.getOutput();
+
+ String typeNamespace = wsdlMessage.getMessageInfo().getName().getNamespaceURI();
+ if (typeNamespace == null || typeNamespace.length() == 0) {
+ throw new IllegalArgumentException("messageType namespace is null or empty");
+ }
+ xmlWriter.writeAttribute(XMLConstants.XMLNS_ATTRIBUTE + ":" + "msg",
+ typeNamespace);
+ String typeLocalName = wsdlMessage.getMessageInfo().getName().getLocalPart();
+ if (typeLocalName == null || typeLocalName.length() == 0) {
+ throw new IllegalArgumentException("messageType local name is null or empty");
+ }
+ xmlWriter.writeAttribute("type", "msg" + ":" + typeLocalName);
+
+ }
+
+ protected BindingOperationInfo getOperation(Message message) {
+ BindingOperationInfo operation = message.getExchange().get(BindingOperationInfo.class);
+ if (operation == null) {
+ throw new Fault(new Exception("Operation not bound on this message"));
+ }
+ return operation;
+ }
+
+ protected boolean isRequestor(org.apache.cxf.message.Message message) {
+ return Boolean.TRUE.equals(message.containsKey(
+ org.apache.cxf.message.Message.REQUESTOR_ROLE));
+ }
+
+}
Added: servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/spring/JBIBindingInfoConfigBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/spring/JBIBindingInfoConfigBeanDefinitionParser.java?rev=1222013&view=auto
==============================================================================
--- servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/spring/JBIBindingInfoConfigBeanDefinitionParser.java (added)
+++ servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/spring/JBIBindingInfoConfigBeanDefinitionParser.java Thu Dec 22 03:06:00 2011
@@ -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.servicemix.cxf.binding.jbi.spring;
+
+import org.w3c.dom.Element;
+
+import org.apache.servicemix.cxf.binding.jbi.JBIBindingConfiguration;
+import org.apache.cxf.configuration.spring.AbstractBeanDefinitionParser;
+
+public class JBIBindingInfoConfigBeanDefinitionParser extends AbstractBeanDefinitionParser {
+
+ @Override
+ protected Class getBeanClass(Element arg0) {
+ return JBIBindingConfiguration.class;
+ }
+
+}
Added: servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/spring/NamespaceHandler.java
URL: http://svn.apache.org/viewvc/servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/spring/NamespaceHandler.java?rev=1222013&view=auto
==============================================================================
--- servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/spring/NamespaceHandler.java (added)
+++ servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/binding/jbi/spring/NamespaceHandler.java Thu Dec 22 03:06:00 2011
@@ -0,0 +1,27 @@
+/**
+ * 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.servicemix.cxf.binding.jbi.spring;
+
+import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
+
+public class NamespaceHandler extends NamespaceHandlerSupport {
+ public void init() {
+ registerBeanDefinitionParser("jbiBinding", new JBIBindingInfoConfigBeanDefinitionParser());
+ }
+}
Added: servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/transport/jbi/JBIConduit.java
URL: http://svn.apache.org/viewvc/servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/transport/jbi/JBIConduit.java?rev=1222013&view=auto
==============================================================================
--- servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/transport/jbi/JBIConduit.java (added)
+++ servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/transport/jbi/JBIConduit.java Thu Dec 22 03:06:00 2011
@@ -0,0 +1,69 @@
+/**
+ * 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.servicemix.cxf.transport.jbi;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.jbi.messaging.DeliveryChannel;
+
+
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.transport.AbstractConduit;
+import org.apache.cxf.ws.addressing.EndpointReferenceType;
+
+
+public class JBIConduit extends AbstractConduit {
+
+ private static final Logger LOG = LogUtils.getL7dLogger(JBIConduit.class);
+
+ private DeliveryChannel channel;
+ private Bus bus;
+
+ public JBIConduit(EndpointReferenceType target, DeliveryChannel dc) {
+ this(null, target, dc);
+ }
+
+ public JBIConduit(Bus b, EndpointReferenceType target, DeliveryChannel dc) {
+ super(target);
+ channel = dc;
+ bus = b;
+ }
+
+ public Bus getBus() {
+ return bus;
+ }
+
+ protected Logger getLogger() {
+ return LOG;
+ }
+
+ public void prepare(Message message) throws IOException {
+ getLogger().log(Level.FINE, "JBIConduit send message");
+
+ message.setContent(OutputStream.class,
+ new JBIConduitOutputStream(message, channel, target, this));
+ }
+}
Added: servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/transport/jbi/JBIConduitOutputStream.java
URL: http://svn.apache.org/viewvc/servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/transport/jbi/JBIConduitOutputStream.java?rev=1222013&view=auto
==============================================================================
--- servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/transport/jbi/JBIConduitOutputStream.java (added)
+++ servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/transport/jbi/JBIConduitOutputStream.java Thu Dec 22 03:06:00 2011
@@ -0,0 +1,216 @@
+/**
+ * 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.servicemix.cxf.transport.jbi;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+import java.util.logging.Logger;
+
+import javax.jbi.messaging.DeliveryChannel;
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.InOut;
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessageExchangeFactory;
+import javax.jbi.messaging.NormalizedMessage;
+import javax.jws.WebService;
+import javax.xml.namespace.QName;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.helpers.CastUtils;
+import org.apache.cxf.io.CachedOutputStream;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageImpl;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.ws.addressing.EndpointReferenceType;
+import org.apache.cxf.wsdl.EndpointReferenceUtils;
+
+public class JBIConduitOutputStream extends CachedOutputStream {
+
+ private static final Logger LOG = LogUtils.getL7dLogger(JBIConduitOutputStream.class);
+
+ private Message message;
+ private boolean isOneWay;
+ private DeliveryChannel channel;
+ private JBIConduit conduit;
+ private EndpointReferenceType target;
+
+ public JBIConduitOutputStream(Message m, DeliveryChannel channel, EndpointReferenceType target,
+ JBIConduit conduit) {
+ message = m;
+ this.channel = channel;
+ this.conduit = conduit;
+ this.target = target;
+
+ }
+
+ @Override
+ protected void doFlush() throws IOException {
+
+ }
+
+ @Override
+ protected void doClose() throws IOException {
+ isOneWay = message.getExchange().isOneWay();
+ commitOutputMessage();
+ if (target != null) {
+ target.getClass();
+ }
+ }
+
+ private void commitOutputMessage() throws IOException {
+ try {
+ Member member = (Member) message.get(Method.class.getName());
+ Class<?> clz = member.getDeclaringClass();
+ Exchange exchange = message.getExchange();
+ BindingOperationInfo bop = exchange.get(BindingOperationInfo.class);
+
+ LOG.info(new org.apache.cxf.common.i18n.Message("INVOKE.SERVICE", LOG).toString() + clz);
+
+ WebService ws = clz.getAnnotation(WebService.class);
+ assert ws != null;
+ QName interfaceName = new QName(ws.targetNamespace(), ws.name());
+ QName serviceName = null;
+ if (target != null) {
+ serviceName = EndpointReferenceUtils.getServiceName(target,
+ message.getExchange().get(Bus.class));
+ } else {
+ serviceName = message.getExchange().get(org.apache.cxf.service.Service.class).getName();
+ }
+
+ MessageExchangeFactory factory = channel.createExchangeFactoryForService(serviceName);
+ LOG.info(new org.apache.cxf.common.i18n.Message("CREATE.MESSAGE.EXCHANGE", LOG).toString()
+ + serviceName);
+ MessageExchange xchng = null;
+ if (isOneWay) {
+ xchng = factory.createInOnlyExchange();
+ } else if (bop.getOutput() == null) {
+ xchng = factory.createRobustInOnlyExchange();
+ } else {
+ xchng = factory.createInOutExchange();
+ }
+
+ NormalizedMessage inMsg = xchng.createMessage();
+ LOG.info(new org.apache.cxf.common.i18n.Message("EXCHANGE.ENDPOINT", LOG).toString()
+ + xchng.getEndpoint());
+ if (inMsg != null) {
+ LOG.info("setup message contents on " + inMsg);
+ inMsg.setContent(getMessageContent(message));
+ xchng.setService(serviceName);
+ LOG.info("service for exchange " + serviceName);
+
+ xchng.setInterfaceName(interfaceName);
+
+ xchng.setOperation(bop.getName());
+ //copy context
+ Map<String, Object> invocationContext =
+ CastUtils.cast((Map)message.get(Message.INVOCATION_CONTEXT));
+ if (invocationContext != null) {
+ for (Map.Entry<String, Object> ent
+ : CastUtils.cast((Map)invocationContext.get("RequestContext"),
+ String.class, Object.class).entrySet()) {
+ // check if value is Serializable, and if value is Map
+ // or collection,
+ // just exclude it since the entry of it may not be
+ // Serializable as well
+ if (ent.getValue() instanceof Serializable
+ && !(ent.getValue() instanceof Map)
+ && !(ent.getValue() instanceof Collection)) {
+ inMsg.setProperty(ent.getKey(), ent.getValue());
+ }
+ }
+ }
+ xchng.setMessage(inMsg, "in");
+ LOG.info("sending message");
+ if (!isOneWay) {
+ channel.sendSync(xchng);
+ NormalizedMessage outMsg = ((InOut)xchng).getOutMessage();
+ Source content = null;
+ Set normalizedMessageProps = null;
+ if (outMsg != null) {
+ content = outMsg.getContent();
+ normalizedMessageProps = outMsg.getPropertyNames();
+ } else {
+ if (((InOut)xchng).getFault() == null) {
+ throw xchng.getError();
+ }
+ content = ((InOut)xchng).getFault().getContent();
+ normalizedMessageProps = ((InOut)xchng).getFault().getPropertyNames();
+ }
+ Message inMessage = new MessageImpl();
+ message.getExchange().setInMessage(inMessage);
+ InputStream ins = JBIMessageHelper.convertMessageToInputStream(content);
+ if (ins == null) {
+ throw new IOException(new org.apache.cxf.common.i18n.Message(
+ "UNABLE.RETRIEVE.MESSAGE", LOG).toString());
+ }
+ inMessage.setContent(InputStream.class, ins);
+ inMessage.put(MessageExchange.class, xchng);
+
+
+ if (normalizedMessageProps != null) {
+
+ for (Object name : normalizedMessageProps) {
+ inMessage.put((String) name, outMsg
+ .getProperty((String) name));
+
+ }
+ }
+ conduit.getMessageObserver().onMessage(inMessage);
+
+ xchng.setStatus(ExchangeStatus.DONE);
+ channel.send(xchng);
+ } else {
+ channel.send(xchng);
+ }
+
+ } else {
+ LOG.info(new org.apache.cxf.common.i18n.Message("NO.MESSAGE", LOG).toString());
+ }
+
+
+
+ } catch (IOException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new RuntimeException(e.toString());
+ }
+ }
+
+ private Source getMessageContent(Message message2) throws IOException {
+ return new StreamSource(this.getInputStream());
+
+ }
+
+ @Override
+ protected void onWrite() throws IOException {
+
+ }
+
+}
Added: servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/transport/jbi/JBIDestination.java
URL: http://svn.apache.org/viewvc/servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/transport/jbi/JBIDestination.java?rev=1222013&view=auto
==============================================================================
--- servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/transport/jbi/JBIDestination.java (added)
+++ servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/transport/jbi/JBIDestination.java Thu Dec 22 03:06:00 2011
@@ -0,0 +1,129 @@
+/**
+ * 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.servicemix.cxf.transport.jbi;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.logging.Logger;
+
+import javax.jbi.messaging.DeliveryChannel;
+import javax.jbi.messaging.MessageExchange;
+
+
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.transport.AbstractConduit;
+import org.apache.cxf.transport.AbstractDestination;
+import org.apache.cxf.transport.Conduit;
+import org.apache.cxf.transport.MessageObserver;
+import org.apache.cxf.ws.addressing.EndpointReferenceType;
+import org.apache.cxf.wsdl.EndpointReferenceUtils;
+
+public class JBIDestination extends AbstractDestination {
+
+ private static final Logger LOG = LogUtils.getL7dLogger(JBIDestination.class);
+ private JBIDispatcherUtil dispatcherUtil;
+ private DeliveryChannel channel;
+ public JBIDestination(EndpointInfo info,
+ JBIDispatcherUtil dispatcher,
+ DeliveryChannel dc) {
+ super(getTargetReference(info, null), info);
+ this.dispatcherUtil = dispatcher;
+ this.channel = dc;
+ }
+
+ public void setDeliveryChannel(DeliveryChannel dc) {
+ this.channel = dc;
+ }
+
+ public DeliveryChannel getDeliveryChannel() {
+ return this.channel;
+ }
+
+ protected Logger getLogger() {
+ return LOG;
+ }
+
+ /**
+ * @param inMessage the incoming message
+ * @return the inbuilt backchannel
+ */
+ protected Conduit getInbuiltBackChannel(Message inMessage) {
+ return new BackChannelConduit(EndpointReferenceUtils.getAnonymousEndpointReference(),
+ inMessage);
+ }
+
+ public void shutdown() {
+ dispatcherUtil.deactivateDispatch();
+ }
+
+ public void deactivate() {
+ dispatcherUtil.deactivateDispatch();
+ }
+
+ public void activate() {
+ dispatcherUtil.activateDispatch();
+ }
+
+ public JBIDispatcherUtil getJBIDispatcherUtil() {
+ return dispatcherUtil;
+ }
+
+ // this should deal with the cxf message
+ protected class BackChannelConduit extends AbstractConduit {
+
+ protected Message inMessage;
+ protected JBIDestination jbiDestination;
+
+ BackChannelConduit(EndpointReferenceType ref, Message message) {
+ super(ref);
+ inMessage = message;
+ }
+
+ /**
+ * Register a message observer for incoming messages.
+ *
+ * @param observer the observer to notify on receipt of incoming
+ */
+ public void setMessageObserver(MessageObserver observer) {
+ // shouldn't be called for a back channel conduit
+ }
+
+ /**
+ * Send an outbound message, assumed to contain all the name-value
+ * mappings of the corresponding input message (if any).
+ *
+ * @param message the message to be sent.
+ */
+ public void prepare(Message message) throws IOException {
+ // setup the message to be send back
+ DeliveryChannel dc = channel;
+ message.put(MessageExchange.class, inMessage.get(MessageExchange.class));
+ message.setContent(OutputStream.class,
+ new JBIDestinationOutputStream(inMessage, message, dc));
+ }
+
+ protected Logger getLogger() {
+ return LOG;
+ }
+ }
+
+}
Added: servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/transport/jbi/JBIDestinationOutputStream.java
URL: http://svn.apache.org/viewvc/servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/transport/jbi/JBIDestinationOutputStream.java?rev=1222013&view=auto
==============================================================================
--- servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/transport/jbi/JBIDestinationOutputStream.java (added)
+++ servicemix/components/trunk/engines/servicemix-cxf-se/src/main/java/org/apache/servicemix/cxf/transport/jbi/JBIDestinationOutputStream.java Thu Dec 22 03:06:00 2011
@@ -0,0 +1,149 @@
+/**
+ * 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.servicemix.cxf.transport.jbi;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.jbi.messaging.DeliveryChannel;
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.Fault;
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.NormalizedMessage;
+import javax.xml.transform.dom.DOMSource;
+
+import org.w3c.dom.Document;
+
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.io.CachedOutputStream;
+import org.apache.cxf.message.Attachment;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.staxutils.StaxUtils;
+
+public class JBIDestinationOutputStream extends CachedOutputStream {
+
+ private static final String SEND_SYNC = "javax.jbi.messaging.sendSync";
+
+ private static final Logger LOG = LogUtils.getL7dLogger(JBIDestinationOutputStream.class);
+ private Message inMessage;
+ private Message outMessage;
+ private DeliveryChannel channel;
+
+ public JBIDestinationOutputStream(Message m,
+ Message outM,
+ DeliveryChannel dc) {
+ super();
+ inMessage = m;
+ outMessage = outM;
+ channel = dc;
+ }
+
+ @Override
+ protected void doFlush() throws IOException {
+ // so far do nothing
+ }
+
+ @Override
+ protected void doClose() throws IOException {
+ commitOutputMessage();
+ }
+
+ @Override
+ protected void onWrite() throws IOException {
+ // so far do nothing
+ }
+
+ private void commitOutputMessage() throws IOException {
+ try {
+ if (inMessage.getExchange().isOneWay()) {
+ return;
+ } else {
+
+ InputStream bais = getInputStream();
+ LOG.finest(new org.apache.cxf.common.i18n.Message(
+ "BUILDING.DOCUMENT", LOG).toString());
+ Document doc = StaxUtils.read(bais);
+ bais.close();
+
+
+ MessageExchange xchng = inMessage.get(MessageExchange.class);
+ LOG.fine(new org.apache.cxf.common.i18n.Message(
+ "CREATE.NORMALIZED.MESSAGE", LOG).toString());
+ if (inMessage.getExchange().getOutFaultMessage() != null) {
+ org.apache.cxf.interceptor.Fault f = (org.apache.cxf.interceptor.Fault)
+ inMessage.getContent(Exception.class);
+ if (!(f.getCause() instanceof Error)) {
+ Fault fault = xchng.createFault();
+ fault.setContent(new DOMSource(doc));
+ xchng.setFault(fault);
+ if (!f.hasDetails()) {
+ xchng.setProperty("faultstring", f.getMessage());
+ }
+ } else {
+ xchng.setError(f);
+ }
+ } else {
+ NormalizedMessage msg = xchng.createMessage();
+ //copy attachments
+ if (outMessage != null && outMessage.getAttachments() != null) {
+ for (Attachment att : outMessage.getAttachments()) {
+ msg.addAttachment(att.getId(), att
+ .getDataHandler());
+ }
+ }
+ //copy properties
+
+ for (Map.Entry<String, Object> ent : inMessage.entrySet()) {
+ //check if value is Serializable, and if value is Map or collection,
+ //just exclude it since the entry of it may not be Serializable as well
+ if (ent.getValue() instanceof Serializable
+ && !(ent.getValue() instanceof Map)
+ && !(ent.getValue() instanceof Collection)) {
+ msg.setProperty(ent.getKey(), ent.getValue());
+ }
+ }
+
+
+ //copy contents
+ msg.setContent(new DOMSource(doc));
+ xchng.setMessage(msg, "out");
+
+ }
+ LOG.fine(new org.apache.cxf.common.i18n.Message(
+ "POST.DISPATCH", LOG).toString());
+ if (xchng.getStatus() == ExchangeStatus.ACTIVE
+ && Boolean.TRUE.equals(xchng.getProperty(SEND_SYNC))) {
+ channel.sendSync(xchng);
+ } else {
+ channel.send(xchng);
+ }
+ }
+ } catch (Exception ex) {
+ LOG.log(Level.SEVERE, new org.apache.cxf.common.i18n.Message(
+ "ERROR.SEND.MESSAGE", LOG).toString(), ex);
+ }
+ }
+
+}