Return-Path: Delivered-To: apmail-incubator-cxf-commits-archive@locus.apache.org Received: (qmail 34137 invoked from network); 29 Jan 2007 13:50:21 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 29 Jan 2007 13:50:21 -0000 Received: (qmail 40120 invoked by uid 500); 29 Jan 2007 13:50:26 -0000 Delivered-To: apmail-incubator-cxf-commits-archive@incubator.apache.org Received: (qmail 40069 invoked by uid 500); 29 Jan 2007 13:50:26 -0000 Mailing-List: contact cxf-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cxf-dev@incubator.apache.org Delivered-To: mailing list cxf-commits@incubator.apache.org Received: (qmail 40060 invoked by uid 99); 29 Jan 2007 13:50:26 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 29 Jan 2007 05:50:26 -0800 X-ASF-Spam-Status: No, hits=-8.6 required=10.0 tests=ALL_TRUSTED,INFO_TLD,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 29 Jan 2007 05:50:19 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id 191A21A981A; Mon, 29 Jan 2007 05:49:59 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r501049 - in /incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport: AbstractConduit.java AbstractDestination.java Date: Mon, 29 Jan 2007 13:49:58 -0000 To: cxf-commits@incubator.apache.org From: eglynn@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070129134959.191A21A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: eglynn Date: Mon Jan 29 05:49:58 2007 New Revision: 501049 URL: http://svn.apache.org/viewvc?view=rev&rev=501049 Log: Files missed in last commit. Added: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/AbstractConduit.java (with props) incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/AbstractDestination.java (with props) Added: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/AbstractConduit.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/AbstractConduit.java?view=auto&rev=501049 ============================================================================== --- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/AbstractConduit.java (added) +++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/AbstractConduit.java Mon Jan 29 05:49:58 2007 @@ -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.cxf.transport; + +import java.io.IOException; +import java.io.OutputStream; +import java.util.logging.Logger; + +import org.apache.cxf.message.Message; +import org.apache.cxf.ws.addressing.EndpointReferenceType; + +/** + * Abstract base class factoring out common Conduit logic, + * allowing non-decoupled transports to be written without any + * regard for the decoupled back-channel or partial response logic. + */ +public abstract class AbstractConduit implements Conduit { + + @SuppressWarnings("PMD:LoggerIsNotStaticFinal") + protected static Logger log; + protected final EndpointReferenceType target; + protected MessageObserver incomingObserver; + + public AbstractConduit(EndpointReferenceType t) { + target = t; + } + + /** + * @return the reference associated with the target Destination + */ + public EndpointReferenceType getTarget() { + return target; + } + + /** + * Retreive the back-channel Destination. + * + * @return the backchannel Destination (or null if the backchannel is + * built-in) + */ + public Destination getBackChannel() { + return null; + } + + /** + * @param message for which content shoul dbe closed. + */ + public void close(Message msg) throws IOException { + msg.getContent(OutputStream.class).close(); + } + + /** + * Register a message observer for incoming messages. + * + * @param observer the observer to notify on receipt of incoming + */ + public void setMessageObserver(MessageObserver observer) { + incomingObserver = observer; + log.info("registering incoming observer: " + incomingObserver); + } +} Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/AbstractConduit.java ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/AbstractDestination.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/AbstractDestination.java?view=auto&rev=501049 ============================================================================== --- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/AbstractDestination.java (added) +++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/AbstractDestination.java Mon Jan 29 05:49:58 2007 @@ -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.cxf.transport; + +import java.io.IOException; +import java.io.InputStream; +import java.util.logging.Logger; + +import org.apache.cxf.message.Exchange; +import org.apache.cxf.message.Message; +import org.apache.cxf.service.model.EndpointInfo; +import org.apache.cxf.ws.addressing.EndpointReferenceType; + +/** + * Abstract base class factoring out common Destination logic, + * allowing non-decoupled transports to be written without any + * regard for the decoupled back-channel or partial response logic. + */ +public abstract class AbstractDestination implements Destination { + + @SuppressWarnings("PMD:LoggerIsNotStaticFinal") + protected static Logger log; + protected final EndpointReferenceType reference; + protected final EndpointInfo endpointInfo; + protected MessageObserver incomingObserver; + + public AbstractDestination(EndpointReferenceType ref, + EndpointInfo ei) { + reference = ref; + endpointInfo = ei; + } + + /** + * @return the reference associated with this Destination + */ + public EndpointReferenceType getAddress() { + return reference; + } + + /** + * Retreive a back-channel Conduit, which must be policy-compatible + * with the current Message and associated Destination. For example + * compatible Quality of Protection must be asserted on the back-channel. + * This would generally only be an issue if the back-channel is decoupled. + * + * @param inMessage the current inbound message (null to indicate a + * disassociated back-channel) + * @param partialResponse in the decoupled case, this is expected to be the + * outbound Message to be sent over the in-built back-channel. + * @param address the backchannel address (null to indicate anonymous) + * @return a suitable Conduit + */ + public Conduit getBackChannel(Message inMessage, + Message partialResponse, + EndpointReferenceType address) + throws IOException { + Conduit backChannel = null; + Exchange ex = inMessage.getExchange(); + EndpointReferenceType target = address != null + ? address + : ex.get(EndpointReferenceType.class); + if (target == null) { + backChannel = getInbuiltBackChannel(inMessage); + } else { + if (partialResponse != null) { + if (markPartialResponse(partialResponse, target)) { + backChannel = getInbuiltBackChannel(inMessage); + } + } else { + ConduitInitiator conduitInitiator = getConduitInitiator(); + if (conduitInitiator != null) { + backChannel = conduitInitiator.getConduit(endpointInfo, target); + // ensure decoupled back channel input stream is closed + backChannel.setMessageObserver(new MessageObserver() { + public void onMessage(Message m) { + if (m.getContentFormats().contains(InputStream.class)) { + InputStream is = m.getContent(InputStream.class); + try { + is.close(); + } catch (Exception e) { + // ignore + } + } + } + }); + } + } + } + return backChannel; + } + + /** + * Register a message observer for incoming messages. + * + * @param observer the observer to notify on receipt of incoming + */ + public synchronized void setMessageObserver(MessageObserver observer) { + if (observer != incomingObserver) { + MessageObserver old = incomingObserver; + incomingObserver = observer; + if (observer != null) { + log.info("registering incoming observer: " + observer); + if (old == null) { + activateIncoming(); + } + } else { + log.info("unregistering incoming observer: " + incomingObserver); + if (old != null) { + deactivateIncoming(); + } + } + } + } + + /** + * Shutdown the Destination, i.e. stop accepting incoming messages. + */ + public void shutdown() { + // nothing to do by default + } + + /** + * Mark message as a partial message. Only required if decoupled + * mode is supported. + * + * @param partialResponse the partial response message + * @param the decoupled target + * @return true iff partial responses are supported + */ + protected boolean markPartialResponse(Message partialResponse, + EndpointReferenceType decoupledTarget) { + return false; + } + + /** + * @return the associated conduit initiator, or null if decoupled mode + * not supported. + */ + protected ConduitInitiator getConduitInitiator() { + return null; + } + + /** + * Activate receipt of incoming messages. + */ + protected abstract void activateIncoming(); + + /** + * Deactivate receipt of incoming messages. + */ + protected abstract void deactivateIncoming(); + + /** + * @param inMessage the incoming message + * @return the inbuilt backchannel + */ + protected abstract Conduit getInbuiltBackChannel(Message inMessage); +} Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/AbstractDestination.java ------------------------------------------------------------------------------ svn:eol-style = native