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/02/23 08:50:16 UTC
svn commit: r380065 - in /incubator/tuscany/java/sca:
container.java/src/main/java/org/apache/tuscany/container/java/config/
container.java/src/main/java/org/apache/tuscany/container/java/handler/
container.java/src/main/java/org/apache/tuscany/contain...
Author: jmarino
Date: Wed Feb 22 23:50:11 2006
New Revision: 380065
URL: http://svn.apache.org/viewcvs?rev=380065&view=rev
Log:
code cleanup, removal of FIXMEs
Removed:
incubator/tuscany/java/sca/container.java/src/main/java/org/apache/tuscany/container/java/handler/impl/
Modified:
incubator/tuscany/java/sca/container.java/src/main/java/org/apache/tuscany/container/java/config/JavaComponentRuntimeConfiguration.java
incubator/tuscany/java/sca/container.java/src/main/java/org/apache/tuscany/container/java/handler/ScopedJavaComponentInvoker.java
incubator/tuscany/java/sca/container.java/src/main/java/org/apache/tuscany/container/java/injection/ReferenceProxyTargetFactory.java
incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/Interceptor.java
incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/InvocationRuntimeException.java
incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/TargetInvoker.java
incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/impl/InvokerInterceptor.java
incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/JDKInvocationHandler.java
incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/JDKProxyFactory.java
incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/message/channel/MessageChannel.java
incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/message/channel/impl/MessageDispatcher.java
Modified: incubator/tuscany/java/sca/container.java/src/main/java/org/apache/tuscany/container/java/config/JavaComponentRuntimeConfiguration.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/container.java/src/main/java/org/apache/tuscany/container/java/config/JavaComponentRuntimeConfiguration.java?rev=380065&r1=380064&r2=380065&view=diff
==============================================================================
--- incubator/tuscany/java/sca/container.java/src/main/java/org/apache/tuscany/container/java/config/JavaComponentRuntimeConfiguration.java (original)
+++ incubator/tuscany/java/sca/container.java/src/main/java/org/apache/tuscany/container/java/config/JavaComponentRuntimeConfiguration.java Wed Feb 22 23:50:11 2006
@@ -42,7 +42,6 @@
private Constructor ctr;
// injectors for properties, references and other metadata values such as
- // @Context
private List<Injector> setters;
// an invoker for a method decorated with @Init
@@ -113,8 +112,6 @@
return new JavaComponentContext(name, objectFactory, eagerInit, init, destroy, stateless);
}
- // //
-
private Map<String, ProxyFactory> targetProxyFactories = new HashMap();
public void addTargetProxyFactory(String serviceName, ProxyFactory factory) {
@@ -150,45 +147,5 @@
public void prepare(){
}
-
-
-//
-// private Injector createReferenceInjector(ProxyFactory factory,
-// Set<Field> fields, Set<Method> methods) throws NoAccessorException, BuilderConfigException {
-// String refName = reference.getReference().getName();
-// List<ConfiguredService> services = reference.getConfiguredServices();
-// Class type;
-// // FIXME added the size check - do we need to do this?
-// if (services.size() == 1) {
-// // get the interface
-// type = reference.getReference().getInterfaceContract().getInterfaceType().getInstanceClass();
-// } else {
-// // FIXME do we support arrays?
-// type = List.class;
-// }
-//
-// Method method = null;
-//
-// Field field = JavaIntrospectionHelper.findClosestMatchingField(refName, type, fields);
-// if (field == null) {
-// method = JavaIntrospectionHelper.findClosestMatchingMethod(refName, new Class[] { type }, methods);
-// if (method == null) {
-// throw new NoAccessorException(refName);
-// }
-// }
-// Injector injector;
-// try {
-// if (field != null) {
-// injector = new FieldInjector(field, new ReferenceProxyTargetFactory(reference));
-// } else {
-// injector = new MethodInjector(method, new ReferenceProxyTargetFactory(reference));
-// }
-// } catch (FactoryInitException e) {
-// BuilderConfigException ce = new BuilderConfigException("Error configuring reference", e);
-// ce.setIdentifier(refName);
-// throw ce;
-// }
-// return injector;
-// }
-
+
}
Modified: incubator/tuscany/java/sca/container.java/src/main/java/org/apache/tuscany/container/java/handler/ScopedJavaComponentInvoker.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/container.java/src/main/java/org/apache/tuscany/container/java/handler/ScopedJavaComponentInvoker.java?rev=380065&r1=380064&r2=380065&view=diff
==============================================================================
--- incubator/tuscany/java/sca/container.java/src/main/java/org/apache/tuscany/container/java/handler/ScopedJavaComponentInvoker.java (original)
+++ incubator/tuscany/java/sca/container.java/src/main/java/org/apache/tuscany/container/java/handler/ScopedJavaComponentInvoker.java Wed Feb 22 23:50:11 2006
@@ -37,22 +37,6 @@
public boolean cacheable;
- /**
- * Constructs a new component invoker for a given operation.
- *
- * @param serviceName the name of the target service
- * @param operation the method on the target object to invoke corresponding to the operation
- * @param container the scope container managing the service instance
- * @deprecated
- */
- public ScopedJavaComponentInvoker(String serviceName, Method operation, ScopeContext container) {
- super(operation);
- assert (serviceName != null) : "No service name specified";
- assert (container != null) : "No scope container specified";
- name = new QualifiedName(serviceName);
- this.container = container;
- }
-
public ScopedJavaComponentInvoker(QualifiedName serviceName, Method operation, ScopeContext container) {
super(operation);
assert (serviceName != null) : "No service name specified";
Modified: incubator/tuscany/java/sca/container.java/src/main/java/org/apache/tuscany/container/java/injection/ReferenceProxyTargetFactory.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/container.java/src/main/java/org/apache/tuscany/container/java/injection/ReferenceProxyTargetFactory.java?rev=380065&r1=380064&r2=380065&view=diff
==============================================================================
--- incubator/tuscany/java/sca/container.java/src/main/java/org/apache/tuscany/container/java/injection/ReferenceProxyTargetFactory.java (original)
+++ incubator/tuscany/java/sca/container.java/src/main/java/org/apache/tuscany/container/java/injection/ReferenceProxyTargetFactory.java Wed Feb 22 23:50:11 2006
@@ -15,14 +15,6 @@
*/
public class ReferenceProxyTargetFactory<T> implements ObjectFactory<T> {
- //FIXME we don't need to cache this information here
- // the logical model reference
- private ConfiguredReference reference;
-
- //FIXME we don't need to cache this information here
- // the SCDL name of the target component/service for this reference
- private String targetName;
-
// the proxy factory for the reference
private ProxyFactory<T> factory;
@@ -31,10 +23,7 @@
// ----------------------------------
public ReferenceProxyTargetFactory(ConfiguredReference reference) throws FactoryInitException {
- // FIXME how to handle a reference that is a list - may take different proxy factories for each entry
assert (reference != null) : "Reference was null";
- this.reference = reference;
- // FIXME should not need the cast to ProxyFactory
factory = (ProxyFactory) reference.getProxyFactory();
if (factory == null) {
throw new FactoryInitException("No proxy factory found");
Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/Interceptor.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/Interceptor.java?rev=380065&r1=380064&r2=380065&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/Interceptor.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/Interceptor.java Wed Feb 22 23:50:11 2006
@@ -24,6 +24,7 @@
* @version $Rev$ $Date$
*/
public interface Interceptor {
+
/**
* Process a synchronous invocation.
*
Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/InvocationRuntimeException.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/InvocationRuntimeException.java?rev=380065&r1=380064&r2=380065&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/InvocationRuntimeException.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/InvocationRuntimeException.java Wed Feb 22 23:50:11 2006
@@ -19,7 +19,7 @@
import org.osoa.sca.ServiceRuntimeException;
/**
- * Denotes an exception thrown during the processign of an invocation
+ * Denotes an exception thrown during invocation processing
*
* @version $Rev$ $Date$
*/
Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/TargetInvoker.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/TargetInvoker.java?rev=380065&r1=380064&r2=380065&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/TargetInvoker.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/TargetInvoker.java Wed Feb 22 23:50:11 2006
@@ -19,19 +19,19 @@
import java.lang.reflect.InvocationTargetException;
/**
- * Implementations are responsible for resolving a target and performing the actual invocation on it, for example, a service
- * component implementation instance or an external service client.
+ * Implementations are responsible for resolving a target and performing the actual invocation on it, for example, a
+ * service component implementation instance or an external service client.
*
* @version $Rev$ $Date$
*/
-public interface TargetInvoker extends Interceptor{
+public interface TargetInvoker extends Interceptor {
/**
* Responsible for invoking an operation on a target with the given payload
*
* @param payload the parameters of the target operation or null
- * @throws InvocationTargetException if the target operation itself throws an exception. The root cause will be set to that
- * exception
+ * @throws InvocationTargetException if the target operation itself throws an exception. The root cause will be set
+ * to that exception
*/
public Object invokeTarget(Object payload) throws InvocationTargetException;
Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/impl/InvokerInterceptor.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/impl/InvokerInterceptor.java?rev=380065&r1=380064&r2=380065&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/impl/InvokerInterceptor.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/impl/InvokerInterceptor.java Wed Feb 22 23:50:11 2006
@@ -14,6 +14,7 @@
package org.apache.tuscany.core.invocation.impl;
import org.apache.tuscany.core.invocation.Interceptor;
+import org.apache.tuscany.core.invocation.InvocationRuntimeException;
import org.apache.tuscany.core.invocation.TargetInvoker;
import org.apache.tuscany.core.message.Message;
@@ -30,11 +31,10 @@
public InvokerInterceptor() {
}
- public Message invoke(Message msg) {
+ public Message invoke(Message msg) throws InvocationRuntimeException {
TargetInvoker invoker = msg.getTargetInvoker();
if (invoker == null) {
- // FIXME
- // throw new ProxyOperationException("No target invoker specified on message");
+ throw new InvocationRuntimeException("No target invoker specified on message");
}
return invoker.invoke(msg);
}
Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/JDKInvocationHandler.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/JDKInvocationHandler.java?rev=380065&r1=380064&r2=380065&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/JDKInvocationHandler.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/JDKInvocationHandler.java Wed Feb 22 23:50:11 2006
@@ -79,11 +79,11 @@
Message resp = headInterceptor.invoke(msg);
Object body = resp.getBody();
- if (body instanceof Throwable)
+ if (body instanceof Throwable) {
throw (Throwable) body;
+ }
return body;
}
}
-
}
Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/JDKProxyFactory.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/JDKProxyFactory.java?rev=380065&r1=380064&r2=380065&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/JDKProxyFactory.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/JDKProxyFactory.java Wed Feb 22 23:50:11 2006
@@ -34,6 +34,14 @@
*/
public class JDKProxyFactory implements ProxyFactory {
+ private static final int UNINITIALIZED = 0;
+
+ private static final int INITIALIZED = 1;
+
+ private static final int ERROR = -1;
+
+ private int state = UNINITIALIZED;
+
private Class[] businessInterfaceArray;
private Map<Method, InvocationConfiguration> methodToInvocationConfig;
@@ -41,15 +49,22 @@
private ProxyConfiguration configuration;
public void initialize() throws ProxyInitializationException {
+ if (state != UNINITIALIZED) {
+ throw new IllegalStateException("Proxy factory in wrong state [" + state + "]");
+ }
Map<Method, InvocationConfiguration> invocationConfigs = configuration.getInvocationConfigurations();
methodToInvocationConfig = new HashMap(invocationConfigs.size());
for (Map.Entry entry : invocationConfigs.entrySet()) {
Method method = (Method) entry.getKey();
methodToInvocationConfig.put(method, (InvocationConfiguration) entry.getValue());
}
+ state = INITIALIZED;
}
public Object createProxy() {
+ if (state != INITIALIZED) {
+ throw new IllegalStateException("Proxy factory not INITIALIZED [" + state + "]");
+ }
InvocationHandler handler = new JDKInvocationHandler(configuration.getMessageFactory(), methodToInvocationConfig);
return Proxy.newProxyInstance(configuration.getProxyClassLoader(), businessInterfaceArray, handler);
}
Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/message/channel/MessageChannel.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/message/channel/MessageChannel.java?rev=380065&r1=380064&r2=380065&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/message/channel/MessageChannel.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/message/channel/MessageChannel.java Wed Feb 22 23:50:11 2006
@@ -19,8 +19,7 @@
import org.apache.tuscany.core.message.Message;
/**
- * Represents a one-way pipeline through which messages are sent during an
- * invocation
+ * Represents a one-way pipeline through which messages are sent during an invocation
*
* @see org.apache.tuscany.core.message.Message
*/
Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/message/channel/impl/MessageDispatcher.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/message/channel/impl/MessageDispatcher.java?rev=380065&r1=380064&r2=380065&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/message/channel/impl/MessageDispatcher.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/message/channel/impl/MessageDispatcher.java Wed Feb 22 23:50:11 2006
@@ -21,9 +21,9 @@
import org.apache.tuscany.core.message.handler.MessageHandler;
/**
- * A message handler that dispatches the message through an interceptor stack
- * and the uses the response channel to return the invocation result.
- *
+ * A message handler that dispatches the message through an interceptor stack and the uses the response channel to
+ * return the invocation result.
+ *
* @version $Rev$ $Date$
*/
public class MessageDispatcher implements MessageHandler {
@@ -31,7 +31,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) {