summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/core
diff options
context:
space:
mode:
authorlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2008-11-19 05:27:58 +0000
committerlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2008-11-19 05:27:58 +0000
commit5f3869c451e46aadc943d00087d6847877dd1c50 (patch)
treee22baaff1fb9ea42606b7d04af52e032e3bc03bc /java/sca/modules/core
parent60744a36aae604ac3c4499ed54f1082ab8f5947d (diff)
Merging the 1.x delta on top of the equinox based modules
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@718858 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/core')
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/EndpointWireImpl.java18
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeWireImpl.java85
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/RequestContextImpl.java10
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/InvocationChainImpl.java5
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKProxyFactory.java15
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/MessageImpl.java15
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/NonBlockingInterceptor.java3
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/PhaseManager.java60
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeWireInvoker.java21
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/SCAProxy.java74
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/work/Jsr237WorkScheduler.java2
-rw-r--r--java/sca/modules/core/src/test/resources/META-INF/services/org.apache.tuscany.sca.invocation.PhaseTest4
12 files changed, 283 insertions, 29 deletions
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/EndpointWireImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/EndpointWireImpl.java
index c25c580fe6..4f463b105d 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/EndpointWireImpl.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/EndpointWireImpl.java
@@ -24,6 +24,7 @@ import java.util.List;
import org.apache.tuscany.sca.assembly.Endpoint;
import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.core.invocation.InvocationChainImpl;
import org.apache.tuscany.sca.endpointresolver.EndpointResolver;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.interfacedef.Operation;
@@ -47,6 +48,7 @@ public class EndpointWireImpl implements RuntimeWire {
private EndpointResolver endpointResolver;
private EndpointReference source;
private RuntimeWire wire;
+ private InvocationChain binidngInvocationChain;
/**
* @param endpoint
@@ -126,6 +128,11 @@ public class EndpointWireImpl implements RuntimeWire {
}
}
+ public Object invoke(Message msg) throws InvocationTargetException {
+ // not called as the endpoint wire only appears on the reference side
+ return null;
+ }
+
public Object invoke(Operation operation, Object[] args) throws InvocationTargetException {
// not called as the endpoint wire only appears on the reference side
return null;
@@ -150,6 +157,17 @@ public class EndpointWireImpl implements RuntimeWire {
public void rebuild() {
}
+
+ public synchronized InvocationChain getBindingInvocationChain() {
+ if (binidngInvocationChain == null) {
+ if (source instanceof RuntimeComponentReference) {
+ binidngInvocationChain = new InvocationChainImpl(null, null, true);
+ } else {
+ binidngInvocationChain = new InvocationChainImpl(null, null, false);
+ }
+ }
+ return binidngInvocationChain;
+ }
// TODO: TUSCANY-2580: give RuntimeComponentReferenceImpl a way to get at the endpoint
public Endpoint getEndpoint() {
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeWireImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeWireImpl.java
index 58109fd86b..b6f949f081 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeWireImpl.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeWireImpl.java
@@ -41,10 +41,15 @@ import org.apache.tuscany.sca.invocation.Invoker;
import org.apache.tuscany.sca.invocation.Message;
import org.apache.tuscany.sca.invocation.MessageFactory;
import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
import org.apache.tuscany.sca.provider.ImplementationProvider;
import org.apache.tuscany.sca.provider.PolicyProvider;
+import org.apache.tuscany.sca.provider.PolicyProviderRRB;
import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.provider.ReferenceBindingProviderRRB;
import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.provider.ServiceBindingProviderRRB;
import org.apache.tuscany.sca.runtime.EndpointReference;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
@@ -76,6 +81,7 @@ public class RuntimeWireImpl implements RuntimeWire {
private RuntimeWireImpl clonedFrom;
private List<InvocationChain> chains;
+ private InvocationChain bindingInvocationChain;
/**
* @param source
@@ -110,6 +116,20 @@ public class RuntimeWireImpl implements RuntimeWire {
}
return chains;
}
+
+ public synchronized InvocationChain getBindingInvocationChain() {
+ if (bindingInvocationChain == null) {
+ Contract source = wireSource.getContract();
+ if (source instanceof RuntimeComponentReference) {
+ bindingInvocationChain = new InvocationChainImpl(null, null, true);
+ initReferenceBindingInvocationChains();
+ } else {
+ bindingInvocationChain = new InvocationChainImpl(null, null, false);
+ initServiceBindingInvocationChains();
+ }
+ }
+ return bindingInvocationChain;
+ }
public InvocationChain getInvocationChain(Operation operation) {
for (InvocationChain chain : getInvocationChains()) {
@@ -127,6 +147,10 @@ public class RuntimeWireImpl implements RuntimeWire {
}
return null;
}
+
+ public Object invoke(Message msg) throws InvocationTargetException {
+ return getBindingInvocationChain().getHeadInvoker().invoke(msg);
+ }
public Object invoke(Operation operation, Object[] args) throws InvocationTargetException {
Message msg = messageFactory.createMessage();
@@ -167,6 +191,7 @@ public class RuntimeWireImpl implements RuntimeWire {
addReferenceBindingInterceptor(reference, refBinding, chain, operation);
chains.add(chain);
}
+
} else {
// It's the service wire
RuntimeComponentService service = (RuntimeComponentService)wireTarget.getContract();
@@ -189,9 +214,68 @@ public class RuntimeWireImpl implements RuntimeWire {
addImplementationInterceptor(serviceComponent, service, chain, targetOperation);
chains.add(chain);
}
+
}
wireProcessor.process(this);
}
+
+ private void initReferenceBindingInvocationChains() {
+ RuntimeComponentReference reference = (RuntimeComponentReference)wireSource.getContract();
+ Binding referenceBinding = wireSource.getBinding();
+
+ // add the binding interceptors to the reference binding wire
+ ReferenceBindingProvider provider = reference.getBindingProvider(referenceBinding);
+ if ((provider != null) &&
+ (provider instanceof ReferenceBindingProviderRRB)){
+ ((ReferenceBindingProviderRRB)provider).configureBindingChain(this);
+ }
+
+ // add the policy interceptors to the service binding wire
+ // find out which policies are active
+ List<PolicyProvider> pps = ((RuntimeComponentReference)reference).getPolicyProviders(referenceBinding);
+ if (pps != null) {
+ for (PolicyProvider p : pps) {
+ if (p instanceof PolicyProviderRRB) {
+ Interceptor interceptor = ((PolicyProviderRRB)p).createBindingInterceptor();
+ if (interceptor != null) {
+ bindingInvocationChain.addInterceptor(p.getPhase(), interceptor);
+ }
+ }
+ }
+ }
+ }
+
+ private void initServiceBindingInvocationChains() {
+ RuntimeComponentService service = (RuntimeComponentService)wireTarget.getContract();
+ Binding serviceBinding = wireTarget.getBinding();
+
+ // add the binding interceptors to the service binding wire
+ ServiceBindingProvider provider = service.getBindingProvider(serviceBinding);
+ if ((provider != null) &&
+ (provider instanceof ServiceBindingProviderRRB)){
+ ((ServiceBindingProviderRRB)provider).configureBindingChain(this);
+ }
+
+ // add the policy interceptors to the service binding wire
+ List<PolicyProvider> pps = ((RuntimeComponentService)service).getPolicyProviders(serviceBinding);
+ if (pps != null) {
+ for (PolicyProvider p : pps) {
+ if (p instanceof PolicyProviderRRB) {
+ Interceptor interceptor = ((PolicyProviderRRB)p).createBindingInterceptor();
+ if (interceptor != null) {
+ bindingInvocationChain.addInterceptor(p.getPhase(), interceptor);
+ }
+ }
+ }
+ }
+
+
+ // TODO - add something on the end of the wire to invoke the
+ // invocation chain. Need to split out the runtime
+ // wire invoker into conversation, callback interceptors etc
+ bindingInvocationChain.addInvoker(invoker);
+
+ }
public EndpointReference getSource() {
return wireSource;
@@ -336,6 +420,7 @@ public class RuntimeWireImpl implements RuntimeWire {
copy.wireSource = (EndpointReference)wireSource.clone();
copy.wireTarget = (EndpointReference)wireTarget.clone();
copy.invoker = new RuntimeWireInvoker(copy.messageFactory, copy.conversationManager, copy);
+ copy.cachedWire = null; // TUSCANY-2630
return copy;
}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/RequestContextImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/RequestContextImpl.java
index aa69bb3ae5..ed6c3df8fa 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/RequestContextImpl.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/RequestContextImpl.java
@@ -48,7 +48,15 @@ public class RequestContextImpl implements RequestContext {
}
public Subject getSecuritySubject() {
- throw new UnsupportedOperationException();
+ Subject subject = null;
+
+ for (Object header : ThreadMessageContext.getMessageContext().getHeaders()){
+ if (header instanceof Subject){
+ subject = (Subject)header;
+ break;
+ }
+ }
+ return subject;
}
public String getServiceName() {
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/InvocationChainImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/InvocationChainImpl.java
index c26501e7d7..c559a42bdc 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/InvocationChainImpl.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/InvocationChainImpl.java
@@ -45,8 +45,9 @@ public class InvocationChainImpl implements InvocationChain {
private boolean allowsPassByReference;
public InvocationChainImpl(Operation sourceOperation, Operation targetOperation, boolean forReference) {
- assert sourceOperation != null;
- assert targetOperation != null;
+ // TODO - binding invocation chain doesn't provide operations
+ //assert sourceOperation != null;
+ //assert targetOperation != null;
this.targetOperation = targetOperation;
this.sourceOperation = sourceOperation;
this.forReference = forReference;
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKProxyFactory.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKProxyFactory.java
index 0992638318..a2cbd1365b 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKProxyFactory.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKProxyFactory.java
@@ -19,11 +19,12 @@
package org.apache.tuscany.sca.core.invocation;
import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Proxy;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.List;
+import java.util.HashMap;
+import org.apache.tuscany.sca.core.invocation.SCAProxy;
import org.apache.tuscany.sca.core.context.CallableReferenceImpl;
import org.apache.tuscany.sca.core.context.ServiceReferenceImpl;
import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
@@ -54,7 +55,7 @@ public class JDKProxyFactory implements ProxyFactory {
ServiceReference<T> serviceReference = new ServiceReferenceImpl(interfaze, wire, this);
return createProxy(serviceReference);
}
-
+
public <T> T createProxy(CallableReference<T> callableReference) throws ProxyCreationException {
assert callableReference != null;
final Class<T> interfaze = callableReference.getBusinessInterface();
@@ -62,10 +63,10 @@ public class JDKProxyFactory implements ProxyFactory {
// Allow privileged access to class loader. Requires RuntimePermission in security policy.
ClassLoader cl = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
public ClassLoader run() {
- return interfaze.getClassLoader();
+ return interfaze.getClassLoader();
}
});
- Object proxy = Proxy.newProxyInstance(cl, new Class[] {interfaze}, handler);
+ Object proxy = SCAProxy.newProxyInstance(cl, new Class[] {interfaze}, handler);
((CallableReferenceImpl)callableReference).setProxy(proxy);
return interfaze.cast(proxy);
}
@@ -80,13 +81,13 @@ public class JDKProxyFactory implements ProxyFactory {
Class<T> interfaze = callbackReference.getBusinessInterface();
InvocationHandler handler = new JDKCallbackInvocationHandler(messageFactory, callbackReference);
ClassLoader cl = interfaze.getClassLoader();
- Object proxy = Proxy.newProxyInstance(cl, new Class[] {interfaze}, handler);
+ Object proxy = SCAProxy.newProxyInstance(cl, new Class[] {interfaze}, handler);
callbackReference.setProxy(proxy);
return interfaze.cast(proxy);
}
public <B, R extends CallableReference<B>> R cast(B target) throws IllegalArgumentException {
- InvocationHandler handler = Proxy.getInvocationHandler(target);
+ InvocationHandler handler = SCAProxy.getInvocationHandler(target);
if (handler instanceof JDKInvocationHandler) {
return (R)((JDKInvocationHandler)handler).getCallableReference();
} else {
@@ -98,6 +99,6 @@ public class JDKProxyFactory implements ProxyFactory {
* @see org.apache.tuscany.sca.core.invocation.ProxyFactory#isProxyClass(java.lang.Class)
*/
public boolean isProxyClass(Class<?> clazz) {
- return Proxy.isProxyClass(clazz);
+ return SCAProxy.isProxyClass(clazz);
}
}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/MessageImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/MessageImpl.java
index 7d7fc583c3..a45362a92d 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/MessageImpl.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/MessageImpl.java
@@ -18,8 +18,8 @@
*/
package org.apache.tuscany.sca.core.invocation;
-import java.util.Hashtable;
-import java.util.Map;
+import java.util.ArrayList;
+import java.util.List;
import org.apache.tuscany.sca.core.assembly.EndpointReferenceImpl;
import org.apache.tuscany.sca.interfacedef.Operation;
@@ -32,12 +32,11 @@ import org.apache.tuscany.sca.runtime.EndpointReference;
* @version $Rev $Date$
*/
public class MessageImpl implements Message {
- private Map<String, Object> header = new Hashtable<String, Object>();
+ private List<Object> headers = new ArrayList<Object>();
private Object body;
private Object messageID;
private boolean isFault;
private Operation operation;
- private Map<String, Object> qosContext = new Hashtable<String, Object>();
private EndpointReference from;
private EndpointReference to;
@@ -97,13 +96,9 @@ public class MessageImpl implements Message {
public void setOperation(Operation op) {
this.operation = op;
}
-
- public Map<String, Object> getQoSContext() {
- return qosContext;
- }
- public Map<String, Object> getHeader() {
- return qosContext;
+ public List<Object> getHeaders() {
+ return headers;
}
}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/NonBlockingInterceptor.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/NonBlockingInterceptor.java
index 60f90fb6b5..582d1ee141 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/NonBlockingInterceptor.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/NonBlockingInterceptor.java
@@ -19,6 +19,7 @@
package org.apache.tuscany.sca.core.invocation;
import java.util.LinkedList;
+import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -186,7 +187,7 @@ public class NonBlockingInterceptor implements Interceptor {
return null;
}
- public Map<String, Object> getHeader() {
+ public List<Object> getHeaders() {
return null;
}
}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/PhaseManager.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/PhaseManager.java
index 94d67bffcc..a3c8429c7b 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/PhaseManager.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/PhaseManager.java
@@ -19,6 +19,24 @@
package org.apache.tuscany.sca.core.invocation;
+import static org.apache.tuscany.sca.invocation.Phase.IMPLEMENTATION;
+import static org.apache.tuscany.sca.invocation.Phase.IMPLEMENTATION_POLICY;
+import static org.apache.tuscany.sca.invocation.Phase.REFERENCE;
+import static org.apache.tuscany.sca.invocation.Phase.REFERENCE_BINDING;
+import static org.apache.tuscany.sca.invocation.Phase.REFERENCE_BINDING_POLICY;
+import static org.apache.tuscany.sca.invocation.Phase.REFERENCE_BINDING_TRANSPORT;
+import static org.apache.tuscany.sca.invocation.Phase.REFERENCE_BINDING_WIREFORMAT;
+import static org.apache.tuscany.sca.invocation.Phase.REFERENCE_INTERFACE;
+import static org.apache.tuscany.sca.invocation.Phase.REFERENCE_POLICY;
+import static org.apache.tuscany.sca.invocation.Phase.SERVICE;
+import static org.apache.tuscany.sca.invocation.Phase.SERVICE_BINDING;
+import static org.apache.tuscany.sca.invocation.Phase.SERVICE_BINDING_OPERATION_SELECTOR;
+import static org.apache.tuscany.sca.invocation.Phase.SERVICE_BINDING_POLICY;
+import static org.apache.tuscany.sca.invocation.Phase.SERVICE_BINDING_TRANSPORT;
+import static org.apache.tuscany.sca.invocation.Phase.SERVICE_BINDING_WIREFORMAT;
+import static org.apache.tuscany.sca.invocation.Phase.SERVICE_INTERFACE;
+import static org.apache.tuscany.sca.invocation.Phase.SERVICE_POLICY;
+
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
@@ -42,15 +60,24 @@ public class PhaseManager {
private static final Logger log = Logger.getLogger(PhaseManager.class.getName());
public static final String STAGE_REFERENCE = "reference";
+ public static final String STAGE_REFERENCE_BINDING = "reference.binding";
+ public static final String STAGE_SERVICE_BINDING = "service.binding";
public static final String STAGE_SERVICE = "service";
public static final String STAGE_IMPLEMENTATION = "implementation";
+
private static final String[] SYSTEM_REFERENCE_PHASES =
- {Phase.REFERENCE, Phase.REFERENCE_INTERFACE, Phase.REFERENCE_POLICY, Phase.REFERENCE_BINDING};
+ {REFERENCE, REFERENCE_INTERFACE, REFERENCE_POLICY, REFERENCE_BINDING};
+ private static final String[] SYSTEM_REFERENCE_BINDING_PHASES =
+ {REFERENCE_BINDING_WIREFORMAT, REFERENCE_BINDING_POLICY, REFERENCE_BINDING_TRANSPORT};
+
+ private static final String[] SYSTEM_SERVICE_BINDING_PHASES =
+ {SERVICE_BINDING_TRANSPORT, SERVICE_BINDING_OPERATION_SELECTOR, SERVICE_BINDING_WIREFORMAT, SERVICE_BINDING_POLICY};
+
private static final String[] SYSTEM_SERVICE_PHASES =
- {Phase.SERVICE_BINDING, Phase.SERVICE_POLICY, Phase.SERVICE_INTERFACE, Phase.SERVICE};
+ {SERVICE_BINDING, SERVICE_POLICY, SERVICE_INTERFACE, SERVICE};
- private static final String[] SYSTEM_IMPLEMENTATION_PHASES = {Phase.IMPLEMENTATION_POLICY, Phase.IMPLEMENTATION};
+ private static final String[] SYSTEM_IMPLEMENTATION_PHASES = {IMPLEMENTATION_POLICY, IMPLEMENTATION};
private String pattern = Phase.class.getName();
private Map<String, Stage> stages;
@@ -116,6 +143,14 @@ public class PhaseManager {
return getPhases(STAGE_SERVICE);
}
+ public List<String> getReferenceBindingPhases() {
+ return getPhases(STAGE_REFERENCE_BINDING);
+ }
+
+ public List<String> getServiceBindingPhases() {
+ return getPhases(STAGE_SERVICE_BINDING);
+ }
+
public List<String> getImplementationPhases() {
return getPhases(STAGE_IMPLEMENTATION);
}
@@ -124,6 +159,8 @@ public class PhaseManager {
if (phases == null) {
phases = new ArrayList<String>();
phases.addAll(getReferencePhases());
+ phases.addAll(getReferenceBindingPhases());
+ phases.addAll(getServiceBindingPhases());
phases.addAll(getServicePhases());
phases.addAll(getImplementationPhases());
}
@@ -228,9 +265,22 @@ public class PhaseManager {
for (int i = 1; i < SYSTEM_REFERENCE_PHASES.length; i++) {
referenceStage.getSorter().addEdge(SYSTEM_REFERENCE_PHASES[i - 1], SYSTEM_REFERENCE_PHASES[i]);
}
- referenceStage.getLastSet().add(Phase.REFERENCE_BINDING);
+ referenceStage.getLastSet().add(REFERENCE_BINDING);
stages.put(referenceStage.getName(), referenceStage);
+ Stage referenceBindingStage = new Stage(STAGE_REFERENCE_BINDING);
+ for (int i = 1; i < SYSTEM_REFERENCE_BINDING_PHASES.length; i++) {
+ referenceBindingStage.getSorter().addEdge(SYSTEM_REFERENCE_BINDING_PHASES[i - 1], SYSTEM_REFERENCE_BINDING_PHASES[i]);
+ }
+ stages.put(referenceBindingStage.getName(), referenceBindingStage);
+
+ Stage serviceBindingStage = new Stage(STAGE_SERVICE_BINDING);
+ for (int i = 1; i < SYSTEM_SERVICE_BINDING_PHASES.length; i++) {
+ serviceBindingStage.getSorter().addEdge(SYSTEM_SERVICE_BINDING_PHASES[i - 1], SYSTEM_SERVICE_BINDING_PHASES[i]);
+ }
+ stages.put(serviceBindingStage.getName(), serviceBindingStage);
+
+
Stage serviceStage = new Stage(STAGE_SERVICE);
for (int i = 1; i < SYSTEM_SERVICE_PHASES.length; i++) {
serviceStage.getSorter().addEdge(SYSTEM_SERVICE_PHASES[i - 1], SYSTEM_SERVICE_PHASES[i]);
@@ -242,7 +292,7 @@ public class PhaseManager {
implementationStage.getSorter().addEdge(SYSTEM_IMPLEMENTATION_PHASES[i - 1],
SYSTEM_IMPLEMENTATION_PHASES[i]);
}
- implementationStage.getLastSet().add(Phase.IMPLEMENTATION);
+ implementationStage.getLastSet().add(IMPLEMENTATION);
stages.put(implementationStage.getName(), implementationStage);
}
}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeWireInvoker.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeWireInvoker.java
index c007669bdf..925a7c10a5 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeWireInvoker.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeWireInvoker.java
@@ -47,7 +47,7 @@ import org.osoa.sca.ServiceRuntimeException;
/**
* @version $Rev$ $Date$
*/
-public class RuntimeWireInvoker {
+public class RuntimeWireInvoker implements Invoker{
protected ConversationManager conversationManager;
protected boolean conversational;
protected ExtendedConversation conversation;
@@ -74,6 +74,25 @@ public class RuntimeWireInvoker {
this.conversational = contract.getInterface().isConversational();
}
}
+
+ /*
+ * TODO - Introduced to allow the RuntimeWireInvoker to sit on the end of the
+ * service binding chain. Runtime wire invoke needs splitting up into
+ * separate conversation, callback interceptors etc.
+ */
+ public Message invoke(Message msg) {
+
+ try {
+ Object response = invoke(msg.getOperation(),msg);
+ // Hack to put the response back in a message.
+ // shouldn't take it out of the response message in the first place
+ msg.setBody(response);
+ } catch (InvocationTargetException e) {
+ throw new ServiceRuntimeException(e);
+ }
+
+ return msg;
+ }
public Object invoke(Operation operation, Message msg) throws InvocationTargetException {
return invoke(wire, operation, msg);
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/SCAProxy.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/SCAProxy.java
new file mode 100644
index 0000000000..1112d02b7e
--- /dev/null
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/SCAProxy.java
@@ -0,0 +1,74 @@
+/*
+ * 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.tuscany.sca.core.invocation;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Proxy;
+import java.lang.reflect.Constructor;
+import java.util.WeakHashMap;
+
+public class SCAProxy extends Proxy
+{
+ protected SCAProxy (InvocationHandler handler) {
+ super(handler);
+ }
+
+ // This is a cache containing the proxy class constructor for each business interface.
+ // This improves performance compared to calling Proxy.newProxyInstance()
+ // every time that a proxy is needed.
+ private static WeakHashMap cache = new WeakHashMap<Class, Object>();
+
+ public static Object newProxyInstance(ClassLoader classloader, Class aclass[], InvocationHandler invocationhandler)
+ throws IllegalArgumentException
+ {
+ try {
+ if(invocationhandler == null)
+ throw new NullPointerException();
+ // Lookup cached constructor. aclass[0] is the reference's business interface.
+ Constructor proxyCTOR;
+ synchronized(cache) {
+ proxyCTOR = (Constructor) cache.get(aclass[0]);
+ }
+ if(proxyCTOR == null) {
+ Class proxyClass = getProxyClass(classloader, aclass);
+ proxyCTOR = proxyClass.getConstructor(constructorParams);
+ synchronized(cache){
+ cache.put(aclass[0],proxyCTOR);
+ }
+ }
+ return proxyCTOR.newInstance(new Object[] { invocationhandler });
+ }
+ catch(NoSuchMethodException e) {
+ throw new InternalError(e.toString());
+ }
+ catch(IllegalAccessException e) {
+ throw new InternalError(e.toString());
+ }
+ catch (InstantiationException e) {
+ throw new InternalError(e.toString());
+ }
+ catch (InvocationTargetException e) {
+ throw new InternalError(e.toString());
+ }
+ }
+
+ private static final Class constructorParams[] = { InvocationHandler.class };
+
+} \ No newline at end of file
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/work/Jsr237WorkScheduler.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/work/Jsr237WorkScheduler.java
index 90c13e6da8..ffc34e7328 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/work/Jsr237WorkScheduler.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/work/Jsr237WorkScheduler.java
@@ -65,7 +65,7 @@ public class Jsr237WorkScheduler implements WorkScheduler {
try {
InitialContext ctx = new InitialContext();
jsr237WorkManager = (WorkManager)ctx.lookup("java:comp/env/wm/TuscanyWorkManager");
- } catch (NamingException e) {
+ } catch (Throwable e) {
// ignore
}
if (jsr237WorkManager == null) {
diff --git a/java/sca/modules/core/src/test/resources/META-INF/services/org.apache.tuscany.sca.invocation.PhaseTest b/java/sca/modules/core/src/test/resources/META-INF/services/org.apache.tuscany.sca.invocation.PhaseTest
index 9ed0928a33..ad23df3761 100644
--- a/java/sca/modules/core/src/test/resources/META-INF/services/org.apache.tuscany.sca.invocation.PhaseTest
+++ b/java/sca/modules/core/src/test/resources/META-INF/services/org.apache.tuscany.sca.invocation.PhaseTest
@@ -18,5 +18,7 @@
name=implementation.last, stage=implementation, after=*
name=reference.first, stage=reference, before=*
name=reference.transaction, stage=reference, after=reference.interface
+name=reference.binding.header, stage=reference.binding, after=reference.binding.transport
+name=service.binding.header, stage=service.binding, after=service.binding.transport
name=service.transaction, stage=service, after=service.binding, before=component.service
-name=implementation.transaction, stage=implementation, before=implementation.policy \ No newline at end of file
+name=implementation.transaction, stage=implementation, before=implementation.policy