You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ch...@apache.org on 2007/09/17 19:00:16 UTC
svn commit: r576522 [2/3] - in /activemq/camel/trunk/components/camel-cxf:
./ src/main/java/org/apache/camel/component/cxf/
src/main/java/org/apache/camel/component/cxf/interceptors/
src/main/java/org/apache/camel/component/cxf/invoker/ src/main/java/o...
Added: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/SoapMessageInInterceptor.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/SoapMessageInInterceptor.java?rev=576522&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/SoapMessageInInterceptor.java (added)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/SoapMessageInInterceptor.java Mon Sep 17 10:00:08 2007
@@ -0,0 +1,123 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.cxf.interceptors;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+//import java.util.ResourceBundle;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+
+import org.apache.cxf.binding.soap.SoapMessage;
+import org.apache.cxf.binding.soap.model.SoapBindingInfo;
+import org.apache.cxf.common.logging.LogUtils;
+//import org.apache.cxf.common.i18n.BundleUtils;
+
+import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.service.model.BindingInfo;
+import org.apache.cxf.service.model.BindingMessageInfo;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.service.model.MessagePartInfo;
+
+public class SoapMessageInInterceptor extends AbstractMessageInInterceptor<SoapMessage> {
+ private static final Logger LOG = LogUtils.getL7dLogger(SoapMessageInInterceptor.class);
+
+ public SoapMessageInInterceptor() {
+ super(Phase.READ);
+ }
+
+ protected Logger getLogger() {
+ return LOG;
+ }
+
+ protected boolean isFaultMessage(SoapMessage message) {
+ //Fault Processing is Handled in SOAP Binding in the ReadHeadersInterceptor.
+ return false;
+ }
+
+ protected BindingOperationInfo getBindingOperation(SoapMessage message, Document doc) {
+ Exchange ex = message.getExchange();
+ SoapBindingInfo soapBinding = (SoapBindingInfo)ex.get(BindingInfo.class);
+
+ Element payloadEl = (Element)doc.getChildNodes().item(0);
+ QName startQName = new QName(payloadEl.getNamespaceURI(), payloadEl.getLocalName());
+
+ // handling xml normal inbound message
+ boolean client = isRequestor(message);
+
+ List<BindingOperationInfo> boiList = new ArrayList<BindingOperationInfo>();
+ for (BindingOperationInfo boi : soapBinding.getOperations()) {
+ String style = soapBinding.getStyle(boi.getOperationInfo());
+ QName rootName = null;
+ if ("rpc".equals(style)) {
+ rootName = boi.getOperationInfo().getName();
+ } else {
+ BindingMessageInfo bmi = client ? boi.getOutput() : boi.getInput();
+ if (bmi != null) {
+ Collection<MessagePartInfo> bodyParts = bmi.getMessageParts();
+ if (bodyParts.size() == 1) {
+ MessagePartInfo p = bodyParts.iterator().next();
+ rootName = p.getConcreteName();
+ }
+ }
+ }
+
+ if (startQName.equals(rootName)) {
+ boiList.add(boi);
+ }
+ }
+
+ if (boiList.size() > 1
+ && LOG.isLoggable(Level.INFO)) {
+ LOG.info("Mulitple matching BindingOperationIno found in Binding.");
+ }
+
+ return boiList.size() != 1 ? null : boiList.get(0);
+ }
+
+ protected List<Element> getPartList(SoapMessage inMessage, Element rootNode, BindingMessageInfo bmi) {
+ List<Element> partList = new ArrayList<Element>();
+ Exchange ex = inMessage.getExchange();
+ SoapBindingInfo soapBinding = (SoapBindingInfo)ex.get(BindingInfo.class);
+
+ String style = soapBinding.getStyle(bmi.getBindingOperation().getOperationInfo());
+ if ("rpc".equals(style)) {
+ //Remove the operation element.
+ rootNode = (Element)DOMUtils.getChild(rootNode, Node.ELEMENT_NODE);
+ }
+ partList.add(rootNode);
+ return partList;
+ }
+
+ protected Element getHeader(SoapMessage inMessage) {
+ // need to revisited
+ Element element = null;
+ return element;
+ // return inMessage.getHeaders(Element.class);
+ }
+
+}
Propchange: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/SoapMessageInInterceptor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/SoapMessageInInterceptor.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/SoapMessageOutInterceptor.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/SoapMessageOutInterceptor.java?rev=576522&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/SoapMessageOutInterceptor.java (added)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/SoapMessageOutInterceptor.java Mon Sep 17 10:00:08 2007
@@ -0,0 +1,152 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.cxf.interceptors;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.ResourceBundle;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.wsdl.Definition;
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Element;
+
+import org.apache.cxf.binding.soap.SoapMessage;
+import org.apache.cxf.binding.soap.SoapVersion;
+import org.apache.cxf.binding.soap.model.SoapBindingInfo;
+import org.apache.cxf.binding.soap.model.SoapHeaderInfo;
+import org.apache.cxf.common.i18n.BundleUtils;
+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.Phase;
+import org.apache.cxf.service.model.BindingInfo;
+import org.apache.cxf.service.model.BindingMessageInfo;
+import org.apache.cxf.service.model.MessagePartInfo;
+import org.apache.cxf.service.model.OperationInfo;
+import org.apache.cxf.wsdl11.WSDLServiceBuilder;
+
+public class SoapMessageOutInterceptor extends AbstractMessageOutInterceptor<SoapMessage> {
+ private static final Logger LOG = LogUtils.getL7dLogger(SoapMessageInInterceptor.class);
+
+
+ public SoapMessageOutInterceptor() {
+ super(Phase.PREPARE_SEND);
+ addAfter(DOMOutInterceptor.class.getName());
+ }
+
+ protected Logger getLogger() {
+ return LOG;
+ }
+
+ @SuppressWarnings("unchecked")
+ public void handleMessage(SoapMessage message) throws Fault {
+ Element header = message.get(Element.class);
+ List<Element> payload = message.get(List.class);
+ Exchange exchange = message.getExchange();
+ BindingMessageInfo bmi = exchange.get(BindingMessageInfo.class);
+
+
+ //Headers -represent as -Element,Body -represent as StaxStream.
+ //Check if BindingOperationInfo contains header
+ List<SoapHeaderInfo> bindingHdr = bmi.getExtensors(SoapHeaderInfo.class);
+ if (bindingHdr != null && !bindingHdr.isEmpty()) {
+ if (LOG.isLoggable(Level.INFO)) {
+ LOG.info("SoapMessageOutInterceptor BindingOperation header processing.");
+ }
+
+ List<Element> headerList = new ArrayList<Element>();
+ List<Element> newPayload = new ArrayList<Element>(payload);
+ //Look for headers in Payload.
+ for (SoapHeaderInfo shi : bindingHdr) {
+ List<Element> tmpList = new ArrayList<Element>();
+ MessagePartInfo mpi = shi.getPart();
+ QName hdrName = mpi.getConcreteName();
+ for (Element el : payload) {
+ QName elName = new QName(el.getNamespaceURI(), el.getLocalName());
+ if (elName.equals(hdrName)) {
+ newPayload.remove(el);
+ tmpList.add(el);
+ }
+ }
+
+ if (tmpList.size() > 1) {
+ throw new Fault(new org.apache.cxf.common.i18n.Message(
+ "MULTIPLE_HDR_PARTS", LOG, hdrName));
+ }
+ headerList.addAll(tmpList);
+ }
+
+ if (LOG.isLoggable(Level.INFO)) {
+ LOG.info("DOMOutInterceptor Copy Payload parts to SOAPHeaders");
+ }
+ if (headerList.size() != 0) {
+ SoapVersion version = ((SoapMessage)message).getVersion();
+ header = createElement(version.getHeader(), headerList);
+ }
+ payload = newPayload;
+ }
+
+ //Set SOAP Header Element.
+ //Child Elements Could be binding specified parts or user specified headers.
+ //REVISTED the soap headers
+ //message.setHeaders(Element.class, header);
+
+ //TODO Moving Parts from Header to Payload.
+ //For e.g Payload ROuting from SOAP11 <-> SOAP12
+
+ //So write payload and header to outbound message
+ if (LOG.isLoggable(Level.INFO)) {
+ LOG.info("SoapMessageOutInterceptor binding operation style processing.");
+ }
+ SoapBindingInfo soapBinding = (SoapBindingInfo)exchange.get(BindingInfo.class);
+ String style = soapBinding.getStyle(bmi.getBindingOperation().getOperationInfo());
+ if ("rpc".equals(style)) {
+ //Add the Operation Node or Operation+"Response" node
+ //Remove the operation element.
+ OperationInfo oi = bmi.getBindingOperation().getOperationInfo();
+ Endpoint ep = exchange.get(Endpoint.class);
+ Definition def =
+ ep.getService().getServiceInfos().get(0).getProperty(WSDLServiceBuilder.WSDL_DEFINITION,
+ Definition.class);
+ String prefix = def.getPrefix(oi.getName().getNamespaceURI());
+
+ if ("".equals(prefix)) {
+ prefix = "tns";
+ }
+ QName opName = null;
+ boolean isClient = isRequestor(message);
+ if (isClient) {
+ opName = new QName(oi.getName().getNamespaceURI(),
+ oi.getName().getLocalPart(),
+ prefix);
+ } else {
+ opName = new QName(oi.getName().getNamespaceURI(),
+ oi.getName().getLocalPart() + "Response",
+ prefix);
+ }
+ Element opEl = createElement(opName, payload);
+ payload = new ArrayList<Element>();
+ payload.add(opEl);
+ }
+
+ message.put(List.class, payload);
+ }
+}
Propchange: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/SoapMessageOutInterceptor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/SoapMessageOutInterceptor.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/XMLMessageInInterceptor.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/XMLMessageInInterceptor.java?rev=576522&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/XMLMessageInInterceptor.java (added)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/XMLMessageInInterceptor.java Mon Sep 17 10:00:08 2007
@@ -0,0 +1,148 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.cxf.interceptors;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.ResourceBundle;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+import org.apache.cxf.binding.xml.XMLConstants;
+import org.apache.cxf.binding.xml.XMLFault;
+import org.apache.cxf.bindings.xformat.XMLBindingMessageFormat;
+import org.apache.cxf.common.i18n.BundleUtils;
+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.message.XMLMessage;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.service.model.BindingInfo;
+import org.apache.cxf.service.model.BindingMessageInfo;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.service.model.MessagePartInfo;
+import org.apache.cxf.staxutils.StaxUtils;
+
+public class XMLMessageInInterceptor extends AbstractMessageInInterceptor<XMLMessage> {
+ private static final Logger LOG = LogUtils.getL7dLogger(XMLMessageInInterceptor.class);
+
+
+ public XMLMessageInInterceptor() {
+ super(Phase.READ);
+ }
+
+ protected Logger getLogger() {
+ return LOG;
+ }
+
+ protected boolean isFaultMessage(XMLMessage message) {
+ XMLStreamReader xsr = message.getContent(XMLStreamReader.class);
+ boolean isFault = false;
+ try {
+ if (StaxUtils.skipToStartOfElement(xsr)) {
+ QName startQName = xsr.getName();
+ isFault = XMLConstants.NS_XML_FORMAT.equals(startQName.getNamespaceURI())
+ && XMLFault.XML_FAULT_ROOT.equals(startQName.getLocalPart());
+ }
+ } catch (XMLStreamException xse) {
+ throw new Fault(new org.apache.cxf.common.i18n.Message("STAX_READ_EXC", LOG));
+ }
+
+ return isFault;
+ }
+
+ protected BindingOperationInfo getBindingOperation(XMLMessage message, Document doc) {
+ Exchange ex = message.getExchange();
+ BindingInfo binding = ex.get(BindingInfo.class);
+ if (binding == null) {
+ Endpoint ep = ex.get(Endpoint.class);
+ binding = ep.getEndpointInfo().getBinding();
+ }
+ //TODO if binding is null throw exception.
+
+ Element payloadEl = (Element)doc.getChildNodes().item(0);
+ QName startQName = new QName(payloadEl.getNamespaceURI(), payloadEl.getLocalName());
+
+ // handling xml normal inbound message
+ boolean client = isRequestor(message);
+
+ List<BindingOperationInfo> boiList = new ArrayList<BindingOperationInfo>();
+ for (BindingOperationInfo boi : binding.getOperations()) {
+ BindingMessageInfo bmi = client ? boi.getOutput() : boi.getInput();
+
+ QName rootName = null;
+ if (bmi != null) {
+ XMLBindingMessageFormat msgFormat =
+ bmi.getExtensor(XMLBindingMessageFormat.class);
+
+ if (msgFormat != null) {
+ rootName = msgFormat.getRootNode();
+ } else {
+ Collection<MessagePartInfo> bodyParts = bmi.getMessageParts();
+ if (bodyParts.size() == 1) {
+ MessagePartInfo p = bodyParts.iterator().next();
+ rootName = p.getConcreteName();
+ }
+ }
+ }
+
+ if (startQName.equals(rootName)) {
+ boiList.add(boi);
+ }
+ }
+
+ BindingOperationInfo match = null;
+ if (boiList.size() > 1) {
+ if (LOG.isLoggable(Level.INFO)) {
+ LOG.info("Mulitple matching BindingOperationIno found in Binding.");
+ }
+ } else if (!boiList.isEmpty()) {
+ match = boiList.get(0);
+ }
+ return match;
+ }
+
+ protected List<Element> getPartList(XMLMessage inMessage, Element rootNode, BindingMessageInfo bmi) {
+ List<Element> partList = new ArrayList<Element>();
+ XMLBindingMessageFormat msgFormat =
+ bmi.getExtensor(XMLBindingMessageFormat.class);
+ if (msgFormat != null) {
+ NodeList nodeList = rootNode.getChildNodes();
+ for (int idx = 0; idx < nodeList.getLength(); idx++) {
+ partList.add((Element)nodeList.item(idx));
+ }
+ } else {
+ partList.add(rootNode);
+ }
+ return partList;
+ }
+
+ protected Element getHeader(XMLMessage inMessage) {
+ return null;
+ }
+
+}
Propchange: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/XMLMessageInInterceptor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/XMLMessageInInterceptor.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/XMLMessageOutInterceptor.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/XMLMessageOutInterceptor.java?rev=576522&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/XMLMessageOutInterceptor.java (added)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/XMLMessageOutInterceptor.java Mon Sep 17 10:00:08 2007
@@ -0,0 +1,123 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.cxf.interceptors;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.ResourceBundle;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import org.apache.cxf.bindings.xformat.XMLBindingMessageFormat;
+import org.apache.cxf.common.i18n.BundleUtils;
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.XMLMessage;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.service.model.BindingMessageInfo;
+//import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.service.model.MessagePartInfo;
+
+public class XMLMessageOutInterceptor extends AbstractMessageOutInterceptor<XMLMessage> {
+ private static final Logger LOG = LogUtils.getL7dLogger(XMLMessageOutInterceptor.class);
+
+
+ public XMLMessageOutInterceptor() {
+ super(Phase.PREPARE_SEND);
+ addAfter(DOMOutInterceptor.class.getName());
+ }
+
+ protected Logger getLogger() {
+ return LOG;
+ }
+
+ @SuppressWarnings("unchecked")
+ public void handleMessage(XMLMessage message) throws Fault {
+ Exchange exchange = message.getExchange();
+ //BindingOperationInfo boi = exchange.get(BindingOperationInfo.class);
+ BindingMessageInfo bmi = exchange.get(BindingMessageInfo.class);
+
+ List<Element> payload = message.get(List.class);
+ if (bmi == null && payload.size() > 1) {
+ throw new Fault(new org.apache.cxf.common.i18n.Message(
+ "NO_XML_ROOT_NODE", LOG));
+ }
+
+ if (bmi != null) {
+ Element header = message.get(Element.class);
+ if (header != null) {
+ //Headers -represent as -Element,
+ //Body -represent as StaxStream in CXF Runtime.
+ //Copy inbound Header parts to outbound payload
+ if (LOG.isLoggable(Level.INFO)) {
+ LOG.info("DOMOutInterceptor Copy Message Part related Headers to Payload.");
+ }
+ moveHeaderPartToPayload(bmi, header, payload);
+ }
+
+ XMLBindingMessageFormat msgFormat =
+ bmi.getExtensor(XMLBindingMessageFormat.class);
+ QName rootName = msgFormat != null ? msgFormat.getRootNode() : null;
+
+ if (rootName == null) {
+ if (payload.size() > 1) {
+ throw new Fault(new org.apache.cxf.common.i18n.Message(
+ "NO_XML_ROOT_NODE", LOG));
+ }
+ } else {
+ if (LOG.isLoggable(Level.INFO)) {
+ LOG.info("DOMOutInterceptor Create xmlformat RootNode element");
+ }
+ Element el = createElement(rootName, payload);
+ payload = new ArrayList<Element>();
+ payload.add(el);
+ }
+
+ message.put(List.class, payload);
+ message.remove(Element.class);
+ }
+ }
+
+ private void moveHeaderPartToPayload(BindingMessageInfo bmi,
+ Element header,
+ List<Element> payload) {
+ Collection<MessagePartInfo> bodyParts = bmi.getMessageParts();
+ NodeList nodes = header.getChildNodes();
+
+ for (int idx = 0; idx < nodes.getLength(); idx++) {
+ Node node = nodes.item(idx);
+ int index = 0;
+ for (MessagePartInfo mpi : bodyParts) {
+ QName name = mpi.getConcreteName();
+ if (name.getLocalPart().equals(node.getLocalName())
+ && name.getNamespaceURI().equals(node.getNamespaceURI())) {
+ payload.add(index, (Element)node);
+ break;
+ }
+ ++index;
+ }
+ }
+ }
+}
Propchange: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/XMLMessageOutInterceptor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/XMLMessageOutInterceptor.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/package.html
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/package.html?rev=576522&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/package.html (added)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/package.html Mon Sep 17 10:00:08 2007
@@ -0,0 +1,25 @@
+<!--
+ 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.
+-->
+<html>
+<head>
+</head>
+<body>
+
+Defines the CXF Component's interceptors
+
+</body>
+</html>
Propchange: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/package.html
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/package.html
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/package.html
------------------------------------------------------------------------------
svn:mime-type = text/html
Added: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/AbstractInvokingContext.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/AbstractInvokingContext.java?rev=576522&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/AbstractInvokingContext.java (added)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/AbstractInvokingContext.java Mon Sep 17 10:00:08 2007
@@ -0,0 +1,151 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.cxf.invoker;
+
+import java.util.List;
+import java.util.Map;
+import java.util.SortedSet;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.endpoint.EndpointImpl;
+import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.phase.PhaseInterceptorChain;
+
+/**
+ * A RoutingContext encapulates specific knowledge about how to route messages of
+ * a particular data format.
+ *
+ */
+public abstract class AbstractInvokingContext implements InvokingContext {
+
+ private static final Logger LOG = Logger.getLogger(AbstractInvokingContext.class.getName());
+
+ /**
+ * This method is called when an request from a (routing) client is observed
+ * at the router's transport (inbound to the router from a client). It will
+ * return an "in" interceptor chain that will allow the appropriate routing
+ * interceptor to receive and handle the message.
+ * @param exchange
+ * @return in interceptor chain
+ */
+ public PhaseInterceptorChain getRequestInInterceptorChain(Exchange exchange) {
+ return getInInterceptorChain(exchange, false);
+ }
+
+ protected PhaseInterceptorChain getInInterceptorChain(Exchange exchange, boolean isResponse) {
+
+ Bus bus = exchange.get(Bus.class);
+ assert bus != null;
+
+ PhaseInterceptorChain chain = new PhaseInterceptorChain(getInPhases());
+
+ if (!isResponse) {
+ List<Interceptor> routingInterceptors = getRoutingInterceptors();
+ chain.add(routingInterceptors);
+ if (LOG.isLoggable(Level.FINE)) {
+ LOG.fine("Injected " + routingInterceptors);
+ }
+ }
+
+ // bus
+ List<Interceptor> list = bus.getInInterceptors();
+ if (LOG.isLoggable(Level.FINE)) {
+ LOG.fine("Interceptors contributed by bus: " + list);
+ }
+
+ chain.add(list);
+
+ // endpoint
+ Endpoint ep = exchange.get(Endpoint.class);
+ if (ep != null) {
+ list = ep.getInInterceptors();
+ if (LOG.isLoggable(Level.FINE)) {
+ LOG.fine("Interceptors contributed by endpoint: " + list);
+ }
+ chain.add(list);
+
+ // binding
+ list = ep.getBinding().getInInterceptors();
+ if (LOG.isLoggable(Level.FINE)) {
+ LOG.fine("Interceptors contributed by binding: " + list);
+ }
+ chain.add(list);
+
+ // service
+ list = ep.getService().getInInterceptors();
+ if (LOG.isLoggable(Level.FINE)) {
+ LOG.fine("Interceptors contributed by service: " + list);
+ }
+ chain.add(list);
+ }
+
+ return chain;
+ }
+
+ /**
+ * @return routing interceptor(s) specific to the routing context.
+ */
+ protected abstract List<Interceptor> getRoutingInterceptors();
+
+ /**
+ * @return "in" phrases from the phase manager specific to the routing context.
+ */
+ protected abstract SortedSet<Phase> getInPhases();
+
+ /**
+ * This method is called when a response from a CXF server is observed at the
+ * router's transport (inbound to the router from a server). It will return an
+ * "in" interceptor chain that will allow the response to be returned to the
+ * involved routing interceptor (with the appropriate interceptors in between).
+ * @param exchange
+ * @return in interceptor chain
+ */
+ public PhaseInterceptorChain getResponseInInterceptorChain(Exchange exchange) {
+ return getInInterceptorChain(exchange, true);
+ }
+
+ protected <T> T getResponseObject(Message inMessage, Map<String, Object> responseContext,
+ Class <T> clazz) {
+ System.out.println("get the in message is " + inMessage);
+ System.out.println("*** responseContext is" + responseContext);
+ T retval = null;
+ if (inMessage != null) {
+ if (null != responseContext) {
+ responseContext.putAll(inMessage);
+ LOG.info("set responseContext to be" + responseContext);
+ }
+ retval = inMessage.getContent(clazz);
+ }
+ return retval;
+ }
+
+ /**
+ * This method is called to set the fault observers on the endpoint that are specified
+ * to the phases meaningful to the routing context.
+ * @param endpointImpl
+ * @param bus
+ */
+ public void setEndpointFaultObservers(EndpointImpl endpointImpl, Bus bus) {
+ // default is no op
+ }
+}
Propchange: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/AbstractInvokingContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/AbstractInvokingContext.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/CxfClient.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/CxfClient.java?rev=576522&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/CxfClient.java (added)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/CxfClient.java Mon Sep 17 10:00:08 2007
@@ -0,0 +1,241 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.cxf.invoker;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.binding.Binding;
+import org.apache.cxf.endpoint.ClientImpl;
+import org.apache.cxf.endpoint.ConduitSelector;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.endpoint.EndpointImpl;
+import org.apache.cxf.endpoint.PreexistingConduitSelector;
+import org.apache.cxf.helpers.IOUtils;
+import org.apache.cxf.io.CachedOutputStream;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.ExchangeImpl;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.PhaseInterceptorChain;
+import org.apache.cxf.service.model.BindingInfo;
+import org.apache.cxf.service.model.BindingMessageInfo;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.transport.MessageObserver;
+
+/**
+ * Just deal with the PayLoadMessage and RawMessage
+ *
+ */
+public class CxfClient extends ClientImpl {
+
+ private static final Logger LOG = Logger.getLogger(CxfClient.class.getName());
+
+ private Endpoint endpoint;
+
+ public CxfClient(Bus b, Endpoint e) {
+ super(b, e);
+ endpoint = e;
+ }
+
+ public Object dispatch(Object params,
+ Map<String, Object> context,
+ Exchange exchange) throws Exception {
+
+ Object retval = null;
+ InvokingContext invokingContext = exchange.get(InvokingContext.class);
+ assert invokingContext != null;
+
+ // get InBound binding operation info from the exchange object
+ BindingOperationInfo inBoundOp = exchange.get(BindingOperationInfo.class);
+
+ BindingOperationInfo outBoundOp = null;
+
+ if (inBoundOp != null) {
+ //Get the BindingOperationInfo for the outbound binding.
+ BindingInfo bi = getEndpoint().getEndpointInfo().getBinding();
+ outBoundOp = bi.getOperation(inBoundOp.getOperationInfo().getName());
+ if (outBoundOp != null
+ && inBoundOp.isUnwrapped()) {
+ outBoundOp = outBoundOp.getUnwrappedOperation();
+ }
+ }
+
+
+ retval = invokeWithMessageStream(outBoundOp, params, context, invokingContext);
+
+ return retval;
+
+
+ }
+
+
+ @SuppressWarnings("unchecked")
+ public Object invokeWithMessageStream(BindingOperationInfo bi,
+ Object param,
+ Map<String, Object> context,
+ InvokingContext invokingContext) throws Exception {
+
+ Object retval = null;
+
+ Map<String, Object> requestContext = null;
+ Map<String, Object> responseContext = null;
+
+ if (null != context) {
+ requestContext = (Map<String, Object>) context.get(REQUEST_CONTEXT);
+ responseContext = (Map<String, Object>) context.get(RESPONSE_CONTEXT);
+ }
+
+ Exchange exchange = new ExchangeImpl();
+ // put the message Observer to call the CxfClient onMessage()
+ exchange.put(MessageObserver.class, this);
+ exchange.put(InvokingContext.class, invokingContext);
+ exchange.put(Bus.class, bus);
+ exchange.put(Endpoint.class, getEndpoint());
+ exchange.put(BindingInfo.class, getEndpoint().getEndpointInfo().getBinding());
+ if (bi != null) {
+ //Set The InputMessage
+ exchange.put(BindingOperationInfo.class, bi);
+ exchange.put(BindingMessageInfo.class, bi.getInput());
+ exchange.setOneWay(bi.getOperationInfo().isOneWay());
+ }
+
+ Message message = prepareMessage(exchange, requestContext, param, invokingContext);
+
+ PhaseInterceptorChain chain = setupOutChain(requestContext, message, invokingContext);
+
+ // setup conduit selector
+ prepareConduitSelector(message);
+
+ // execute chain
+ chain.doIntercept(message);
+
+ //it will close all the stream in the message, so we do not call it
+ //getConduitSelector().complete(exchange);
+
+ // Check to see if there is a Fault from the outgoing chain
+ Exception ex = message.getContent(Exception.class);
+
+ if (ex != null) {
+ if (LOG.isLoggable(Level.FINE)) {
+ LOG.fine("Exception in outgoing chain: " + ex.toString());
+ }
+ throw ex;
+ }
+
+ if (!exchange.isOneWay()) {
+ ex = getException(exchange);
+
+ if (ex != null) {
+ if (LOG.isLoggable(Level.FINE)) {
+ LOG.fine("Exception in incoming chain: " + ex.toString());
+ }
+ throw ex;
+ }
+ retval = invokingContext.getResponseObject(exchange, responseContext);
+
+ }
+
+ return retval;
+ }
+
+ public void onMessage(Message message) {
+ Exchange exchange = message.getExchange();
+
+ if (LOG.isLoggable(Level.FINE)) {
+ LOG.fine("call the cxf client on message , exchange is " + exchange);
+ }
+ if (exchange.get(InvokingContext.class) == null) {
+ super.onMessage(message);
+ } else {
+
+ message = getEndpoint().getBinding().createMessage(message);
+ message.put(Message.REQUESTOR_ROLE, Boolean.TRUE);
+ message.put(Message.INBOUND_MESSAGE, Boolean.TRUE);
+
+ exchange.put(Binding.class, getEndpoint().getBinding());
+ BindingOperationInfo bi = exchange.get(BindingOperationInfo.class);
+ if (bi != null) {
+ //Set The OutputMessage
+ exchange.put(BindingMessageInfo.class, bi.getOutput());
+ }
+ InvokingContext invokingContext = exchange.get(InvokingContext.class);
+ assert invokingContext != null;
+
+ // setup interceptor chain
+ PhaseInterceptorChain chain = invokingContext.getResponseInInterceptorChain(exchange);
+ message.setInterceptorChain(chain);
+
+ // execute chain
+ chain.doIntercept(message);
+
+ // set inMessage in the exchange
+ exchange.setInMessage(message);
+ }
+ }
+
+ private Message prepareMessage(Exchange exchange, Map<String, Object> requestContext,
+ Object param, InvokingContext InvokingContext) {
+
+ Message message = getEndpoint().getBinding().createMessage();
+ message.put(Message.REQUESTOR_ROLE, Boolean.TRUE);
+ message.put(Message.INBOUND_MESSAGE, Boolean.FALSE);
+
+ // setup the message context
+ if (requestContext != null) {
+ message.putAll(requestContext);
+ }
+
+ if (param != null) {
+ InvokingContext.setRequestOutMessageContent(message, param);
+ }
+
+ if (null != requestContext) {
+ exchange.putAll(requestContext);
+ }
+
+ exchange.setOutMessage(message);
+ return message;
+ }
+
+ private PhaseInterceptorChain setupOutChain(Map<String, Object> requestContext,
+ Message message, InvokingContext invokingContext) {
+
+ if (LOG.isLoggable(Level.FINEST)) {
+ LOG.finest("Build an out interceptor chain to send request to server");
+ }
+ Exchange exchange = message.getExchange();
+ PhaseInterceptorChain chain = invokingContext.getRequestOutInterceptorChain(exchange);
+ message.setInterceptorChain(chain);
+ modifyChain(chain, requestContext);
+ chain.setFaultObserver(outFaultObserver);
+ return chain;
+ }
+
+ public Endpoint getEndpoint() {
+ return endpoint;
+ }
+
+ public Bus getBus() {
+ return bus;
+ }
+}
+
Propchange: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/CxfClient.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/CxfClient.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/CxfClientFactoryBean.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/CxfClientFactoryBean.java?rev=576522&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/CxfClientFactoryBean.java (added)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/CxfClientFactoryBean.java Mon Sep 17 10:00:08 2007
@@ -0,0 +1,44 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.cxf.invoker;
+
+import org.apache.cxf.BusException;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.endpoint.ClientImpl;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.endpoint.EndpointException;
+import org.apache.cxf.frontend.ClientFactoryBean;
+import org.apache.cxf.service.factory.ReflectionServiceFactoryBean;
+import org.apache.cxf.service.factory.ServiceConstructionException;
+
+
+
+public class CxfClientFactoryBean extends ClientFactoryBean {
+
+
+ public CxfClientFactoryBean() {
+ super();
+ }
+
+ protected void createClient(Endpoint ep) {
+ CxfClient client = new CxfClient(getBus(), ep);
+ setClient(client);
+ }
+
+
+
+}
Propchange: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/CxfClientFactoryBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/CxfClientFactoryBean.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/FaultChainInitiatorObserver.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/FaultChainInitiatorObserver.java?rev=576522&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/FaultChainInitiatorObserver.java (added)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/FaultChainInitiatorObserver.java Mon Sep 17 10:00:08 2007
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.cxf.invoker;
+
+import java.util.SortedSet;
+
+import org.apache.camel.component.cxf.interceptors.FaultOutInterceptor;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.phase.PhaseInterceptorChain;
+
+public class FaultChainInitiatorObserver extends AbstractFaultChainInitiatorObserver {
+
+ private SortedSet<Phase> phases;
+ private boolean isOutbound;
+
+ public FaultChainInitiatorObserver(Bus bus, SortedSet<Phase> phases, boolean isOutbound) {
+ super(bus);
+ this.phases = phases;
+ this.isOutbound = isOutbound;
+ }
+
+ protected void initializeInterceptors(Exchange ex, PhaseInterceptorChain chain) {
+ Endpoint e = ex.get(Endpoint.class);
+
+ if (isOutboundObserver()) {
+ chain.add(e.getOutFaultInterceptors());
+ chain.add(e.getBinding().getOutFaultInterceptors());
+ chain.add(e.getService().getOutFaultInterceptors());
+ chain.add(getBus().getOutFaultInterceptors());
+ chain.add(new FaultOutInterceptor());
+ } else {
+ chain.add(e.getBinding().getInFaultInterceptors());
+ chain.add(e.getService().getInFaultInterceptors());
+ chain.add(getBus().getInFaultInterceptors());
+ }
+ }
+
+ @Override
+ protected SortedSet<Phase> getPhases() {
+ return phases;
+ }
+
+ @Override
+ protected boolean isOutboundObserver() {
+ return isOutbound;
+ }
+
+}
Propchange: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/FaultChainInitiatorObserver.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/FaultChainInitiatorObserver.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/InvokingContext.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/InvokingContext.java?rev=576522&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/InvokingContext.java (added)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/InvokingContext.java Mon Sep 17 10:00:08 2007
@@ -0,0 +1,109 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.cxf.invoker;
+
+import java.util.Map;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.endpoint.EndpointImpl;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.PhaseInterceptorChain;
+
+public interface InvokingContext {
+ /**
+ * This method is called when an request from a (routing) client is observed
+ * at the router's transport (inbound to the router from a client). It will
+ * return an "in" interceptor chain that will allow the appropriate routing
+ * interceptor to receive and handle the message.
+ * @param exchange
+ * @return in interceptor chain
+ */
+ PhaseInterceptorChain getRequestInInterceptorChain(Exchange exchange);
+
+ /**
+ * This method is called when the router is preparing an outbound message
+ * (orignated from the router's client) to be sent to the target CXF server.
+ * It sets the content in the given (out) message object.
+ * @param content
+ */
+ void setRequestOutMessageContent(Message message, Object content);
+
+ /**
+ * This method is called when a response from a CXF server is observed at the
+ * router's transport (inbound to the router from a server). It will return an
+ * "in" interceptor chain that will allow the response to be returned to the
+ * involved routing interceptor (with the appropriate interceptors in between).
+ * @param exchange
+ * @return in interceptor chain
+ */
+ PhaseInterceptorChain getResponseInInterceptorChain(Exchange exchange);
+
+ /**
+ * This method is called when the router is ready to forward a request from a client
+ * to the target CXF server. It returns an "out" intercetptor chain that will deliver
+ * the request message to the CXF server.
+ * @param exchange
+ * @return out interceptor chain
+ */
+ PhaseInterceptorChain getRequestOutInterceptorChain(Exchange exchange);
+
+ /**
+ * This method is called when the router is ready to forward a response from a CXF
+ * to the client who has made the request. It returns an "out" interceptor chain that
+ * will deliver the response message to the client.
+ * @param exchange
+ * @return out interceptor chain
+ */
+ PhaseInterceptorChain getResponseOutInterceptorChain(Exchange exchange);
+
+ /**
+ * This method is call when the CxfClient receives a response from a CXF server and needs
+ * to extract the response object from the message.
+ * @param exchange
+ * @param responseContext
+ * @return response object
+ */
+ Object getResponseObject(Exchange exchange, Map<String, Object> responseContext);
+
+ /**
+ * This method is called to set the fault observers on the endpoint that are specified
+ * to the phases meaningful to the routing context.
+ * @param endpointImpl
+ * @param bus
+ */
+ void setEndpointFaultObservers(EndpointImpl endpointImpl, Bus bus);
+
+ /**
+ * This method is called when the routing interceptor has received a response message
+ * from the target CXF server and needs to set the response in the outgoing message
+ * that is to be sent to the client.
+ * @param outMessage
+ * @param resultPayload
+ */
+ void setResponseContent(Message outMessage, Object resultPayload);
+
+ /**
+ * This method is called when the routing interceptor has intercepted a message from
+ * the client and needs to extract the request content from the message. It retreives
+ * and receives the request content from the incoming message.
+ * @param inMessage
+ * @return the request from client
+ */
+ Object getRequestContent(Message inMessage);
+
+}
Propchange: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/InvokingContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/InvokingContext.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/InvokingContextFactory.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/InvokingContextFactory.java?rev=576522&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/InvokingContextFactory.java (added)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/InvokingContextFactory.java Mon Sep 17 10:00:08 2007
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.cxf.invoker;
+
+import org.apache.camel.component.cxf.DataFormat;
+
+public final class InvokingContextFactory {
+
+ private InvokingContextFactory() {
+ // not constructed
+ }
+
+ /**
+ * Static method that creates a routing context object from a given data format
+ * @param dataFormat
+ * @return routing context
+ */
+ public static InvokingContext createContext(DataFormat dataFormat) {
+
+ if (dataFormat == DataFormat.MESSAGE) {
+ return new RawMessageInvokingContext();
+ }
+
+ if (dataFormat == DataFormat.PAYLOAD) {
+ return new PayloadInvokingContext();
+ }
+
+ //Default is DataFormat.MESSAGE, we do not set the POJO context
+ return new RawMessageInvokingContext();
+ }
+}
Propchange: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/InvokingContextFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/InvokingContextFactory.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/PayloadInvokingContext.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/PayloadInvokingContext.java?rev=576522&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/PayloadInvokingContext.java (added)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/PayloadInvokingContext.java Mon Sep 17 10:00:08 2007
@@ -0,0 +1,245 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.cxf.invoker;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.SortedSet;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.w3c.dom.Element;
+
+import org.apache.camel.component.cxf.interceptors.DOMInInterceptor;
+import org.apache.camel.component.cxf.interceptors.DOMOutInterceptor;
+import org.apache.camel.component.cxf.interceptors.PayloadContentRedirectInterceptor;
+import org.apache.camel.component.cxf.interceptors.PayloadInInterceptor;
+import org.apache.camel.component.cxf.phase.FaultPayloadPhaseManagerImpl;
+import org.apache.camel.component.cxf.phase.PayloadPhaseManagerImpl;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.endpoint.EndpointImpl;
+import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.phase.PhaseInterceptorChain;
+import org.apache.cxf.phase.PhaseManager;
+import org.apache.cxf.transport.MessageObserver;
+
+public class PayloadInvokingContext extends AbstractInvokingContext {
+ private static final Logger LOG = Logger.getLogger(PayloadInvokingContext.class.getName());
+
+ private PhaseManager phaseManager;
+ private PhaseManager faultPhaseManager;
+ private MessageObserver inFaultObserver;
+ private MessageObserver outFaultObserver;
+
+ public PayloadInvokingContext() {
+ phaseManager = new PayloadPhaseManagerImpl();
+ faultPhaseManager = new FaultPayloadPhaseManagerImpl();
+ }
+
+ public PhaseInterceptorChain getRequestOutInterceptorChain(Exchange exchange) {
+ return getOutIntercepterChain(exchange);
+ }
+
+ public PhaseInterceptorChain getResponseOutInterceptorChain(Exchange exchange) {
+ return getOutIntercepterChain(exchange);
+ }
+
+ private PhaseInterceptorChain getOutIntercepterChain(Exchange exchange) {
+ PhaseInterceptorChain chain = new PhaseInterceptorChain(
+ new PayloadPhaseManagerImpl().getOutPhases());
+
+ Bus bus = exchange.get(Bus.class);
+ assert bus != null;
+
+ // bus
+ List<Interceptor> list = bus.getOutInterceptors();
+ if (LOG.isLoggable(Level.FINE)) {
+ LOG.fine("Interceptors contributed by bus: " + list);
+ }
+ chain.add(list);
+
+ // endpoint
+ Endpoint endpoint = exchange.get(Endpoint.class);
+ if (endpoint != null) {
+ list = endpoint.getOutInterceptors();
+ if (LOG.isLoggable(Level.FINE)) {
+ LOG.fine("Interceptors contributed by endpoint: " + list);
+ }
+ chain.add(list);
+ list = endpoint.getBinding().getOutInterceptors();
+ if (LOG.isLoggable(Level.FINE)) {
+ LOG.fine("Interceptors contributed by binding: " + list);
+ }
+ chain.add(list);
+ }
+ chain.add(new DOMOutInterceptor());
+ chain.add(new PayloadContentRedirectInterceptor());
+
+ return chain;
+ }
+
+ public void setRequestOutMessageContent(Message message, Object content) {
+
+ PayloadMessage request = (PayloadMessage) content;
+
+ Element header = request.getHeader();
+ List<Element> payload = request.getPayload();
+
+ if (LOG.isLoggable(Level.FINEST)) {
+ LOG.finest("header = " + header + ", paylaod = " + payload);
+ }
+
+ message.put(Element.class, header);
+ message.put(List.class, payload);
+ }
+
+ @Override
+ protected SortedSet<Phase> getInPhases() {
+ return phaseManager.getInPhases();
+ }
+
+ protected SortedSet<Phase> getOutPhases() {
+ return phaseManager.getOutPhases();
+ }
+
+ @Override
+ protected List<Interceptor> getRoutingInterceptors() {
+ List<Interceptor> list = new ArrayList<Interceptor>();
+ list.add(new DOMInInterceptor());
+ list.add(new PayloadInInterceptor());
+ return list;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Object getResponseObject(Exchange exchange, Map<String, Object> responseContext) {
+ PayloadMessage payloadMsg = null;
+
+ Message msg = exchange.getInMessage();
+ List<Element> payload = getResponseObject(msg , responseContext, List.class);
+ Element header = exchange.getInMessage().get(Element.class);
+ payloadMsg = new PayloadMessage(payload, header);
+
+ if (LOG.isLoggable(Level.FINEST)) {
+ LOG.finest(payloadMsg.toString());
+ }
+
+ return payloadMsg;
+ }
+
+ @Override
+ protected <T> T getResponseObject(Message inMessage, Map<String, Object> responseContext,
+ Class <T> clazz) {
+
+ T retval = null;
+ if (inMessage != null) {
+ if (null != responseContext) {
+ responseContext.putAll(inMessage);
+ LOG.info("set responseContext to be" + responseContext);
+ }
+ retval = inMessage.get(clazz);
+ }
+ return retval;
+ }
+
+ protected PhaseInterceptorChain getInInterceptorChain(Exchange exchange, boolean isResponse) {
+
+ Bus bus = exchange.get(Bus.class);
+ assert bus != null;
+
+ PhaseInterceptorChain chain = new PhaseInterceptorChain(getInPhases());
+
+ List<Interceptor> routingInterceptors = getRoutingInterceptors();
+ chain.add(routingInterceptors);
+ if (LOG.isLoggable(Level.FINE)) {
+ LOG.fine("Injected " + routingInterceptors);
+ }
+
+ // bus
+ List<Interceptor> list = bus.getInInterceptors();
+ if (LOG.isLoggable(Level.FINE)) {
+ LOG.fine("Interceptors contributed by bus: " + list);
+ }
+ chain.add(list);
+
+ // endpoint
+ Endpoint ep = exchange.get(Endpoint.class);
+ if (ep != null) {
+ list = ep.getInInterceptors();
+ if (LOG.isLoggable(Level.FINE)) {
+ LOG.fine("Interceptors contributed by endpoint: " + list);
+ }
+ chain.add(list);
+
+ // binding
+ list = ep.getBinding().getInInterceptors();
+ if (LOG.isLoggable(Level.FINE)) {
+ LOG.fine("Interceptors contributed by binding: " + list);
+ }
+ chain.add(list);
+ }
+
+ return chain;
+ }
+
+ /**
+ * This method is called to set the fault observers on the endpoint that are specified
+ * to the phases meaningful to the routing context.
+ * @param endpointImpl
+ */
+ @Override
+ public void setEndpointFaultObservers(EndpointImpl endpointImpl, Bus bus) {
+ if (inFaultObserver == null) {
+ inFaultObserver = new FaultChainInitiatorObserver(bus, faultPhaseManager.getInPhases(), false);
+ }
+ endpointImpl.setInFaultObserver(inFaultObserver);
+
+ if (outFaultObserver == null) {
+ outFaultObserver = new FaultChainInitiatorObserver(bus, faultPhaseManager.getOutPhases(), true);
+ }
+ endpointImpl.setOutFaultObserver(outFaultObserver);
+ }
+
+ public void setResponseContent(Message outMessage, Object resultPayload) {
+ if (resultPayload != null) {
+ PayloadMessage payloadMessage = (PayloadMessage) resultPayload;
+ if (LOG.isLoggable(Level.FINEST)) {
+ LOG.finest(payloadMessage.toString());
+ }
+ outMessage.put(List.class, payloadMessage.getPayload());
+ outMessage.put(Element.class, payloadMessage.getHeader());
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public Object getRequestContent(Message inMessage) {
+ List<Element> payload = inMessage.get(List.class);
+ Element header = inMessage.get(Element.class);
+
+ if (LOG.isLoggable(Level.FINEST)) {
+ LOG.finest("Header = " + header + ", Payload = " + payload);
+ }
+
+ return new PayloadMessage(payload, header);
+ }
+
+}
Propchange: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/PayloadInvokingContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/PayloadInvokingContext.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/PayloadMessage.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/PayloadMessage.java?rev=576522&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/PayloadMessage.java (added)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/PayloadMessage.java Mon Sep 17 10:00:08 2007
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.cxf.invoker;
+
+import java.util.List;
+
+import org.w3c.dom.Element;
+
+public class PayloadMessage {
+ private List<Element> payload;
+ private Element header;
+
+ public PayloadMessage(List<Element> payload, Element header) {
+ this.payload = payload;
+ this.header = header;
+ }
+
+ public List<Element> getPayload() {
+ return payload;
+ }
+
+ public Element getHeader() {
+ return header;
+ }
+
+ public String toString() {
+ StringBuffer buf = new StringBuffer();
+ buf.append("payload: " + payload);
+ buf.append(" header: " + header);
+ return buf.toString();
+ }
+}
Propchange: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/PayloadMessage.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/PayloadMessage.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/RawMessageInvokingContext.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/RawMessageInvokingContext.java?rev=576522&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/RawMessageInvokingContext.java (added)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/RawMessageInvokingContext.java Mon Sep 17 10:00:08 2007
@@ -0,0 +1,193 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.cxf.invoker;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.SortedSet;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.camel.component.cxf.interceptors.RawMessageContentRedirectInterceptor;
+import org.apache.camel.component.cxf.interceptors.RawMessageInInterceptor;
+import org.apache.camel.component.cxf.phase.RawMessagePhaseManagerImpl;
+
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.helpers.IOUtils;
+import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.io.CachedOutputStream;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.phase.PhaseInterceptorChain;
+import org.apache.cxf.phase.PhaseManager;
+
+public class RawMessageInvokingContext extends AbstractInvokingContext {
+ private static final Logger LOG = Logger.getLogger(RawMessageInvokingContext.class.getName());
+
+ private PhaseManager phaseManager;
+
+ public RawMessageInvokingContext() {
+ phaseManager = new RawMessagePhaseManagerImpl();
+ }
+
+ public PhaseInterceptorChain getRequestOutInterceptorChain(Exchange exchange) {
+ return getOutInterceptorChain(exchange);
+ }
+
+ public PhaseInterceptorChain getResponseOutInterceptorChain(Exchange exchange) {
+ return getOutInterceptorChain(exchange);
+ }
+
+ private PhaseInterceptorChain getOutInterceptorChain(Exchange exchange) {
+
+ PhaseInterceptorChain chain = new PhaseInterceptorChain(
+ new RawMessagePhaseManagerImpl().getOutPhases());
+
+ Bus bus = exchange.get(Bus.class);
+ assert bus != null;
+
+ // bus
+ List<Interceptor> list = bus.getOutInterceptors();
+ if (LOG.isLoggable(Level.FINE)) {
+ LOG.fine("Interceptors contributed by bus: " + list);
+ }
+ chain.add(list);
+
+ // endpoint
+ Endpoint endpoint = exchange.get(Endpoint.class);
+ if (endpoint != null) {
+ list = endpoint.getOutInterceptors();
+ if (LOG.isLoggable(Level.FINE)) {
+ LOG.fine("Interceptors contributed by endpoint: " + list);
+ }
+ chain.add(list);
+ }
+
+ if (LOG.isLoggable(Level.FINE)) {
+ LOG.fine("inject " + RawMessageContentRedirectInterceptor.class);
+ }
+ chain.add(new RawMessageContentRedirectInterceptor());
+
+ return chain;
+
+ }
+
+ public void setRequestOutMessageContent(Message message, Object content) {
+ message.setContent(InputStream.class, content);
+ }
+
+ @Override
+ protected SortedSet<Phase> getInPhases() {
+ return phaseManager.getInPhases();
+ }
+
+ @Override
+ protected List<Interceptor> getRoutingInterceptors() {
+ List<Interceptor> list = new ArrayList<Interceptor>();
+ list.add(new RawMessageInInterceptor());
+ return list;
+ }
+
+ public Object getResponseObject(Exchange exchange, Map<String, Object> responseContext) {
+ /*CachedOutputStream bos = exchange.getInMessage().getContent(CachedOutputStream.class);
+ InputStream in = null;
+ try {
+ in = bos.getInputStream();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return in;*/
+ return getResponseObject(exchange.getInMessage(), responseContext, InputStream.class);
+ }
+
+ //@Override
+ protected PhaseInterceptorChain getInInterceptorChain(Exchange exchange, boolean isResponse) {
+
+ Bus bus = exchange.get(Bus.class);
+ assert bus != null;
+
+ PhaseInterceptorChain chain = new PhaseInterceptorChain(getInPhases());
+
+ if (!isResponse) {
+ List<Interceptor> routingInterceptors = getRoutingInterceptors();
+ chain.add(routingInterceptors);
+ if (LOG.isLoggable(Level.FINE)) {
+ LOG.fine("Injected " + routingInterceptors);
+ }
+ }
+
+ // bus
+ List<Interceptor> list = bus.getInInterceptors();
+
+ LOG.fine("Interceptors contributed by bus: " + list);
+ chain.add(list);
+
+ // endpoint
+ Endpoint ep = exchange.get(Endpoint.class);
+ if (ep != null) {
+ list = ep.getInInterceptors();
+ if (LOG.isLoggable(Level.FINE)) {
+ LOG.fine("Interceptors contributed by endpoint: " + list);
+ }
+ chain.add(list);
+ }
+
+ return chain;
+ }
+
+ public void setResponseContent(Message outMessage, Object resultPayload) {
+ LOG.info("Set content: " + resultPayload);
+ outMessage.setContent(InputStream.class, resultPayload);
+ //loggerTheMessage(outMessage, "Out Message");
+ }
+
+ public Object getRequestContent(Message inMessage) {
+ //loggerTheMessage(inMessage, "In Message");
+ return inMessage.getContent(InputStream.class);
+ }
+
+ private void loggerTheMessage(Message message, String messageTile) {
+ StringBuffer buffer = new StringBuffer( messageTile + "\n"
+ + "--------------------------------------");
+ InputStream is = message.getContent(InputStream.class);
+ if (is != null) {
+ CachedOutputStream bos = new CachedOutputStream();
+ try {
+ IOUtils.copy(is, bos);
+
+ is.close();
+ bos.close();
+
+ buffer.append("\nMessage:\n");
+ buffer.append(bos.getOut().toString());
+
+ message.setContent(InputStream.class, bos.getInputStream());
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ buffer.append("\n--------------------------------------");
+ LOG.info(buffer.toString());
+ }
+}
Propchange: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/RawMessageInvokingContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/RawMessageInvokingContext.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/package.html
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/package.html?rev=576522&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/package.html (added)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/package.html Mon Sep 17 10:00:08 2007
@@ -0,0 +1,25 @@
+<!--
+ 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.
+-->
+<html>
+<head>
+</head>
+<body>
+
+Defines the CXF Component's routers definitions
+
+</body>
+</html>
Propchange: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/package.html
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/package.html
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/package.html
------------------------------------------------------------------------------
svn:mime-type = text/html
Added: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/phase/AbstractPhaseManagerImpl.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/phase/AbstractPhaseManagerImpl.java?rev=576522&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/phase/AbstractPhaseManagerImpl.java (added)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/phase/AbstractPhaseManagerImpl.java Mon Sep 17 10:00:08 2007
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.cxf.phase;
+
+import java.util.List;
+import java.util.SortedSet;
+
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.phase.PhaseManager;
+
+public abstract class AbstractPhaseManagerImpl implements PhaseManager {
+ private SortedSet<Phase> inPhases;
+ private SortedSet<Phase> outPhases;
+
+ public AbstractPhaseManagerImpl() {
+ inPhases = createInPhases();
+ outPhases = createOutPhases();
+ }
+
+ public SortedSet<Phase> getInPhases() {
+ return inPhases;
+ }
+
+ public SortedSet<Phase> getOutPhases() {
+ return outPhases;
+ }
+
+ protected abstract SortedSet<Phase> createInPhases();
+
+ protected abstract SortedSet<Phase> createOutPhases();
+}
Propchange: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/phase/AbstractPhaseManagerImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/phase/AbstractPhaseManagerImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date