OW2 Consortium
Search OW2 Mail Archive: 

Advanced Search - Powered by Google


Mail Archive Home | gotm-commits List | April 2005 Index

<--  Date Index  --> <--  Thread Index  -->

CVS update of gotm/src/java/org/objectweb/gotm/lib/resource (1 file)


    Date: Tuesday, April 19, 2005 @ 11:35:55
  Author: rouvoy
    Path: /cvsroot/gotm/gotm/src/java/org/objectweb/gotm/lib/resource

   Added: ResourceWithThread.java

* Adding a new EventBus multithreaded event propagation policy.


-------------------------+
 ResourceWithThread.java |  103 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 103 insertions(+)


Index: gotm/src/java/org/objectweb/gotm/lib/resource/ResourceWithThread.java
diff -u /dev/null 
gotm/src/java/org/objectweb/gotm/lib/resource/ResourceWithThread.java:1.1
--- /dev/null   Tue Apr 19 11:35:55 2005
+++ gotm/src/java/org/objectweb/gotm/lib/resource/ResourceWithThread.java     
  Tue Apr 19 11:35:55 2005
@@ -0,0 +1,103 @@
+/*====================================================================
+
+GoTM: GoTM is an open Transaction Monitor
+Copyright (C) 2000-2004 INRIA & USTL - LIFL - GOAL
+Contact: gotm-team@xxxxxxxxxxxxx
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
+USA
+
+Initial developer(s): Romain Rouvoy.
+Contributor(s): .
+
+---------------------------------------------------------------------
+$Id: ResourceWithThread.java,v 1.1 2005/04/19 09:35:55 rouvoy Exp $
+====================================================================*/
+
+package org.objectweb.gotm.lib.resource;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.Vector;
+
+import org.objectweb.gotm.lib.event.SubscribablePrimitive;
+import org.objectweb.transaction.api.event.PublishFeature;
+import org.objectweb.transaction.api.event.SubscribeFeature;
+
+/**
+ * Implementation of a wrapper.
+ * @author <a href="mailto:Romain.Rouvoy@xxxxxxx";>Romain Rouvoy</a>
+ * @created 22 déc. 2004
+ * @modified $Date: 2005/04/19 09:35:55 $
+ * @version $Revision: 1.1 $
+ * @fractal.itf
+ */
+public abstract class ResourceWithThread 
+              extends SubscribablePrimitive
+           implements PublishFeature, Resource
+{
+    /** list of registered observers for this kind of wrapper. */
+    private Set observers = new HashSet();
+    
+    /* (non-Javadoc)
+     * @see org.objectweb.fractal.lib.BindablePrimitive#clientFc()
+     */
+    protected String[] clientFc() {
+        return new String[] {
+                SubscribeFeature.SUBSCRIBE_FEATURE,
+            };
+    }
+
+    /* (non-Javadoc)
+     * @see 
org.objectweb.gotm.lib.event.Resource#addResource(java.lang.Object)
+     */
+    public void addResource(Object wrapped) {
+        this.observers.add(wrapped);
+    }
+
+    /* (non-Javadoc)
+     * @see 
org.objectweb.gotm.lib.resource.Resource#delResource(java.lang.Object)
+     */
+    public void delResource(Object wrapped) {
+        this.observers.remove(wrapped);
+    }
+    
+    protected abstract Runnable configureAction(String topic, Map context, 
Object resource);
+    
+    /* (non-Javadoc)
+     * @see 
org.objectweb.gotm.lib.topic.PublishFeature#notify(java.lang.String, 
java.util.Map)
+     */
+    public void notify(String topic, Map context) {
+        Vector v = new Vector();
+        for (Iterator i = this.observers.iterator() ; i.hasNext() ;) {
+            try {
+                Thread t = new 
Thread(configureAction(topic,context,i.next()));
+                t.start();
+                v.add(t);
+            } catch (Exception ex) {
+                getTrace().error("Action.execute: "+ex.getMessage());
+            }
+        }
+        for (Iterator i = v.iterator();i.hasNext();) {
+            try {
+                ((Thread)i.next()).join();
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+        }
+    }    
+}



<--  Date Index  --> <--  Thread Index  -->

Reply via email to:

Powered by MHonArc.

Copyright © 2006-2007, OW2 Consortium | contact | webmaster.