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/12/27 10:37:01 UTC
svn commit: r490470 - in /incubator/tuscany/java/sca:
kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/
kernel/core/src/main/java/org/apache/tuscany/core/wire/
kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/ kernel/core...
Author: jmarino
Date: Wed Dec 27 01:36:59 2006
New Revision: 490470
URL: http://svn.apache.org/viewvc?view=rev&rev=490470
Log:
optimize creation of JDKOutboundInvocationHandlers by pecomputing method-to-operation mappings
Added:
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/NoMethodForOperationException.java (contents, props changed)
- copied, changed from r490460, incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/NoMethodForOperationException.java
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/WireObjectFactory.java (contents, props changed)
- copied, changed from r490370, incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WireObjectFactory.java
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/WireUtils.java (contents, props changed)
- copied, changed from r490460, incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/WireUtils.java
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/WireObjectFactoryTestCase.java (contents, props changed)
- copied, changed from r490370, incubator/tuscany/java/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/WireObjectFactoryTestCase.java
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/WireUtilsTestCase.java (with props)
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/OutboundChainHolder.java (with props)
incubator/tuscany/java/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/OutboundChainHolderTestCase.java (with props)
incubator/tuscany/java/sca/services/containers/container.script/src/main/java/org/apache/tuscany/container/script/WireObjectFactory.java (with props)
Removed:
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/NoMethodForOperationException.java
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/WireUtils.java
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WireObjectFactory.java
incubator/tuscany/java/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/WireObjectFactoryTestCase.java
Modified:
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaAtomicComponent.java
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKInboundInvocationHandler.java
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandler.java
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKWireService.java
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderReferenceTestCase.java
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaReferenceWireTestCase.java
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/ContractCompatibilityTestCase.java
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/CompositeComponentExtension.java
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/SystemAtomicComponentExtension.java
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WireService.java
incubator/tuscany/java/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/AtomicComponentExtensionTestCase.java
incubator/tuscany/java/sca/services/containers/container.script/src/main/java/org/apache/tuscany/container/script/ScriptComponent.java
incubator/tuscany/java/sca/services/containers/container.script/src/main/java/org/apache/tuscany/container/script/ScriptComponentBuilder.java
Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaAtomicComponent.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaAtomicComponent.java?view=diff&rev=490470&r1=490469&r2=490470
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaAtomicComponent.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaAtomicComponent.java Wed Dec 27 01:36:59 2006
@@ -29,7 +29,7 @@
import org.apache.tuscany.spi.wire.InboundWire;
import org.apache.tuscany.spi.wire.OutboundWire;
import org.apache.tuscany.spi.wire.TargetInvoker;
-import org.apache.tuscany.spi.wire.WireObjectFactory;
+import org.apache.tuscany.core.wire.WireObjectFactory;
import org.apache.tuscany.core.implementation.PojoAtomicComponent;
import org.apache.tuscany.core.implementation.PojoConfiguration;
Copied: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/NoMethodForOperationException.java (from r490460, incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/NoMethodForOperationException.java)
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/NoMethodForOperationException.java?view=diff&rev=490470&p1=incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/NoMethodForOperationException.java&r1=490460&p2=incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/NoMethodForOperationException.java&r2=490470
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/NoMethodForOperationException.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/NoMethodForOperationException.java Wed Dec 27 01:36:59 2006
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.tuscany.core.wire.jdk;
+package org.apache.tuscany.core.wire;
import org.apache.tuscany.spi.wire.ProxyCreationException;
Propchange: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/NoMethodForOperationException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/NoMethodForOperationException.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Copied: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/WireObjectFactory.java (from r490370, incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WireObjectFactory.java)
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/WireObjectFactory.java?view=diff&rev=490470&p1=incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WireObjectFactory.java&r1=490370&p2=incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/WireObjectFactory.java&r2=490470
==============================================================================
--- incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WireObjectFactory.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/WireObjectFactory.java Wed Dec 27 01:36:59 2006
@@ -16,10 +16,17 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.tuscany.spi.wire;
+package org.apache.tuscany.core.wire;
+
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
import org.apache.tuscany.spi.ObjectCreationException;
import org.apache.tuscany.spi.ObjectFactory;
+import org.apache.tuscany.spi.wire.OutboundChainHolder;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.WireService;
/**
* Uses a wire to return an object instance
@@ -28,17 +35,35 @@
*/
public class WireObjectFactory<T> implements ObjectFactory<T> {
private Class<T> interfaze;
- private Wire wire;
+ private OutboundWire wire;
private WireService wireService;
+ // the cache of proxy interface method to operation mappings
+ private Map<Method, OutboundChainHolder> mappings;
- public WireObjectFactory(Class<T> interfaze, Wire wire, WireService wireService) {
+ /**
+ * Constructor.
+ *
+ * @param interfaze the interface to inject on the client
+ * @param wire the backing wire
+ * @param wireService the wire service to create the proxy
+ * @throws NoMethodForOperationException
+ */
+ public WireObjectFactory(Class<T> interfaze, OutboundWire wire, WireService wireService)
+ throws NoMethodForOperationException {
this.interfaze = interfaze;
this.wire = wire;
this.wireService = wireService;
+ this.mappings = WireUtils.createInterfaceToWireMapping(interfaze, wire);
}
public T getInstance() throws ObjectCreationException {
- return interfaze.cast(wireService.createProxy(interfaze, wire));
+ // clone the cached mappings
+ Map<Method, OutboundChainHolder> newChains = new HashMap<Method, OutboundChainHolder>(mappings.size());
+ for (Map.Entry<Method, OutboundChainHolder> entry : mappings.entrySet()) {
+ newChains.put(entry.getKey(), entry.getValue().clone());
+ }
+ return interfaze.cast(wireService.createProxy(interfaze, wire, newChains));
}
+
}
Propchange: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/WireObjectFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/WireObjectFactory.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Copied: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/WireUtils.java (from r490460, incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/WireUtils.java)
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/WireUtils.java?view=diff&rev=490470&p1=incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/WireUtils.java&r1=490460&p2=incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/WireUtils.java&r2=490470
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/WireUtils.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/WireUtils.java Wed Dec 27 01:36:59 2006
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.tuscany.core.wire.jdk;
+package org.apache.tuscany.core.wire;
import java.lang.reflect.Method;
import java.util.HashMap;
@@ -26,6 +26,9 @@
import org.apache.tuscany.spi.model.Operation;
import org.apache.tuscany.spi.wire.InboundInvocationChain;
import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundChainHolder;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+import org.apache.tuscany.spi.wire.OutboundWire;
/**
* Utilities for operating on wires
@@ -59,4 +62,30 @@
}
return chains;
}
+
+
+ /**
+ * Maps methods on an interface to operations on a wire
+ *
+ * @param interfaze the interface to map from
+ * @param wire the wire to map to
+ * @return a collection of method to operation mappings
+ * @throws NoMethodForOperationException
+ */
+ public static Map<Method, OutboundChainHolder> createInterfaceToWireMapping(Class<?> interfaze, OutboundWire wire)
+ throws NoMethodForOperationException {
+ Map<Operation<?>, OutboundInvocationChain> invocationChains = wire.getInvocationChains();
+ Map<Method, OutboundChainHolder> chains = new HashMap<Method, OutboundChainHolder>(invocationChains.size());
+ Method[] methods = interfaze.getMethods();
+ for (Map.Entry<Operation<?>, OutboundInvocationChain> entry : invocationChains.entrySet()) {
+ Operation operation = entry.getKey();
+ Method method = findMethod(operation, methods);
+ if (method == null) {
+ throw new NoMethodForOperationException(operation.getName());
+ }
+ chains.put(method, new OutboundChainHolder(entry.getValue()));
+ }
+ return chains;
+ }
+
}
Propchange: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/WireUtils.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/WireUtils.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKInboundInvocationHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKInboundInvocationHandler.java?view=diff&rev=490470&r1=490469&r2=490470
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKInboundInvocationHandler.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKInboundInvocationHandler.java Wed Dec 27 01:36:59 2006
@@ -38,6 +38,8 @@
import org.apache.tuscany.spi.wire.TargetInvoker;
import org.apache.tuscany.spi.wire.WireInvocationHandler;
+import org.apache.tuscany.core.wire.WireUtils;
+
/**
* Receives a request from a proxy and performs an invocation on an {@link org.apache.tuscany.spi.wire.InboundWire} via
Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandler.java?view=diff&rev=490470&r1=490469&r2=490470
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandler.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandler.java Wed Dec 27 01:36:59 2006
@@ -24,7 +24,6 @@
import java.io.ObjectOutput;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
@@ -37,18 +36,19 @@
import org.apache.tuscany.spi.component.SCAObject;
import org.apache.tuscany.spi.component.TargetInvocationException;
import org.apache.tuscany.spi.component.WorkContext;
-import static org.apache.tuscany.spi.idl.java.JavaIDLUtils.findMethod;
import static org.apache.tuscany.spi.model.InteractionScope.CONVERSATIONAL;
-import org.apache.tuscany.spi.model.Operation;
import org.apache.tuscany.spi.model.Scope;
import org.apache.tuscany.spi.model.ServiceContract;
import org.apache.tuscany.spi.wire.AbstractOutboundInvocationHandler;
+import org.apache.tuscany.spi.wire.OutboundChainHolder;
import org.apache.tuscany.spi.wire.OutboundInvocationChain;
import org.apache.tuscany.spi.wire.OutboundWire;
import org.apache.tuscany.spi.wire.TargetInvoker;
import org.apache.tuscany.spi.wire.WireInvocationHandler;
import org.apache.tuscany.core.implementation.PojoAtomicComponent;
+import org.apache.tuscany.core.wire.NoMethodForOperationException;
+import org.apache.tuscany.core.wire.WireUtils;
/**
@@ -68,7 +68,7 @@
* to a target of greater scope since the target reference can be maintained by the invoker. When a target invoker
* is not cacheable, the master associated with the wire chains will be used.
*/
- private transient Map<Method, ChainHolder> chains;
+ private transient Map<Method, OutboundChainHolder> chains;
private transient WorkContext workContext;
private transient Object fromAddress;
private transient boolean wireContainerIsAtomicComponent;
@@ -92,11 +92,21 @@
throws NoMethodForOperationException {
this.workContext = workContext;
this.interfaze = interfaze;
- init(interfaze, wire);
+ init(interfaze, wire, null);
+ }
+
+ public JDKOutboundInvocationHandler(Class<?> interfaze,
+ OutboundWire wire,
+ Map<Method, OutboundChainHolder> mapping,
+ WorkContext workContext)
+ throws NoMethodForOperationException {
+ this.workContext = workContext;
+ this.interfaze = interfaze;
+ init(interfaze, wire, mapping);
}
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
- ChainHolder holder = chains.get(method);
+ OutboundChainHolder holder = chains.get(method);
if (holder == null) {
if (method.getParameterTypes().length == 0 && "toString".equals(method.getName())) {
return "[Proxy - " + Integer.toHexString(hashCode()) + "]";
@@ -111,10 +121,10 @@
}
throw new TargetInvocationException("Operation not configured", method.getName());
}
- OutboundInvocationChain chain = holder.chain;
+ OutboundInvocationChain chain = holder.getChain();
TargetInvoker invoker;
- if (holder.cachedInvoker == null) {
+ if (holder.getCachedInvoker() == null) {
assert chain != null;
if (chain.getTargetInvoker() == null) {
String name = chain.getOperation().getName();
@@ -122,8 +132,8 @@
}
if (chain.getTargetInvoker().isCacheable()) {
// clone and store the invoker locally
- holder.cachedInvoker = (TargetInvoker) chain.getTargetInvoker().clone();
- invoker = holder.cachedInvoker;
+ holder.setCachedInvoker((TargetInvoker) chain.getTargetInvoker().clone());
+ invoker = holder.getCachedInvoker();
} else {
invoker = chain.getTargetInvoker();
}
@@ -195,13 +205,14 @@
// TODO handle multiplicity
OutboundWire wire = wires.get(0);
try {
- init(interfaze, wire);
+ init(interfaze, wire, null);
} catch (NoMethodForOperationException e) {
throw new ReactivationException(e);
}
}
- private void init(Class<?> interfaze, OutboundWire wire) throws NoMethodForOperationException {
+ private void init(Class<?> interfaze, OutboundWire wire, Map<Method, OutboundChainHolder> mapping)
+ throws NoMethodForOperationException {
ServiceContract contract = wire.getServiceContract();
this.referenceName = wire.getReferenceName();
SCAObject wireContainer = wire.getContainer();
@@ -214,6 +225,7 @@
} else {
this.callbackClassName = null;
}
+ // FIXME JFM this should be done during the callback and not be dependent on PojoAtomicComponent
this.wireContainerIsAtomicComponent = wireContainer instanceof PojoAtomicComponent;
if (wireContainerIsAtomicComponent && contractHasCallback) {
this.callbackIsImplemented =
@@ -221,17 +233,10 @@
} else {
this.callbackIsImplemented = false;
}
- Map<Operation<?>, OutboundInvocationChain> invocationChains = wire.getInvocationChains();
- this.chains = new HashMap<Method, ChainHolder>(invocationChains.size());
- // TODO optimize this
- Method[] methods = interfaze.getMethods();
- for (Map.Entry<Operation<?>, OutboundInvocationChain> entry : invocationChains.entrySet()) {
- Operation operation = entry.getKey();
- Method method = findMethod(operation, methods);
- if (method == null) {
- throw new NoMethodForOperationException(operation.getName());
- }
- this.chains.put(method, new ChainHolder(entry.getValue()));
+ if (mapping == null) {
+ chains = WireUtils.createInterfaceToWireMapping(interfaze, wire);
+ } else {
+ chains = mapping;
}
}
@@ -240,19 +245,5 @@
return UUID.randomUUID().toString();
}
- /**
- * A holder used to associate an wire chain with a local copy of a target invoker that was previously cloned from
- * the chain master
- */
- private class ChainHolder {
-
- OutboundInvocationChain chain;
- TargetInvoker cachedInvoker;
-
- public ChainHolder(OutboundInvocationChain config) {
- this.chain = config;
- }
-
- }
}
Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKWireService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKWireService.java?view=diff&rev=490470&r1=490469&r2=490470
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKWireService.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKWireService.java Wed Dec 27 01:36:59 2006
@@ -19,6 +19,8 @@
package org.apache.tuscany.core.wire.jdk;
import java.lang.reflect.Proxy;
+import java.lang.reflect.Method;
+import java.util.Map;
import org.osoa.sca.annotations.Constructor;
import org.osoa.sca.annotations.Init;
@@ -31,6 +33,7 @@
import org.apache.tuscany.spi.wire.ProxyCreationException;
import org.apache.tuscany.spi.wire.Wire;
import org.apache.tuscany.spi.wire.WireInvocationHandler;
+import org.apache.tuscany.spi.wire.OutboundChainHolder;
import org.apache.tuscany.core.wire.WireServiceExtension;
@@ -55,7 +58,28 @@
}
public <T> T createProxy(Class<T> interfaze, Wire wire) throws ProxyCreationException {
- assert wire != null : "Wire was null";
+ assert interfaze != null;
+ assert wire != null;
+ if (wire instanceof InboundWire) {
+ InboundWire inbound = (InboundWire) wire;
+ JDKInboundInvocationHandler handler = new JDKInboundInvocationHandler(interfaze, inbound, context);
+ ClassLoader cl = interfaze.getClassLoader();
+ return interfaze.cast(Proxy.newProxyInstance(cl, new Class[]{interfaze}, handler));
+ } else if (wire instanceof OutboundWire) {
+ OutboundWire outbound = (OutboundWire) wire;
+ JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(interfaze, outbound, context);
+ ClassLoader cl = interfaze.getClassLoader();
+ return interfaze.cast(Proxy.newProxyInstance(cl, new Class[]{interfaze}, handler));
+ } else {
+ throw new ProxyCreationException("Invalid wire type", wire.getClass().getName());
+ }
+ }
+
+ public <T> T createProxy(Class<T> interfaze, Wire wire, Map<Method, OutboundChainHolder> mapping)
+ throws ProxyCreationException {
+ assert interfaze != null;
+ assert wire != null;
+ assert mapping != null;
if (wire instanceof InboundWire) {
InboundWire inbound = (InboundWire) wire;
JDKInboundInvocationHandler handler = new JDKInboundInvocationHandler(interfaze, inbound, context);
Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderReferenceTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderReferenceTestCase.java?view=diff&rev=490470&r1=490469&r2=490470
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderReferenceTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaComponentBuilderReferenceTestCase.java Wed Dec 27 01:36:59 2006
@@ -136,7 +136,7 @@
Map<Operation<?>, OutboundInvocationChain> chains = Collections.emptyMap();
wire = EasyMock.createMock(OutboundWire.class);
EasyMock.expect(wire.getReferenceName()).andReturn("target").atLeastOnce();
- EasyMock.expect(wire.getInvocationChains()).andReturn(chains);
+ EasyMock.expect(wire.getInvocationChains()).andReturn(chains).atLeastOnce();
JavaServiceContract targetContract = new JavaServiceContract(Target.class);
targetContract.setInteractionScope(InteractionScope.NONCONVERSATIONAL);
EasyMock.expect(wire.getServiceContract()).andReturn(targetContract).atLeastOnce();
Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaReferenceWireTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaReferenceWireTestCase.java?view=diff&rev=490470&r1=490469&r2=490470
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaReferenceWireTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/JavaReferenceWireTestCase.java Wed Dec 27 01:36:59 2006
@@ -44,6 +44,7 @@
*/
public class JavaReferenceWireTestCase extends TestCase {
+ @SuppressWarnings({"unchecked"})
public void testReferenceSet() throws Exception {
ScopeContainer scope = createMock();
scope.start();
@@ -55,11 +56,11 @@
configuration.setScopeContainer(scope);
OutboundWire wire = EasyMock.createMock(OutboundWire.class);
wire.getInvocationChains();
- EasyMock.expectLastCall().andReturn(new HashMap<Operation<?>, OutboundInvocationChain>());
+ EasyMock.expectLastCall().andReturn(new HashMap<Operation<?>, OutboundInvocationChain>()).atLeastOnce();
EasyMock.expect(wire.getReferenceName()).andReturn("target").atLeastOnce();
EasyMock.replay(wire);
WireService service = EasyMock.createMock(WireService.class);
- EasyMock.expect(service.createProxy(EasyMock.eq(Target.class), EasyMock.eq(wire)))
+ EasyMock.expect(service.createProxy(EasyMock.eq(Target.class), EasyMock.eq(wire), EasyMock.isA(Map.class)))
.andAnswer(new IAnswer<Target>() {
public Target answer() throws Throwable {
OutboundWire wire = (OutboundWire) EasyMock.getCurrentArguments()[1];
Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/ContractCompatibilityTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/ContractCompatibilityTestCase.java?view=diff&rev=490470&r1=490469&r2=490470
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/ContractCompatibilityTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/ContractCompatibilityTestCase.java Wed Dec 27 01:36:59 2006
@@ -19,6 +19,7 @@
package org.apache.tuscany.core.wire;
import java.lang.reflect.Type;
+import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -44,6 +45,7 @@
import org.apache.tuscany.spi.wire.Wire;
import org.apache.tuscany.spi.wire.WireInvocationHandler;
import org.apache.tuscany.spi.wire.WireService;
+import org.apache.tuscany.spi.wire.OutboundChainHolder;
import junit.framework.TestCase;
@@ -354,6 +356,11 @@
}
public <T> T createProxy(Class<T> interfaze, Wire wire) throws ProxyCreationException {
+ throw new UnsupportedOperationException();
+ }
+
+ public <T> T createProxy(Class<T> interfaze, Wire wire, Map<Method, OutboundChainHolder> mapping)
+ throws ProxyCreationException {
throw new UnsupportedOperationException();
}
Copied: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/WireObjectFactoryTestCase.java (from r490370, incubator/tuscany/java/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/WireObjectFactoryTestCase.java)
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/WireObjectFactoryTestCase.java?view=diff&rev=490470&p1=incubator/tuscany/java/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/WireObjectFactoryTestCase.java&r1=490370&p2=incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/WireObjectFactoryTestCase.java&r2=490470
==============================================================================
--- incubator/tuscany/java/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/WireObjectFactoryTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/WireObjectFactoryTestCase.java Wed Dec 27 01:36:59 2006
@@ -16,27 +16,48 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.tuscany.spi.wire;
+package org.apache.tuscany.core.wire;
+
+import java.lang.reflect.Type;
+import java.util.Map;
+
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.WireService;
import junit.framework.TestCase;
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expectLastCall;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
+import org.easymock.EasyMock;
/**
* @version $Rev$ $Date$
*/
public class WireObjectFactoryTestCase extends TestCase {
+ @SuppressWarnings({"unchecked"})
public void testCreateInstance() throws Exception {
- Wire wire = createMock(Wire.class);
- WireService service = createMock(WireService.class);
- service.createProxy(Object.class, wire);
- expectLastCall().andReturn(null);
- replay(service);
- WireObjectFactory<Object> factory = new WireObjectFactory<Object>(Object.class, wire, service);
+ OutboundWire wire = new OutboundWireImpl();
+ Operation<Type> op = new Operation<Type>("hello", null, null, null);
+ OutboundInvocationChain chain = new OutboundInvocationChainImpl(op);
+ wire.addInvocationChain(op, chain);
+
+ WireService service = EasyMock.createMock(WireService.class);
+ service.createProxy(EasyMock.eq(Foo.class), EasyMock.eq(wire), EasyMock.isA(Map.class));
+ EasyMock.expectLastCall().andReturn(new Foo() {
+ public void hello() {
+
+ }
+ });
+ EasyMock.replay(service);
+
+ WireObjectFactory<Foo> factory = new WireObjectFactory<Foo>(Foo.class, wire, service);
factory.getInstance();
- verify(service);
+ EasyMock.verify(service);
}
+
+
+ private interface Foo {
+ void hello();
+ }
+
}
Propchange: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/WireObjectFactoryTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/WireObjectFactoryTestCase.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/WireUtilsTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/WireUtilsTestCase.java?view=auto&rev=490470
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/WireUtilsTestCase.java (added)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/WireUtilsTestCase.java Wed Dec 27 01:36:59 2006
@@ -0,0 +1,94 @@
+/*
+ * 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.core.wire;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.util.Map;
+
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.InboundInvocationChain;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundChainHolder;
+import org.apache.tuscany.spi.wire.OutboundInvocationChain;
+import org.apache.tuscany.spi.wire.OutboundWire;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WireUtilsTestCase extends TestCase {
+ private Method m;
+
+ public void testCreateInterfaceToWireMapping() throws Exception {
+ OutboundWire wire = new OutboundWireImpl();
+ Operation<Type> op = new Operation<Type>("hello", null, null, null);
+ OutboundInvocationChain chain = new OutboundInvocationChainImpl(op);
+ wire.addInvocationChain(op, chain);
+ Map<Method, OutboundChainHolder> chains = WireUtils.createInterfaceToWireMapping(Foo.class, wire);
+ assertEquals(1, chains.size());
+ assertNotNull(chains.get(m));
+ }
+
+ public void testCreateInterfaceToWireMappingNoOperation() throws Exception {
+ OutboundWire wire = new OutboundWireImpl();
+ Operation<Type> op = new Operation<Type>("goodbye", null, null, null);
+ OutboundInvocationChain chain = new OutboundInvocationChainImpl(op);
+ wire.addInvocationChain(op, chain);
+ try {
+ WireUtils.createInterfaceToWireMapping(Foo.class, wire);
+ fail();
+ } catch (NoMethodForOperationException e) {
+ // expected
+ }
+ }
+
+ public void testCreateInboundMapping() throws Exception {
+ InboundWire wire = new InboundWireImpl();
+ Operation<Type> op = new Operation<Type>("hello", null, null, null);
+ InboundInvocationChain chain = new InboundInvocationChainImpl(op);
+ wire.addInvocationChain(op, chain);
+ Map<Method, InboundInvocationChain> chains = WireUtils.createInboundMapping(wire, new Method[]{m});
+ assertEquals(1, chains.size());
+ assertNotNull(chains.get(m));
+ }
+
+ public void testCreateInboundMappingNoOperation() throws Exception {
+ InboundWire wire = new InboundWireImpl();
+ Operation<Type> op = new Operation<Type>("goodbye", null, null, null);
+ InboundInvocationChain chain = new InboundInvocationChainImpl(op);
+ wire.addInvocationChain(op, chain);
+ try {
+ WireUtils.createInboundMapping(wire, new Method[]{m});
+ fail();
+ } catch (NoMethodForOperationException e) {
+ // expected
+ }
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ m = Foo.class.getMethod("hello");
+ }
+
+ private interface Foo {
+ void hello();
+ }
+}
Propchange: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/WireUtilsTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/WireUtilsTestCase.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/CompositeComponentExtension.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/CompositeComponentExtension.java?view=diff&rev=490470&r1=490469&r2=490470
==============================================================================
--- incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/CompositeComponentExtension.java (original)
+++ incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/CompositeComponentExtension.java Wed Dec 27 01:36:59 2006
@@ -437,7 +437,8 @@
return;
}
for (InboundWire wire : component.getInboundWires().values()) {
- if (wire.getServiceContract().getInterfaceClass().isAssignableFrom(interfaze)) {
+ Class<?> clazz = wire.getServiceContract().getInterfaceClass();
+ if (clazz.isAssignableFrom(interfaze)) {
systemAutowireInternal.put(interfaze, wire);
return;
}
Modified: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/SystemAtomicComponentExtension.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/SystemAtomicComponentExtension.java?view=diff&rev=490470&r1=490469&r2=490470
==============================================================================
--- incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/SystemAtomicComponentExtension.java (original)
+++ incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/SystemAtomicComponentExtension.java Wed Dec 27 01:36:59 2006
@@ -18,8 +18,6 @@
*/
package org.apache.tuscany.spi.extension;
-import java.util.List;
-
import org.apache.tuscany.spi.component.CompositeComponent;
import org.apache.tuscany.spi.component.ScopeContainer;
import org.apache.tuscany.spi.model.Operation;
Added: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/OutboundChainHolder.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/OutboundChainHolder.java?view=auto&rev=490470
==============================================================================
--- incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/OutboundChainHolder.java (added)
+++ incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/OutboundChainHolder.java Wed Dec 27 01:36:59 2006
@@ -0,0 +1,38 @@
+package org.apache.tuscany.spi.wire;
+
+/**
+ * A holder used to associate an wire chain with a local copy of a target invoker that was previously cloned from the
+ * chain master
+ *
+ * @version $Rev$ $Date$
+ */
+public class OutboundChainHolder implements Cloneable {
+ OutboundInvocationChain chain;
+ TargetInvoker cachedInvoker;
+
+ public OutboundChainHolder(OutboundInvocationChain config) {
+ this.chain = config;
+ }
+
+ public OutboundInvocationChain getChain() {
+ return chain;
+ }
+
+ public TargetInvoker getCachedInvoker() {
+ return cachedInvoker;
+ }
+
+ public void setCachedInvoker(TargetInvoker invoker) {
+ this.cachedInvoker = invoker;
+ }
+
+ @SuppressWarnings({"CloneDoesntDeclareCloneNotSupportedException"})
+ @Override
+ public OutboundChainHolder clone() {
+ try {
+ return (OutboundChainHolder) super.clone();
+ } catch (CloneNotSupportedException e) {
+ throw new AssertionError();
+ }
+ }
+}
Propchange: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/OutboundChainHolder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/OutboundChainHolder.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WireService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WireService.java?view=diff&rev=490470&r1=490469&r2=490470
==============================================================================
--- incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WireService.java (original)
+++ incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WireService.java Wed Dec 27 01:36:59 2006
@@ -18,6 +18,9 @@
*/
package org.apache.tuscany.spi.wire;
+import java.lang.reflect.Method;
+import java.util.Map;
+
import org.apache.tuscany.spi.component.Component;
import org.apache.tuscany.spi.component.Reference;
import org.apache.tuscany.spi.component.Service;
@@ -44,6 +47,18 @@
<T> T createProxy(Class<T> interfaze, Wire wire) throws ProxyCreationException;
/**
+ * Creates a Java proxy for the given wire
+ *
+ * @param interfaze the interface the proxy implements
+ * @param wire the wire to proxy @return the proxy
+ * @param mapping the method to chain holder mapping to use in creating the proxy. Clients may cache and resuse
+ * this mapping for performance.
+ * @throws ProxyCreationException
+ */
+ <T> T createProxy(Class<T> interfaze, Wire wire, Map<Method, OutboundChainHolder> mapping)
+ throws ProxyCreationException;
+
+ /**
* Creates a Java proxy for the service contract callback
*
* @param interfaze the interface the proxy should implement
@@ -56,7 +71,7 @@
* Creates an {@link WireInvocationHandler} for the given wire
*
* @param interfaze the client side interface
- * @param wire the wire to create the invocation handler for
+ * @param wire the wire to create the invocation handler for
* @return the invocation handler
*/
WireInvocationHandler createHandler(Class<?> interfaze, Wire wire);
Modified: incubator/tuscany/java/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/AtomicComponentExtensionTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/AtomicComponentExtensionTestCase.java?view=diff&rev=490470&r1=490469&r2=490470
==============================================================================
--- incubator/tuscany/java/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/AtomicComponentExtensionTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/AtomicComponentExtensionTestCase.java Wed Dec 27 01:36:59 2006
@@ -18,8 +18,6 @@
*/
package org.apache.tuscany.spi.extension;
-import java.util.List;
-
import org.apache.tuscany.spi.ObjectCreationException;
import org.apache.tuscany.spi.component.ScopeContainer;
import org.apache.tuscany.spi.component.TargetResolutionException;
Added: incubator/tuscany/java/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/OutboundChainHolderTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/OutboundChainHolderTestCase.java?view=auto&rev=490470
==============================================================================
--- incubator/tuscany/java/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/OutboundChainHolderTestCase.java (added)
+++ incubator/tuscany/java/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/OutboundChainHolderTestCase.java Wed Dec 27 01:36:59 2006
@@ -0,0 +1,35 @@
+/*
+ * 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.spi.wire;
+
+import junit.framework.TestCase;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class OutboundChainHolderTestCase extends TestCase {
+
+ public void testClone() {
+ OutboundInvocationChain chain = EasyMock.createMock(OutboundInvocationChain.class);
+ EasyMock.replay(chain);
+ OutboundChainHolder holder = new OutboundChainHolder(chain);
+ assertNotNull(holder.clone());
+ }
+}
Propchange: incubator/tuscany/java/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/OutboundChainHolderTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/OutboundChainHolderTestCase.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/java/sca/services/containers/container.script/src/main/java/org/apache/tuscany/container/script/ScriptComponent.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/services/containers/container.script/src/main/java/org/apache/tuscany/container/script/ScriptComponent.java?view=diff&rev=490470&r1=490469&r2=490470
==============================================================================
--- incubator/tuscany/java/sca/services/containers/container.script/src/main/java/org/apache/tuscany/container/script/ScriptComponent.java (original)
+++ incubator/tuscany/java/sca/services/containers/container.script/src/main/java/org/apache/tuscany/container/script/ScriptComponent.java Wed Dec 27 01:36:59 2006
@@ -19,10 +19,8 @@
package org.apache.tuscany.container.script;
import java.lang.reflect.Method;
-import java.util.List;
import org.apache.tuscany.spi.ObjectCreationException;
-import org.apache.tuscany.spi.component.TargetNotFoundException;
import org.apache.tuscany.spi.component.TargetResolutionException;
import org.apache.tuscany.spi.extension.AtomicComponentExtension;
import static org.apache.tuscany.spi.idl.java.JavaIDLUtils.findMethod;
@@ -30,7 +28,6 @@
import org.apache.tuscany.spi.wire.InboundWire;
import org.apache.tuscany.spi.wire.OutboundWire;
import org.apache.tuscany.spi.wire.TargetInvoker;
-import org.apache.tuscany.spi.wire.WireObjectFactory;
/**
* A component implementation for script languages.
@@ -64,6 +61,7 @@
return new ScriptTargetInvoker(method.getName(), this);
}
+ @SuppressWarnings({"unchecked"})
protected void onReferenceWire(OutboundWire wire) {
Class<?> clazz = wire.getServiceContract().getInterfaceClass();
factory.addContextObjectFactory(wire.getReferenceName(), new WireObjectFactory(clazz, wire, wireService));
Modified: incubator/tuscany/java/sca/services/containers/container.script/src/main/java/org/apache/tuscany/container/script/ScriptComponentBuilder.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/services/containers/container.script/src/main/java/org/apache/tuscany/container/script/ScriptComponentBuilder.java?view=diff&rev=490470&r1=490469&r2=490470
==============================================================================
--- incubator/tuscany/java/sca/services/containers/container.script/src/main/java/org/apache/tuscany/container/script/ScriptComponentBuilder.java (original)
+++ incubator/tuscany/java/sca/services/containers/container.script/src/main/java/org/apache/tuscany/container/script/ScriptComponentBuilder.java Wed Dec 27 01:36:59 2006
@@ -35,6 +35,8 @@
/**
* Extension point for creating {@link ScriptComponent}s from an assembly configuration
+ *
+ * @version $Rev$ $Date$
*/
public class ScriptComponentBuilder extends ComponentBuilderExtension<ScriptImplementation> {
Added: incubator/tuscany/java/sca/services/containers/container.script/src/main/java/org/apache/tuscany/container/script/WireObjectFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/services/containers/container.script/src/main/java/org/apache/tuscany/container/script/WireObjectFactory.java?view=auto&rev=490470
==============================================================================
--- incubator/tuscany/java/sca/services/containers/container.script/src/main/java/org/apache/tuscany/container/script/WireObjectFactory.java (added)
+++ incubator/tuscany/java/sca/services/containers/container.script/src/main/java/org/apache/tuscany/container/script/WireObjectFactory.java Wed Dec 27 01:36:59 2006
@@ -0,0 +1,50 @@
+/*
+ * 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.container.script;
+
+import org.apache.tuscany.spi.ObjectCreationException;
+import org.apache.tuscany.spi.ObjectFactory;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.WireService;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WireObjectFactory<T> implements ObjectFactory<T> {
+ private Class<T> interfaze;
+ private OutboundWire wire;
+ private WireService wireService;
+
+ /**
+ * Constructor.
+ *
+ * @param interfaze the interface to inject on the client
+ * @param wire the backing wire
+ * @param wireService the wire service to create the proxy
+ */
+ public WireObjectFactory(Class<T> interfaze, OutboundWire wire, WireService wireService) {
+ this.interfaze = interfaze;
+ this.wire = wire;
+ this.wireService = wireService;
+ }
+
+ public T getInstance() throws ObjectCreationException {
+ return interfaze.cast(wireService.createProxy(interfaze, wire));
+ }
+}
Propchange: incubator/tuscany/java/sca/services/containers/container.script/src/main/java/org/apache/tuscany/container/script/WireObjectFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/services/containers/container.script/src/main/java/org/apache/tuscany/container/script/WireObjectFactory.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org