summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/core
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2008-12-05 00:27:12 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2008-12-05 00:27:12 +0000
commit0ea599fa479346814179c57ff939df9abee5a479 (patch)
treef41862ad6354a30c4e9bf678486c77b4f461359c /java/sca/modules/core
parentbb2aadc32654a0e70ab209cb3cbcecdc768068b9 (diff)
Refine the CallableReferenceExt
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@723508 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/context/CallableReferenceExt.java30
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/RequestContextImpl.java5
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/conversation/impl/ConversationManagerImpl.java67
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java7
4 files changed, 55 insertions, 54 deletions
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/CallableReferenceExt.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/CallableReferenceExt.java
index ffa55d583a..6d7ce63d50 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/CallableReferenceExt.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/CallableReferenceExt.java
@@ -25,32 +25,28 @@ import java.io.IOException;
import javax.xml.stream.XMLStreamReader;
import org.apache.tuscany.sca.core.conversation.ConversationExt;
-import org.apache.tuscany.sca.core.factory.ObjectCreationException;
import org.apache.tuscany.sca.runtime.EndpointReference;
import org.apache.tuscany.sca.runtime.RuntimeWire;
import org.osoa.sca.CallableReference;
-import org.osoa.sca.Conversation;
/**
* Extended version of CallableReference
*/
public interface CallableReferenceExt<B> extends CallableReference<B>, Externalizable {
+ /**
+ * @return
+ */
RuntimeWire getRuntimeWire();
- B getProxy() throws ObjectCreationException;
-
- B getService();
-
- Class<B> getBusinessInterface();
-
- boolean isConversational();
-
- Conversation getConversation();
-
- Object getCallbackID();
-
+ /**
+ * @return
+ * @throws IOException
+ */
String toXMLString() throws IOException;
+ /**
+ * @param callbackID
+ */
void attachCallbackID(Object callbackID);
void attachConversationID(Object conversationID);
@@ -59,8 +55,14 @@ public interface CallableReferenceExt<B> extends CallableReference<B>, Externali
void attachConversation(Object conversationID);
+ /**
+ * @return
+ */
EndpointReference getEndpointReference();
+ /**
+ * @return
+ */
XMLStreamReader getXMLReader();
}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/RequestContextImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/RequestContextImpl.java
index a37f14e954..bd4a49a71a 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/RequestContextImpl.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/RequestContextImpl.java
@@ -23,6 +23,7 @@ import java.util.List;
import javax.security.auth.Subject;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.context.CallableReferenceExt;
import org.apache.tuscany.sca.core.invocation.ProxyFactory;
import org.apache.tuscany.sca.core.invocation.ProxyFactoryExtensionPoint;
import org.apache.tuscany.sca.core.invocation.ThreadMessageContext;
@@ -75,8 +76,8 @@ public class RequestContextImpl implements RequestContext {
CallableReference<B> callableReference = component.getComponentContext().getCallableReference(null, component, service);
ReferenceParameters parameters = msgContext.getFrom().getReferenceParameters();
- ((CallableReferenceImpl<B>) callableReference).attachCallbackID(parameters.getCallbackID());
- ((CallableReferenceImpl<B>) callableReference).attachConversation(parameters.getConversationID());
+ ((CallableReferenceExt<B>) callableReference).attachCallbackID(parameters.getCallbackID());
+ ((CallableReferenceExt<B>) callableReference).attachConversation(parameters.getConversationID());
return callableReference;
}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/conversation/impl/ConversationManagerImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/conversation/impl/ConversationManagerImpl.java
index 3c726426f6..9920e5614f 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/conversation/impl/ConversationManagerImpl.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/conversation/impl/ConversationManagerImpl.java
@@ -31,29 +31,29 @@ import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
+import org.apache.tuscany.sca.core.conversation.ConversationExt;
import org.apache.tuscany.sca.core.conversation.ConversationListener;
import org.apache.tuscany.sca.core.conversation.ConversationManager;
import org.apache.tuscany.sca.core.conversation.ConversationState;
-import org.apache.tuscany.sca.core.conversation.ConversationExt;
/**
* @version $Rev$ $Date$
*/
public class ConversationManagerImpl implements ConversationManager {
-
+
private List<ConversationListener> listeners = Collections.synchronizedList(new ArrayList<ConversationListener>());
private Map<Object, ConversationExt> conversations = new ConcurrentHashMap<Object, ConversationExt>();
/**
* the default max age. this is set to 1 hour
*/
- private static final long DEFAULT_MAX_AGE = 60 * 60 * 1000; ;
-
+ private static final long DEFAULT_MAX_AGE = 60 * 60 * 1000;;
+
/**
* the default max idle time. this is set to 1 hour
*/
- private static final long DEFAULT_MAX_IDLE_TIME = 60 * 60 * 1000;
-
+ private static final long DEFAULT_MAX_IDLE_TIME = 60 * 60 * 1000;
+
/**
* the globally used max age
*/
@@ -62,40 +62,40 @@ public class ConversationManagerImpl implements ConversationManager {
/**
* the globally used max idle time
*/
- private final long maxIdleTime;
+ private final long maxIdleTime;
/**
* the reaper thread
*/
private final ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
-
+
/**
* constructor
*/
public ConversationManagerImpl() {
- long mit = DEFAULT_MAX_IDLE_TIME;
- long ma = DEFAULT_MAX_AGE;
-
- // Allow privileged access to read system property. Requires PropertyPermission in security
+ long mit = DEFAULT_MAX_IDLE_TIME;
+ long ma = DEFAULT_MAX_AGE;
+
+ // Allow privileged access to read system property. Requires PropertyPermission in security
// policy.
String aProperty = AccessController.doPrivileged(new PrivilegedAction<String>() {
public String run() {
- return System.getProperty("org.apache.tuscany.sca.core.scope.ConversationalScopeContainer.MaxIdleTime");
+ return System.getProperty(ConversationManager.class.getName() + ".MaxIdleTime");
}
});
- if (aProperty != null) {
- try {
- mit = (new Long(aProperty) * 1000);
- } catch (NumberFormatException nfe) {
- // Ignore
- }
- }
-
- // Allow privileged access to read system property. Requires PropertyPermission in security
+ if (aProperty != null) {
+ try {
+ mit = (new Long(aProperty) * 1000);
+ } catch (NumberFormatException nfe) {
+ // Ignore
+ }
+ }
+
+ // Allow privileged access to read system property. Requires PropertyPermission in security
// policy.
aProperty = AccessController.doPrivileged(new PrivilegedAction<String>() {
public String run() {
- return System.getProperty("org.apache.tuscany.sca.core.scope.ConversationalScopeContainer.MaxAge");
+ return System.getProperty(ConversationManager.class.getName() + ".MaxAge");
}
});
if (aProperty != null) {
@@ -109,7 +109,7 @@ public class ConversationManagerImpl implements ConversationManager {
maxAge = ma;
maxIdleTime = mit;
}
-
+
/**
* @see org.apache.tuscany.sca.core.conversation.ConversationManager#addListener(org.apache.tuscany.sca.core.conversation.ConversationListener)
*/
@@ -165,9 +165,8 @@ public class ConversationManagerImpl implements ConversationManager {
/**
* starts the reaper thread
*/
- public void scheduleConversation(ExtendedConversationImpl aConversation, long time)
- {
- this.scheduler.schedule(aConversation, time, TimeUnit.MILLISECONDS);
+ public void scheduleConversation(ExtendedConversationImpl aConversation, long time) {
+ this.scheduler.schedule(aConversation, time, TimeUnit.MILLISECONDS);
}
/**
@@ -176,16 +175,15 @@ public class ConversationManagerImpl implements ConversationManager {
public synchronized void stopReaper() {
// Prevent the scheduler from submitting any additional reapers,
- // initiate an orderly shutdown if a reaper task is in progress.
- this.scheduler.shutdown();
+ // initiate an orderly shutdown if a reaper task is in progress.
+ this.scheduler.shutdown();
}
-
/**
* @see org.apache.tuscany.sca.core.conversation.ConversationManager#startConversation(java.lang.Object)
*/
public ConversationExt startConversation(Object conversationID) {
-
+
if (conversationID == null) {
conversationID = UUID.randomUUID().toString();
}
@@ -193,9 +191,8 @@ public class ConversationManagerImpl implements ConversationManager {
if (conversation != null && conversation.getState() != ConversationState.ENDED) {
throw new IllegalStateException(conversation + " already exists.");
}
-
- conversation = new ExtendedConversationImpl(
- this, conversationID, ConversationState.STARTED);
+
+ conversation = new ExtendedConversationImpl(this, conversationID, ConversationState.STARTED);
conversations.put(conversationID, conversation);
for (ConversationListener listener : listeners) {
listener.conversationStarted(conversation);
@@ -215,7 +212,7 @@ public class ConversationManagerImpl implements ConversationManager {
* returns the default max age
* @param impProvider the implementation Provider to extract any ConversationAttribute details
*/
- public long getMaxAge(){
+ public long getMaxAge() {
return maxAge;
}
}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java
index 46f09bd1ad..51e469d1c1 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java
@@ -29,10 +29,11 @@ import java.util.Map;
import java.util.UUID;
import org.apache.tuscany.sca.core.assembly.impl.RuntimeWireImpl;
+import org.apache.tuscany.sca.core.context.CallableReferenceExt;
import org.apache.tuscany.sca.core.context.impl.CallableReferenceImpl;
+import org.apache.tuscany.sca.core.conversation.ConversationExt;
import org.apache.tuscany.sca.core.conversation.ConversationManager;
import org.apache.tuscany.sca.core.conversation.ConversationState;
-import org.apache.tuscany.sca.core.conversation.ConversationExt;
import org.apache.tuscany.sca.core.factory.InstanceWrapper;
import org.apache.tuscany.sca.core.invocation.ThreadMessageContext;
import org.apache.tuscany.sca.core.scope.Scope;
@@ -91,7 +92,7 @@ public class JDKInvocationHandler implements InvocationHandler, Serializable {
if (callableReference != null) {
this.businessInterface = callableReference.getBusinessInterface();
this.conversation = (ConversationExt)callableReference.getConversation();
- this.wire = ((CallableReferenceImpl<?>)callableReference).getRuntimeWire();
+ this.wire = ((CallableReferenceExt<?>)callableReference).getRuntimeWire();
if (wire != null) {
init(wire);
}
@@ -351,7 +352,7 @@ public class JDKInvocationHandler implements InvocationHandler, Serializable {
Interface interfaze = msg.getFrom().getCallbackEndpoint().getInterfaceContract().getInterface();
if (callbackObject != null) {
if (callbackObject instanceof ServiceReference) {
- EndpointReference callbackRef = ((CallableReferenceImpl)callbackObject).getEndpointReference();
+ EndpointReference callbackRef = ((CallableReferenceExt<?>)callbackObject).getEndpointReference();
parameters.setCallbackReference(callbackRef);
} else {
if (interfaze != null) {