/** * * 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.core.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.core.builder.WireBuilder}s with the source-side holding references to the target. *
*InvocationChain
s are managed by {@link WireConfiguration}s, which are used by {@link
* org.apache.tuscany.core.wire.WireFactory}s to buildSource wires and proxies.
*
* 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:
* ** * The source-to-target bridge may be constructed in any of the following ways: **
*- The first source interceptor will be called with a message, which will in * turn invoke the next interceptor in the chain
- 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. *
- The RR interceptor will then invoke the target-side request
MessageChannel
. *- The last source-side handler, an instance of {@link org.apache.tuscany.core.wire.impl.MessageDispatcher}, will invoke the * first source-side interceptor, which in turn will pass the message down the target-side interceptor chain. *
- If the target is a component instance the last target-side interceptor, an instance of * {@link org.apache.tuscany.core.wire.impl.InvokerInterceptor} will retrieve the {@link TargetInvoker} from the message and * call it to invoke the operation on a target instance. TargetInvokers are help by * the source proxy to enable optimizations such as caching of target instances.
- The response is returned up the wire * stack * until it reaches the source-side RequestResponseInterceptor, which invokes the target and source-side response * channels respectively. *
- The response is then passed back up the rest of the wire stack.
*