You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by ni...@apache.org on 2004/05/21 14:29:48 UTC

svn commit: rev 20194 - avalon/trunk/tools/magic/engine/src/java/org/apache/merlin/magic

Author: niclas
Date: Fri May 21 05:29:46 2004
New Revision: 20194

Added:
   avalon/trunk/tools/magic/engine/src/java/org/apache/merlin/magic/AbstractPlugin.java
Log:
Convenience class for plugins to extend.

Added: avalon/trunk/tools/magic/engine/src/java/org/apache/merlin/magic/AbstractPlugin.java
==============================================================================
--- (empty file)
+++ avalon/trunk/tools/magic/engine/src/java/org/apache/merlin/magic/AbstractPlugin.java	Fri May 21 05:29:46 2004
@@ -0,0 +1,67 @@
+package org.apache.merlin.magic;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.Contextualizable;
+
+public abstract class AbstractPlugin extends AbstractLogEnabled
+    implements Plugin, Contextualizable
+{
+    private ArrayList m_Listeners;
+    
+    protected PluginContext m_Context;
+    
+    protected AbstractPlugin()
+    {
+        m_Listeners = new ArrayList();
+    }
+    
+    public void contextualize( Context context )
+    {
+        m_Context = (PluginContext) context;
+    }
+    
+    public void addPluginObserver( PluginObserver observer )
+    {
+        if( observer != null )
+            m_Listeners.add( observer );
+    }
+    
+    public void removePluginObserver( PluginObserver observer )
+    {
+        if( observer != null )
+            m_Listeners.remove( observer );
+    }
+    
+    protected void notifyPreMethod( String method )
+    {
+        Iterator list = m_Listeners.iterator();
+        while( list.hasNext() )
+        {
+            PluginObserver observer = (PluginObserver) list.next();
+            observer.preMethod( this, method );
+        }
+    }
+
+    protected void notifyPostMethod( String method )
+    {
+        Iterator list = m_Listeners.iterator();
+        while( list.hasNext() )
+        {
+            PluginObserver observer = (PluginObserver) list.next();
+            observer.postMethod( this, method );
+        }
+    }
+
+    protected void notifyStep( String method, int stepIndex )
+    {
+        Iterator list = m_Listeners.iterator();
+        while( list.hasNext() )
+        {
+            PluginObserver observer = (PluginObserver) list.next();
+            observer.postMethod( this, method, stepIndex );
+        }
+    }
+} 

---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org