You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by jm...@apache.org on 2006/05/05 08:29:42 UTC
svn commit: r399988 [2/2] - in /incubator/tuscany/sandbox/jboynes/sca:
containers/container.java/src/test/java/org/apache/tuscany/container/java/builder/
core/src/main/java/org/apache/tuscany/core/config/
core/src/main/java/org/apache/tuscany/core/conf...
Added: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/InvocationConfiguration.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/InvocationConfiguration.java?rev=399988&view=auto
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/InvocationConfiguration.java (added)
+++ incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/InvocationConfiguration.java Thu May 4 23:29:38 2006
@@ -0,0 +1,191 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.tuscany.spi.wire;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Contains a source- or target-side invocation pipeline for a service operation. The runtime framework
+ * creates invocation chains on a per-operation, per-service basis. Further, invocation chains are further
+ * distinguished by being part of the source or target sides of a wire. Chains are "bridged" together by the
+ * runtime by a set of {@link org.apache.tuscany.spi.builder.WireBuilder}s with the source-side holding
+ * references to the target.
+ * <p/>
+ * <code>InvocationChain</code>s are managed by {@link WireConfiguration}s, which are used by {@link
+ * org.apache.tuscany.core.wire.WireFactory}s to buildSource wires and proxies.
+ * <p/>
+ * Invocation configurations must contain at least one interceptor and may have 0 to N handlers. Handlers
+ * process a wire request or response in a one-way fashion. A typical wire sequence where interceptors and
+ * handlers are configured for both the source and target-side will proceed as follows:
+ * <pre>
+ * <ol>
+ * <li>The first source interceptor will be called with a message, which will in
+ * turn invoke the next interceptor in the chain <li>The last source interceptor, which must be of type
+ * {@link
+ * org.apache.tuscany.core.wire.impl.RequestResponseInterceptor} if there are handlers present, will be
+ * invoked. The RR
+ * interceptor will in turn pass the message to a {@link MessageChannel} which
+ * will invoke all source-side request handlers.
+ * <li>The RR interceptor will then invoke the target-side request <code>MessageChannel</code>.
+ * <li>The last source-side handler, an instance of {@link MessageDispatcher},
+ * will invoke the
+ * first source-side interceptor, which in turn will pass the message down the target-side interceptor
+ * chain.
+ * <li>If the target is a component instance the last target-side interceptor, an instance of
+ * {@link InvokerInterceptor} will retrieve the {@link TargetInvoker} from the
+ * message and
+ * call it to invoke the operation on a target instance. <tt>TargetInvoker</tt>s are help by
+ * the source proxy to enable optimizations such as caching of target instances. <li> The response is
+ * returned up the wire
+ * stack
+ * until it reaches the source-side <tt>RequestResponseInterceptor</tt>, which invokes the target and
+ * source-side response
+ * channels respectively.
+ * <li>The response is then passed back up the rest of the wire stack. </ol>
+ * </pre>
+ * <p/>
+ * The source-to-target bridge may be constructed in any of the following ways:
+ * <pre>
+ * <ul>
+ * <li>Source handler-to-target handler
+ * <li>Source handler-to-target interceptor
+ * <li>Source interceptor-to-target handler
+ * <li>Source interceptor-to-target interceptor
+ * </ul>
+ * </pre>
+ * <p/>
+ * In some scenarios, a service proxy may only contain target-side invocaton chains, for example, when a
+ * service is resolved through a locate operation by a non-component client. In this case, there will be no
+ * source-side wire chains and the target invoker will be held by the target-side and passed down the
+ * pipeline.
+ *
+ * @version $Rev: 396284 $ $Date: 2006-04-23 08:27:42 -0700 (Sun, 23 Apr 2006) $
+ * @see org.apache.tuscany.spi.builder.WireBuilder
+ * @see WireFactory
+ * @see TargetInvoker
+ * @see MessageDispatcher
+ */
+public abstract class InvocationConfiguration {
+
+ // the operation on the target that will utlimately be invoked
+ protected Method operation;
+
+ // responsible for invoking a target instance
+ protected TargetInvoker targetInvoker;
+
+ protected Interceptor interceptorChainHead;
+
+ protected Interceptor interceptorChainTail;
+
+ protected List<MessageHandler> requestHandlers;
+
+ protected List<MessageHandler> responseHandlers;
+
+ public InvocationConfiguration(Method operation) {
+ assert (operation != null) : "No operation type specified";
+ this.operation = operation;
+ }
+
+ /**
+ * Returns the target operation for this invocation chain
+ */
+ public Method getMethod() {
+ return operation;
+ }
+
+ /**
+ * Adds an request handler to the invocation chain
+ */
+ public void addRequestHandler(MessageHandler handler) {
+ if (requestHandlers == null) {
+ requestHandlers = new ArrayList<MessageHandler>();
+ }
+ requestHandlers.add(handler);
+ }
+
+ /**
+ * Adds an response handler to the invocation chain
+ */
+ public void addResponseHandler(MessageHandler handler) {
+ if (responseHandlers == null) {
+ responseHandlers = new ArrayList<MessageHandler>();
+ }
+ responseHandlers.add(handler);
+ }
+
+ /**
+ * Returns the request handler chain
+ */
+ public List<MessageHandler> getRequestHandlers() {
+ return requestHandlers;
+ }
+
+ /**
+ * Returns the response handler chain
+ */
+ public List<MessageHandler> getResponseHandlers() {
+ return responseHandlers;
+ }
+
+ /**
+ * Sets the target invoker to pass down the chain
+ */
+ public void setTargetInvoker(TargetInvoker invoker) {
+ this.targetInvoker = invoker;
+ }
+
+ /**
+ * Returns the target invoker that is passed down the chain
+ */
+ public TargetInvoker getTargetInvoker() {
+ return targetInvoker;
+ }
+
+ /**
+ * Adds an interceptor to the chain
+ */
+ public void addInterceptor(Interceptor interceptor) {
+ if (interceptorChainHead == null) {
+ interceptorChainHead = interceptor;
+ } else {
+ interceptorChainTail.setNext(interceptor);
+ }
+ interceptorChainTail = interceptor;
+ }
+
+ /**
+ * Returns the last interceptor in the chain
+ */
+ public Interceptor getTailInterceptor() {
+ return interceptorChainTail;
+ }
+
+ /**
+ * Returns the first interceptor in the chain
+ */
+ public Interceptor getHeadInterceptor() {
+ return interceptorChainHead;
+ }
+
+ /**
+ * Signals to the chain that its configuration is complete. Implementations may use this callback to
+ * prepare there invocation chains.
+ */
+ public abstract void build();
+}
Copied: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/InvokerInterceptor.java (from r399941, incubator/tuscany/sandbox/jboynes/sca/core/src/main/java/org/apache/tuscany/core/wire/impl/InvokerInterceptor.java)
URL: http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/InvokerInterceptor.java?p2=incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/InvokerInterceptor.java&p1=incubator/tuscany/sandbox/jboynes/sca/core/src/main/java/org/apache/tuscany/core/wire/impl/InvokerInterceptor.java&r1=399941&r2=399988&rev=399988&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core/src/main/java/org/apache/tuscany/core/wire/impl/InvokerInterceptor.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/InvokerInterceptor.java Thu May 4 23:29:38 2006
@@ -11,20 +11,15 @@
* 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.tuscany.core.wire.impl;
-
-import org.apache.tuscany.spi.wire.Interceptor;
-import org.apache.tuscany.spi.wire.InvocationRuntimeException;
-import org.apache.tuscany.spi.wire.TargetInvoker;
-import org.apache.tuscany.spi.wire.Message;
+package org.apache.tuscany.spi.wire;
/**
* Serves as a tail interceptor on a target wire chain. This implementation dispatches to the target invoker
* passed inside the wire message. Target invokers are passed from the source in order to allow for caching of
* target instances.
- *
- * @see org.apache.tuscany.spi.wire.TargetInvoker
+ *
* @version $Rev$ $Date$
+ * @see TargetInvoker
*/
public class InvokerInterceptor implements Interceptor {
Copied: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/MessageChannelImpl.java (from r399941, incubator/tuscany/sandbox/jboynes/sca/core/src/main/java/org/apache/tuscany/core/wire/impl/MessageChannelImpl.java)
URL: http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/MessageChannelImpl.java?p2=incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/MessageChannelImpl.java&p1=incubator/tuscany/sandbox/jboynes/sca/core/src/main/java/org/apache/tuscany/core/wire/impl/MessageChannelImpl.java&r1=399941&r2=399988&rev=399988&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core/src/main/java/org/apache/tuscany/core/wire/impl/MessageChannelImpl.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/MessageChannelImpl.java Thu May 4 23:29:38 2006
@@ -14,28 +14,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.tuscany.core.wire.impl;
-
-import org.apache.tuscany.spi.wire.MessageChannel;
-import org.apache.tuscany.spi.wire.MessageHandler;
-import org.apache.tuscany.spi.wire.Message;
+package org.apache.tuscany.spi.wire;
import java.util.List;
/**
* A channel comprising an ordered collection of message handlers.
*
- *@see org.apache.tuscany.spi.wire.Message
* @version $Rev$ $Date$
+ * @see org.apache.tuscany.spi.wire.Message
*/
public class MessageChannelImpl implements MessageChannel {
private final List<MessageHandler> pipeline;
- //----------------------------------
- // Constructors
- //----------------------------------
-
/**
* Construct a new channel comprising the supplied list of handlers.
*
@@ -45,19 +37,14 @@
this.pipeline = pipeline;
}
- //----------------------------------
- // Methods
- //----------------------------------
-
/**
- * Send a message down the channel. The message will be processed by all handlers
- * in order until one returns false to indicate processing is complete or all
- * handlers have been called.
+ * Send a message down the channel. The message will be processed by all handlers in order until one
+ * returns false to indicate processing is complete or all handlers have been called.
*
* @param msg a Message to send down the channel
*/
public void send(Message msg) {
- if (pipeline!=null) {
+ if (pipeline != null) {
for (MessageHandler handler : pipeline) {
if (!handler.processMessage(msg)) {
break;
Propchange: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/MessageChannelImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/MessageChannelImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Copied: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/MessageDispatcher.java (from r399941, incubator/tuscany/sandbox/jboynes/sca/core/src/main/java/org/apache/tuscany/core/wire/impl/MessageDispatcher.java)
URL: http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/MessageDispatcher.java?p2=incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/MessageDispatcher.java&p1=incubator/tuscany/sandbox/jboynes/sca/core/src/main/java/org/apache/tuscany/core/wire/impl/MessageDispatcher.java&r1=399941&r2=399988&rev=399988&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core/src/main/java/org/apache/tuscany/core/wire/impl/MessageDispatcher.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/MessageDispatcher.java Thu May 4 23:29:38 2006
@@ -14,16 +14,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.tuscany.core.wire.impl;
-
-import org.apache.tuscany.spi.wire.Interceptor;
-import org.apache.tuscany.spi.wire.MessageHandler;
-import org.apache.tuscany.spi.wire.Message;
+package org.apache.tuscany.spi.wire;
/**
- * A message handler that dispatches the message through an interceptor stack and the uses the response channel to
- * return the wire result.
- *
+ * A message handler that dispatches the message through an interceptor stack and the uses the response
+ * channel to return the wire result.
+ *
* @version $Rev$ $Date$
*/
public class MessageDispatcher implements MessageHandler {
@@ -31,7 +27,7 @@
/**
* Construct a handler that dispatches messages to an Interceptor stack.
- *
+ *
* @param head the interceptor at the head of the stack
*/
public MessageDispatcher(Interceptor head) {
Propchange: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/MessageDispatcher.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/MessageDispatcher.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Copied: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/MessageImpl.java (from r399941, incubator/tuscany/sandbox/jboynes/sca/core/src/main/java/org/apache/tuscany/core/message/impl/MessageImpl.java)
URL: http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/MessageImpl.java?p2=incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/MessageImpl.java&p1=incubator/tuscany/sandbox/jboynes/sca/core/src/main/java/org/apache/tuscany/core/message/impl/MessageImpl.java&r1=399941&r2=399988&rev=399988&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core/src/main/java/org/apache/tuscany/core/message/impl/MessageImpl.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/MessageImpl.java Thu May 4 23:29:38 2006
@@ -14,11 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.tuscany.core.message.impl;
-
-import org.apache.tuscany.spi.wire.Message;
-import org.apache.tuscany.spi.wire.MessageChannel;
-import org.apache.tuscany.spi.wire.TargetInvoker;
+package org.apache.tuscany.spi.wire;
/**
* The default implementation of a message flowed through a wire during an invocation
@@ -31,55 +27,33 @@
private Message relatedCallbackMessage;
private TargetInvoker invoker;
- protected MessageImpl() {
- super();
+ public MessageImpl() {
}
- /**
- * @see org.apache.tuscany.spi.wire.Message#getBody()
- */
public Object getBody() {
return body;
}
- /**
- * @see org.apache.tuscany.spi.wire.Message#setBody(java.lang.Object)
- */
public void setBody(Object body) {
this.body = body;
}
- /**
- * @see org.apache.tuscany.spi.wire.Message#getCallbackChannel()
- */
public MessageChannel getCallbackChannel() {
return this;
}
- /**
- * @see org.apache.tuscany.spi.wire.MessageChannel#send(org.apache.tuscany.spi.wire.Message)
- */
public void send(Message message) {
relatedCallbackMessage = message;
}
- /**
- * @see org.apache.tuscany.spi.wire.Message#getRelatedCallbackMessage()
- */
public Message getRelatedCallbackMessage() {
return relatedCallbackMessage;
}
- /**
- * @see org.apache.tuscany.spi.wire.Message#setTargetInvoker(org.apache.tuscany.spi.wire.TargetInvoker)
- */
public void setTargetInvoker(TargetInvoker invoker) {
this.invoker = invoker;
}
- /**
- * @see org.apache.tuscany.spi.wire.Message#getTargetInvoker()
- */
public TargetInvoker getTargetInvoker() {
return invoker;
}
Propchange: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/MessageImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/MessageImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Copied: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/OneWayInterceptor.java (from r399941, incubator/tuscany/sandbox/jboynes/sca/core/src/main/java/org/apache/tuscany/core/wire/impl/OneWayInterceptor.java)
URL: http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/OneWayInterceptor.java?p2=incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/OneWayInterceptor.java&p1=incubator/tuscany/sandbox/jboynes/sca/core/src/main/java/org/apache/tuscany/core/wire/impl/OneWayInterceptor.java&r1=399941&r2=399988&rev=399988&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core/src/main/java/org/apache/tuscany/core/wire/impl/OneWayInterceptor.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/OneWayInterceptor.java Thu May 4 23:29:38 2006
@@ -14,15 +14,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.tuscany.core.wire.impl;
-
-import org.apache.tuscany.spi.wire.Interceptor;
-import org.apache.tuscany.spi.wire.MessageChannel;
-import org.apache.tuscany.spi.wire.Message;
+package org.apache.tuscany.spi.wire;
/**
* An interceptor that sends the wire Message down its request channel and does not expect a response.
- *
+ *
* @version $Rev$ $Date$
*/
public class OneWayInterceptor implements Interceptor {
@@ -30,7 +26,7 @@
/**
* Construct an interceptor that sends messages down the supplied channel.
- *
+ *
* @param requestChannel the channel to send messages down
*/
public OneWayInterceptor(MessageChannel requestChannel) {
Propchange: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/OneWayInterceptor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/OneWayInterceptor.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Copied: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/RequestResponseInterceptor.java (from r399941, incubator/tuscany/sandbox/jboynes/sca/core/src/main/java/org/apache/tuscany/core/wire/impl/RequestResponseInterceptor.java)
URL: http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/RequestResponseInterceptor.java?p2=incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/RequestResponseInterceptor.java&p1=incubator/tuscany/sandbox/jboynes/sca/core/src/main/java/org/apache/tuscany/core/wire/impl/RequestResponseInterceptor.java&r1=399941&r2=399988&rev=399988&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core/src/main/java/org/apache/tuscany/core/wire/impl/RequestResponseInterceptor.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/RequestResponseInterceptor.java Thu May 4 23:29:38 2006
@@ -14,16 +14,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.tuscany.core.wire.impl;
-
-import org.apache.tuscany.spi.wire.Interceptor;
-import org.apache.tuscany.spi.wire.MessageChannel;
-import org.apache.tuscany.spi.wire.Message;
+package org.apache.tuscany.spi.wire;
/**
* An interceptor that first sends a message down its request channel then extracts the response from the
* message and sends it down the response channel before returning it up the interceptor stack.
- *
+ *
* @version $Rev$ $Date$
*/
public class RequestResponseInterceptor implements Interceptor {
@@ -38,8 +34,8 @@
/**
* Construct an interceptor that sends messages down the supplied channels.
- *
- * @param targetRequestChannel the channel to send request messages down
+ *
+ * @param targetRequestChannel the channel to send request messages down
* @param targetResponseChannel the channel to sent response messages down
*/
public RequestResponseInterceptor(MessageChannel sourceRequestChannel, MessageChannel targetRequestChannel,
Propchange: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/RequestResponseInterceptor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/RequestResponseInterceptor.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/SourceInvocationConfiguration.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/SourceInvocationConfiguration.java?rev=399988&view=auto
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/SourceInvocationConfiguration.java (added)
+++ incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/SourceInvocationConfiguration.java Thu May 4 23:29:38 2006
@@ -0,0 +1,127 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.tuscany.spi.wire;
+
+import java.lang.reflect.Method;
+
+/**
+ * Contains a source-side invocation pipeline for a service operation.
+ *
+ * @version $Rev: 394379 $ $Date: 2006-04-15 15:01:36 -0700 (Sat, 15 Apr 2006) $
+ */
+public class SourceInvocationConfiguration extends InvocationConfiguration {
+
+ // the pointer to the bridged target head interceptor or null if the target has no interceptors
+ private Interceptor targetInterceptorChainHead;
+
+ // the pointer to bridged target request channel, or null if the target has an interceptor
+ private MessageChannel targetRequestChannel;
+
+ // the pointer to bridged target response channel, or null if the target has an interceptor
+ private MessageChannel targetResponseChannel;
+
+ /**
+ * Creates an new wire configuration for the given service reference operation
+ *
+ * @param operation the method on the interface representing specified by the reference, where the method corresponds to the
+ * service operation
+ */
+ public SourceInvocationConfiguration(Method operation) {
+ super(operation);
+ }
+
+ /**
+ * Sets the head interceptor of the target-side configuration for the wire. Used when the runtime bridges source and target
+ * chains.
+ *
+ * @param interceptor
+ */
+ public void setTargetInterceptor(Interceptor interceptor) {
+ targetInterceptorChainHead = interceptor;
+ }
+
+ /**
+ * Returns the head target-side interceptor. This will be the head interceptor of the "bridged" target configuration.
+ */
+ public Interceptor getTargetInterceptor() {
+ return targetInterceptorChainHead;
+ }
+
+ /**
+ * Sets the target-side request channel. Used when the runtime bridges source and target chains.
+ */
+ public void setTargetRequestChannel(MessageChannel channel) {
+ targetRequestChannel = channel;
+ }
+
+ /**
+ * Sets the target-side response channel. Used when the runtime bridges source and target chains.
+ */
+ public void setTargetResponseChannel(MessageChannel channel) {
+ targetResponseChannel = channel;
+ }
+
+ /**
+ * Prepares the configuration by linking interceptors and handlers
+ */
+ @Override
+ public void build() {
+
+ if (requestHandlers != null && targetInterceptorChainHead != null) {
+ // on target-side, connect existing handlers and interceptors
+ MessageHandler messageDispatcher = new MessageDispatcher(targetInterceptorChainHead);
+ requestHandlers.add(messageDispatcher);
+ }
+
+ if (requestHandlers != null) {
+ MessageChannel requestChannel = new MessageChannelImpl(requestHandlers);
+ MessageChannel responseChannel = new MessageChannelImpl(responseHandlers);
+ Interceptor channelInterceptor = new RequestResponseInterceptor(requestChannel, targetRequestChannel,
+ responseChannel, targetResponseChannel);
+
+ if (interceptorChainHead != null) {
+ interceptorChainTail.setNext(channelInterceptor);
+ } else {
+ interceptorChainHead = channelInterceptor;
+ }
+
+ } else {
+ // no request handlers
+ if (interceptorChainHead != null) {
+ if (targetInterceptorChainHead != null) {
+ // Connect source interceptor chain directly to target interceptor chain
+ interceptorChainTail.setNext(targetInterceptorChainHead);
+ // interceptorChainTail = targetInterceptorChainHead;
+ } else {
+ // Connect source interceptor chain to the target request channel
+ Interceptor channelInterceptor = new RequestResponseInterceptor(null, targetRequestChannel, null,
+ targetResponseChannel);
+ interceptorChainTail.setNext(channelInterceptor);
+ }
+ } else {
+ // no source interceptor chain or source handlers, conntect to target interceptor chain or channel
+ if (targetInterceptorChainHead != null) {
+ interceptorChainHead = targetInterceptorChainHead;
+ interceptorChainTail = targetInterceptorChainHead;
+ } else {
+ Interceptor channelInterceptor = new RequestResponseInterceptor(null, targetRequestChannel, null,
+ targetResponseChannel);
+ interceptorChainHead = channelInterceptor;
+ interceptorChainTail = channelInterceptor;
+ }
+ }
+ }
+ }
+
+}
Added: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/TargetInvocationConfiguration.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/TargetInvocationConfiguration.java?rev=399988&view=auto
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/TargetInvocationConfiguration.java (added)
+++ incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/TargetInvocationConfiguration.java Thu May 4 23:29:38 2006
@@ -0,0 +1,47 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.tuscany.spi.wire;
+
+import java.lang.reflect.Method;
+
+/**
+ * Contains a target-side invocation pipeline for a service operation.
+ *
+ * @version $Rev: 394379 $ $Date: 2006-04-15 15:01:36 -0700 (Sat, 15 Apr 2006) $
+ */
+public class TargetInvocationConfiguration extends InvocationConfiguration {
+
+ /**
+ * Creates an new target-side pipeline for the given operation
+ *
+ * @param operation the method on the interface representing target service, where the method corresponds
+ * to the service operation
+ */
+ public TargetInvocationConfiguration(Method operation) {
+ super(operation);
+ }
+
+ /**
+ * Prepares the configuration by linking interceptors and handlers
+ */
+ @Override
+ public void build() {
+ if (requestHandlers != null && interceptorChainHead != null) {
+ // on target-side, connect existing handlers and interceptors
+ MessageHandler messageDispatcher = new MessageDispatcher(interceptorChainHead);
+ requestHandlers.add(messageDispatcher);
+ }
+ }
+
+}
Added: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/WireConfiguration.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/WireConfiguration.java?rev=399988&view=auto
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/WireConfiguration.java (added)
+++ incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/WireConfiguration.java Thu May 4 23:29:38 2006
@@ -0,0 +1,82 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.tuscany.spi.wire;
+
+import java.lang.reflect.Method;
+import java.util.Map;
+
+import org.apache.tuscany.spi.QualifiedName;
+
+/**
+ * Contains configuration for a wire, including its invocation chains. Invocation chains are accessed from the
+ * collection of {@link InvocationConfiguration}s keyed by operation on the service specified by the source
+ * reference or target service. <code>WireConfiguration</code> subtypes distinguish between source and target
+ * sides of a wire and hence return corresponding <code>InvocationChain</code> subtypes. Operations are
+ * represented using JDK reflection, i.e. as a <code>Method</code> corresponding to the Java interface
+ * representing the service.
+ * <p/>
+ * Wire configurations are created from an assembly model by the runtime during the buildSource phase.
+ *
+ * @version $Rev: 396284 $ $Date: 2006-04-23 08:27:42 -0700 (Sun, 23 Apr 2006) $
+ */
+public abstract class WireConfiguration<T extends InvocationConfiguration> {
+
+ protected Map<Method, T> configurations;
+
+ protected ClassLoader proxyClassLoader;
+
+ protected QualifiedName targetName;
+
+ /**
+ * Creates the configuration
+ *
+ * @param targetName the qualified name of the target service specified by the wire
+ * @param proxyClassLoader the classloader to use when creating a proxy
+ */
+ public WireConfiguration(QualifiedName targetName, ClassLoader proxyClassLoader) {
+ this.targetName = targetName;
+ if (proxyClassLoader == null) {
+ this.proxyClassLoader = Thread.currentThread().getContextClassLoader();
+ } else {
+ this.proxyClassLoader = proxyClassLoader;
+ }
+ }
+
+ /**
+ * Returns the qualified name of the target service specified by the wire
+ */
+ public QualifiedName getTargetName() {
+ return targetName;
+ }
+
+ /**
+ * Returns the classloader used for creating proxies
+ */
+ public ClassLoader getProxyClassLoader() {
+ return proxyClassLoader;
+ }
+
+ /**
+ * Returns the invocation configuration for each operation on a service specified by a reference or a
+ * target service.
+ */
+ public Map<Method, T> getInvocationConfigurations() {
+ return configurations;
+ }
+
+
+}
Modified: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/WireFactory.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/WireFactory.java?rev=399988&r1=399987&r2=399988&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/WireFactory.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/WireFactory.java Thu May 4 23:29:38 2006
@@ -20,7 +20,7 @@
* Implementations are responsible for managing source or target sides of a wire, including creation of service proxies.
* Source-side wires are injected on references and may contain policy interceptors and/or handlers specified by them. Target-side
* wires may contain policy interceptors and/or handlers specified by the service the wire is targeted to or one of its
- * operations. Source- and target-side <code>WireFactory</code>s are held in the {@link org.apache.tuscany.core.builder.ContextFactory}
+ * operations. Source- and target-side <code>WireFactory</code>s are held in the {@link org.apache.tuscany.spi.context.AtomicContext}
* associated with the source reference or target service.
* <p/>
* When an assembly is built by the runtime, source-side and target-side wires are "bridged" on the source side (i.e. a reference
@@ -61,7 +61,7 @@
/**
* Returns the primary interface type implemented by generated proxies
*/
- public Class getBusinessInterface();
+ public T getBusinessInterface();
/**
* Adds an interface type generated proxies implement
Modified: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/WireSourceConfiguration.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/WireSourceConfiguration.java?rev=399988&r1=399987&r2=399988&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/WireSourceConfiguration.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/WireSourceConfiguration.java Thu May 4 23:29:38 2006
@@ -1,23 +1,65 @@
/**
*
- * Copyright 2006 The Apache Software Foundation or its licensors as applicable
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
*
- * Licensed 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
+ * Licensed 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
+ * 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.
+ * 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.tuscany.spi.wire;
+import org.apache.tuscany.spi.QualifiedName;
+
+import java.lang.reflect.Method;
+import java.util.Map;
+
/**
- * @version $Rev$ $Date$
+ * Contains configuration for the source side of a wire
+ *
+ * @version $Rev: 394379 $ $Date: 2006-04-15 15:01:36 -0700 (Sat, 15 Apr 2006) $
*/
-public class WireSourceConfiguration {
+public class WireSourceConfiguration extends WireConfiguration<SourceInvocationConfiguration> {
+
+ private String referenceName;
+
+ /**
+ * Creates the source side of a wire
+ *
+ * @param referenceName the name of the reference the wire is associated with
+ * @param targetName the qualified name of the target service specified by the wire
+ * @param invocationConfigs a collection of service operation-to-invocation chain mappings
+ * @param proxyClassLoader the classloader to use when creating a proxy
+ */
+ public WireSourceConfiguration(String referenceName, QualifiedName targetName,
+ Map<Method, SourceInvocationConfiguration> invocationConfigs, ClassLoader proxyClassLoader) {
+ super(targetName, proxyClassLoader);
+ this.referenceName = referenceName;
+ this.configurations = invocationConfigs;
+ }
+
+ /**
+ * Creates the source side of a wire where the reference is "anonymous", i.e. on an entry point
+ *
+ * @param targetName the qualified name of the target service specified by the wire
+ * @param invocationConfigs a collection of service operation-to-invocation chain mappings
+ * @param proxyClassLoader the classloader to use when creating a proxy
+ */
+ public WireSourceConfiguration(QualifiedName targetName,
+ Map<Method, SourceInvocationConfiguration> invocationConfigs, ClassLoader proxyClassLoader) {
+ this(null, targetName, invocationConfigs, proxyClassLoader);
+ }
+
+
+ /**
+ * Returns the name of the source reference
+ */
+ public String getReferenceName() {
+ return referenceName;
+ }
+
}
Modified: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/WireTargetConfiguration.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/WireTargetConfiguration.java?rev=399988&r1=399987&r2=399988&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/WireTargetConfiguration.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/wire/WireTargetConfiguration.java Thu May 4 23:29:38 2006
@@ -1,23 +1,30 @@
-/**
- *
- * Copyright 2006 The Apache Software Foundation or its licensors as applicable
- *
- * Licensed 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.tuscany.spi.wire;
+import java.lang.reflect.Method;
+import java.util.Map;
+
+import org.apache.tuscany.spi.QualifiedName;
+
/**
- * @version $Rev$ $Date$
+ * Contains configuration for the target side of a wire
+ *
+ * @version $$Rev$$ $$Date$$
*/
-public class WireTargetConfiguration {
+public class WireTargetConfiguration extends WireConfiguration<TargetInvocationConfiguration> {
+
+ /**
+ * Creates the source side of a wire
+ *
+ * @param targetName the qualified name of the target service specified by the wire
+ * @param invocationConfigs a collection of target service operation-to-invocation chain mappings
+ * @param proxyClassLoader the classloader to use when creating a proxy
+ */
+ public WireTargetConfiguration(QualifiedName targetName, Map<Method, TargetInvocationConfiguration> invocationConfigs,
+ ClassLoader proxyClassLoader) {
+ super(targetName, proxyClassLoader);
+ assert (invocationConfigs != null) : "No wire configuration map specified";
+ configurations = invocationConfigs;
+
+ }
+
}