You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ra...@apache.org on 2006/10/11 21:05:58 UTC
svn commit: r462902 - in
/jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml:
NotificationRegistry.java SCInstance.java SCXMLExecutor.java
Author: rahul
Date: Wed Oct 11 12:05:57 2006
New Revision: 462902
URL: http://svn.apache.org/viewvc?view=rev&rev=462902
Log:
Improving thread-safety for executor instances. Was marked LATER in version 0.5, where external synchronization is recommended, if needed. Required for usecases such as:
* Delayed <send> events
* Certain web applications, AJAX request scenarios
SCXML-2
Modified:
jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/NotificationRegistry.java
jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/SCInstance.java
jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/SCXMLExecutor.java
Modified: jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/NotificationRegistry.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/NotificationRegistry.java?view=diff&rev=462902&r1=462901&r2=462902
==============================================================================
--- jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/NotificationRegistry.java (original)
+++ jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/NotificationRegistry.java Wed Oct 11 12:05:57 2006
@@ -56,7 +56,7 @@
* @param source The observable this listener wants to listen to
* @param lst The listener
*/
- void addListener(final Object source,
+ synchronized void addListener(final Object source,
final SCXMLListener lst) {
Set entries = (Set) regs.get(source);
if (entries == null) {
@@ -72,7 +72,7 @@
* @param source The observable this listener wants to stop listening to
* @param lst The listener
*/
- void removeListener(final Object source,
+ synchronized void removeListener(final Object source,
final SCXMLListener lst) {
Set entries = (Set) regs.get(source);
if (entries != null) {
@@ -116,7 +116,7 @@
* @param source The Observable
* @param state The TransitionTarget that was entered
*/
- private void fireOnEntry(final Object source,
+ private synchronized void fireOnEntry(final Object source,
final TransitionTarget state) {
Set entries = (Set) regs.get(source);
if (entries != null) {
@@ -160,7 +160,7 @@
* @param source The Observable
* @param state The TransitionTarget that was exited
*/
- private void fireOnExit(final Object source,
+ private synchronized void fireOnExit(final Object source,
final TransitionTarget state) {
Set entries = (Set) regs.get(source);
if (entries != null) {
@@ -209,7 +209,7 @@
* @param to The destination TransitionTarget
* @param transition The Transition that was taken
*/
- private void fireOnTransition(final Object source,
+ private synchronized void fireOnTransition(final Object source,
final TransitionTarget from, final TransitionTarget to,
final Transition transition) {
Set entries = (Set) regs.get(source);
Modified: jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/SCInstance.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/SCInstance.java?view=diff&rev=462902&r1=462901&r2=462902
==============================================================================
--- jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/SCInstance.java (original)
+++ jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/SCInstance.java Wed Oct 11 12:05:57 2006
@@ -17,6 +17,7 @@
package org.apache.commons.scxml;
import java.io.Serializable;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@@ -86,10 +87,10 @@
*/
SCInstance(final SCXMLExecutor executor) {
this.notificationRegistry = new NotificationRegistry();
- this.contexts = new HashMap();
- this.histories = new HashMap();
- this.invokerClasses = new HashMap();
- this.invokers = new HashMap();
+ this.contexts = Collections.synchronizedMap(new HashMap());
+ this.histories = Collections.synchronizedMap(new HashMap());
+ this.invokerClasses = Collections.synchronizedMap(new HashMap());
+ this.invokers = Collections.synchronizedMap(new HashMap());
this.evaluator = null;
this.rootContext = null;
this.executor = executor;
Modified: jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/SCXMLExecutor.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/SCXMLExecutor.java?view=diff&rev=462902&r1=462901&r2=462902
==============================================================================
--- jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/SCXMLExecutor.java (original)
+++ jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/SCXMLExecutor.java Wed Oct 11 12:05:57 2006
@@ -97,7 +97,7 @@
* @throws ModelException in case there is a fatal SCXML object
* model problem.
*/
- public void triggerEvents(final TriggerEvent[] evts)
+ public synchronized void triggerEvents(final TriggerEvent[] evts)
throws ModelException {
// Set event data, saving old values
Object[] oldData = setEventData(evts);
@@ -206,7 +206,7 @@
* @throws ModelException in case there is a fatal SCXML object
* model problem.
*/
- public void reset() throws ModelException {
+ public synchronized void reset() throws ModelException {
// Reset all variable contexts
Context rootCtx = scInstance.getRootContext();
// Clone root datamodel
@@ -263,7 +263,7 @@
*
* @return The current Status
*/
- public Status getCurrentStatus() {
+ public synchronized Status getCurrentStatus() {
return currentStatus;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org