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/04/14 02:33:26 UTC
svn commit: r393988 - in
/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/context/scope:
ModuleScopeContext.java RequestScopeContext.java SessionScopeContext.java
Author: jmarino
Date: Thu Apr 13 17:33:24 2006
New Revision: 393988
URL: http://svn.apache.org/viewcvs?rev=393988&view=rev
Log:
more context refactoring
Modified:
incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/context/scope/ModuleScopeContext.java
incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/context/scope/RequestScopeContext.java
incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/context/scope/SessionScopeContext.java
Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/context/scope/ModuleScopeContext.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/context/scope/ModuleScopeContext.java?rev=393988&r1=393987&r2=393988&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/context/scope/ModuleScopeContext.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/context/scope/ModuleScopeContext.java Thu Apr 13 17:33:24 2006
@@ -55,7 +55,7 @@
lifecycleState = RUNNING;
initComponentContexts();
} else if (event instanceof ModuleStopEvent) {
- notifyInstanceShutdown();
+ shutdownContexts();
} else if (event instanceof ContextCreatedEvent) {
checkInit();
if (event.getSource() instanceof AtomicContext) {
@@ -124,10 +124,9 @@
/**
- * Notfies instances that are associated with a context and configured to receive callbacks that the context is
- * being destroyed in reverse order
+ * Notifies contexts of a shutdown in reverse order to which they were started
*/
- private synchronized void notifyInstanceShutdown() {
+ private synchronized void shutdownContexts() {
if (destroyableContexts == null || destroyableContexts.size() == 0) {
return;
}
@@ -137,7 +136,6 @@
Context context = iter.previous();
if (context.getLifecycleState() == RUNNING) {
synchronized (context) {
- //removeContextByKey(context.getName(), key);
try {
if (context instanceof AtomicContext){
((AtomicContext)context).destroy();
@@ -145,7 +143,6 @@
context.stop();
} catch (TargetException e) {
// TODO send a monitoring event
- // log.error("Error releasing instance [" + context.getName() + "]",e);
}
}
}
@@ -171,8 +168,6 @@
if (atomic.isEagerInit()) {
// perform silent creation and manual shutdown registration
atomic.init();
- //if (atomic.isDestroyable()) {
- //}
}
}
context.addListener(this);
Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/context/scope/RequestScopeContext.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/context/scope/RequestScopeContext.java?rev=393988&r1=393987&r2=393988&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/context/scope/RequestScopeContext.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/context/scope/RequestScopeContext.java Thu Apr 13 17:33:24 2006
@@ -136,11 +136,6 @@
return;
}
components.remove(ctxName);
- //Map<String, Context> contexts = contexts.get(key);
- // no synchronization for the following two operations since the request
- // context will not be shutdown before the second call is processed
- //Context context = contexts.get(ctxName);
- //destroyQueues.get(key).remove(context);
}
Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/context/scope/SessionScopeContext.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/context/scope/SessionScopeContext.java?rev=393988&r1=393987&r2=393988&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/context/scope/SessionScopeContext.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/context/scope/SessionScopeContext.java Thu Apr 13 17:33:24 2006
@@ -82,22 +82,10 @@
}else if(event instanceof ContextCreatedEvent){
checkInit();
Object sessionKey = getEventContext().getIdentifier(HttpSessionEvent.HTTP_IDENTIFIER);
- List<Context> contexts = destroyQueues.get(sessionKey);
+ List<Context> shutdownQueue = destroyQueues.get(sessionKey);
Context context = (Context)event.getSource();
- assert(contexts != null): "Shutdown queue not found for key";
-
-// if (context instanceof AtomicContext) {
-// AtomicContext atomic = (AtomicContext)event.getSource();
-// // if destroyable, queue the context to have its component implementation instance released
-// if (atomic.isDestroyable()) {
-// if (contexts == null) {
-// ScopeRuntimeException e = new ScopeRuntimeException("Shutdown queue not found for key");
-// e.setIdentifier(sessionKey.toString());
-// throw e;
-// }
-// }
-// }
- contexts.add(context);
+ assert(shutdownQueue != null): "Shutdown queue not found for key";
+ shutdownQueue.add(context);
}
}
@@ -230,13 +218,11 @@
//removeContextByKey(context.getName(), key);
try {
if (context instanceof AtomicContext){
- System.out.println(":"+context.getName());
((AtomicContext)context).destroy();
}
context.stop();
} catch (TargetException e) {
// TODO send a monitoring event
- // log.error("Error releasing instance [" + context.getName() + "]",e);
}
}
}