You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2004/02/03 07:54:12 UTC
svn commit: rev 6447 - in incubator/directory/eve/trunk/eve/frontend/event: impl merlin-impl merlin-impl/conf merlin-impl/src/java/org/apache/eve/event pojo-impl pojo-impl/src pojo-impl/src/docbook pojo-impl/src/images pojo-impl/src/java pojo-impl/src/java/org pojo-impl/src/java/org/apache pojo-impl/src/java/org/apache/eve pojo-impl/src/java/org/apache/eve/event
Author: akarasulu
Date: Mon Feb 2 22:54:11 2004
New Revision: 6447
Added:
incubator/directory/eve/trunk/eve/frontend/event/merlin-impl/ (props changed)
- copied from rev 6407, incubator/directory/eve/trunk/eve/frontend/event/impl/
incubator/directory/eve/trunk/eve/frontend/event/pojo-impl/
incubator/directory/eve/trunk/eve/frontend/event/pojo-impl/project.properties
incubator/directory/eve/trunk/eve/frontend/event/pojo-impl/project.xml
incubator/directory/eve/trunk/eve/frontend/event/pojo-impl/src/
incubator/directory/eve/trunk/eve/frontend/event/pojo-impl/src/docbook/
incubator/directory/eve/trunk/eve/frontend/event/pojo-impl/src/images/
incubator/directory/eve/trunk/eve/frontend/event/pojo-impl/src/java/
incubator/directory/eve/trunk/eve/frontend/event/pojo-impl/src/java/org/
incubator/directory/eve/trunk/eve/frontend/event/pojo-impl/src/java/org/apache/
incubator/directory/eve/trunk/eve/frontend/event/pojo-impl/src/java/org/apache/eve/
incubator/directory/eve/trunk/eve/frontend/event/pojo-impl/src/java/org/apache/eve/event/
incubator/directory/eve/trunk/eve/frontend/event/pojo-impl/src/java/org/apache/eve/event/DefaultEventRouter.java
Removed:
incubator/directory/eve/trunk/eve/frontend/event/impl/
incubator/directory/eve/trunk/eve/frontend/event/merlin-impl/src/java/org/apache/eve/event/DefaultEventRouter.java
Modified:
incubator/directory/eve/trunk/eve/frontend/event/merlin-impl/conf/block.xml
incubator/directory/eve/trunk/eve/frontend/event/merlin-impl/project.xml
Log:
making things conform to proposed layout
Modified: incubator/directory/eve/trunk/eve/frontend/event/merlin-impl/conf/block.xml
==============================================================================
--- incubator/directory/eve/trunk/eve/frontend/event/impl/conf/block.xml (original)
+++ incubator/directory/eve/trunk/eve/frontend/event/merlin-impl/conf/block.xml Mon Feb 2 22:54:11 2004
@@ -7,6 +7,7 @@
<repository>
<resource id="avalon-framework:avalon-framework-api" version="4.1.5"/>
<resource id="directory:eve-frontend-event-spi" version="SNAPSHOT"/>
+ <resource id="directory:eve-frontend-event-pojo-impl" version="SNAPSHOT"/>
</repository>
</classpath>
</classloader>
Modified: incubator/directory/eve/trunk/eve/frontend/event/merlin-impl/project.xml
==============================================================================
--- incubator/directory/eve/trunk/eve/frontend/event/impl/project.xml (original)
+++ incubator/directory/eve/trunk/eve/frontend/event/merlin-impl/project.xml Mon Feb 2 22:54:11 2004
@@ -2,7 +2,7 @@
<project>
<extend>${basedir}/../../../project.xml</extend>
<groupId>directory</groupId>
- <id>eve-frontend-event-impl</id>
+ <id>eve-frontend-event-merlin-impl</id>
<name>Eve Frontend Event Implementation</name>
<package>org.apache.eve.event</package>
@@ -35,6 +35,13 @@
<dependency>
<groupId>directory</groupId>
<artifactId>eve-frontend-event-spi</artifactId>
+ <version>SNAPSHOT</version>
+ <url>http://directory.apache.org</url>
+ </dependency>
+
+ <dependency>
+ <groupId>directory</groupId>
+ <artifactId>eve-frontend-event-pojo-impl</artifactId>
<version>SNAPSHOT</version>
<url>http://directory.apache.org</url>
</dependency>
Added: incubator/directory/eve/trunk/eve/frontend/event/pojo-impl/project.properties
==============================================================================
--- (empty file)
+++ incubator/directory/eve/trunk/eve/frontend/event/pojo-impl/project.properties Mon Feb 2 22:54:11 2004
@@ -0,0 +1,3 @@
+maven.xdoc.date=left
+maven.xdoc.version=${pom.currentVersion}
+merlin.debug=true
Added: incubator/directory/eve/trunk/eve/frontend/event/pojo-impl/project.xml
==============================================================================
--- (empty file)
+++ incubator/directory/eve/trunk/eve/frontend/event/pojo-impl/project.xml Mon Feb 2 22:54:11 2004
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<project>
+ <extend>${basedir}/../../../project.xml</extend>
+ <groupId>directory</groupId>
+ <id>eve-frontend-event-pojo-impl</id>
+
+ <name>Eve Frontend Event POJO Implementation</name>
+ <package>org.apache.eve.event</package>
+ <currentVersion>SNAPSHOT</currentVersion>
+ <inceptionYear>2003</inceptionYear>
+
+ <shortDescription>
+ Event router implementation used by Eve's frontend
+ </shortDescription>
+
+ <description>
+ Event notification service implementation.
+ </description>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>directory</groupId>
+ <artifactId>eve-frontend-common-api</artifactId>
+ <version>SNAPSHOT</version>
+ <url>http://directory.apache.org</url>
+ </dependency>
+
+ <dependency>
+ <groupId>directory</groupId>
+ <artifactId>eve-frontend-event-spi</artifactId>
+ <version>SNAPSHOT</version>
+ <url>http://directory.apache.org</url>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <url>http://junit.org</url>
+ </dependency>
+ </dependencies>
+</project>
+
Added: incubator/directory/eve/trunk/eve/frontend/event/pojo-impl/src/java/org/apache/eve/event/DefaultEventRouter.java
==============================================================================
--- (empty file)
+++ incubator/directory/eve/trunk/eve/frontend/event/pojo-impl/src/java/org/apache/eve/event/DefaultEventRouter.java Mon Feb 2 22:54:11 2004
@@ -0,0 +1,227 @@
+/*
+
+ ============================================================================
+ The Apache Software License, Version 1.1
+ ============================================================================
+
+ Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modifica-
+ tion, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. The end-user documentation included with the redistribution, if any, must
+ include the following acknowledgment: "This product includes software
+ developed by the Apache Software Foundation (http://www.apache.org/)."
+ Alternately, this acknowledgment may appear in the software itself, if
+ and wherever such third-party acknowledgments normally appear.
+
+ 4. The names "Eve Directory Server", "Apache Directory Project", "Apache Eve"
+ and "Apache Software Foundation" must not be used to endorse or promote
+ products derived from this software without prior written
+ permission. For written permission, please contact apache@apache.org.
+
+ 5. Products derived from this software may not be called "Apache", nor may
+ "Apache" appear in their name, without prior written permission of the
+ Apache Software Foundation.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ This software consists of voluntary contributions made by many individuals
+ on behalf of the Apache Software Foundation. For more information on the
+ Apache Software Foundation, please see <http://www.apache.org/>.
+
+*/
+package org.apache.eve.event ;
+
+
+import java.util.Set ;
+import java.util.HashSet ;
+import java.util.Iterator ;
+import java.util.EventObject ;
+
+
+/**
+ * An synchronous implementation of the event router / notification pattern.
+ *
+ * @author <a href="mailto:akarasulu@apache.org">Alex Karasulu</a>
+ * @author $Author: akarasulu $
+ * @version $Rev: 1452 $
+ */
+public class DefaultEventRouter implements EventRouter
+{
+ /** the set of subscriptions made with this router */
+ private Set m_subscriptions = new HashSet() ;
+ /** the monitor - initially set to the null monitor */
+ private EventRouterMonitor m_monitor = new EventRouterMonitorAdapter() ;
+
+
+ /**
+ * @see org.apache.eve.event.EventRouter#subscribe(java.lang.Class,
+ * org.apache.eve.event.Filter, org.apache.eve.event.Subscriber)
+ */
+ public void subscribe( Class a_type, Filter a_filter,
+ Subscriber a_subscriber )
+ {
+ if ( ! EventObject.class.isAssignableFrom( a_type ) )
+ {
+ throw new IllegalArgumentException( "Invalid event class: "
+ + a_type.getName() ) ;
+ }
+
+ Subscription l_subscription =
+ new Subscription( a_type, a_filter, a_subscriber ) ;
+
+ if ( ! m_subscriptions.contains( l_subscription ) )
+ {
+ synchronized ( m_subscriptions )
+ {
+ m_subscriptions.add( l_subscription ) ;
+ }
+
+ m_monitor.addedSubscription( l_subscription ) ;
+ }
+ }
+
+
+ /**
+ * @see org.apache.eve.event.EventRouter#unsubscribe(
+ * org.apache.eve.event.Subscriber)
+ */
+ public void unsubscribe( Subscriber a_subscriber )
+ {
+ Iterator l_list = m_subscriptions.iterator() ;
+
+ synchronized ( m_subscriptions )
+ {
+ while ( l_list.hasNext() )
+ {
+ Subscription l_subscription = ( Subscription ) l_list.next() ;
+ if ( a_subscriber == l_subscription.getSubscriber() )
+ {
+ l_list.remove() ;
+ m_monitor.removedSubscription( l_subscription ) ;
+ }
+ }
+ }
+ }
+
+
+ /**
+ * (non-Javadoc)
+ * @see org.apache.eve.event.EventRouter#unsubscribe(java.lang.Class,
+ * org.apache.eve.event.Subscriber)
+ */
+ public void unsubscribe( Class a_type, Subscriber a_subscriber )
+ {
+ Iterator l_list = m_subscriptions.iterator() ;
+
+ synchronized ( m_subscriptions )
+ {
+ while ( l_list.hasNext() )
+ {
+ Subscription l_subscription = ( Subscription ) l_list.next() ;
+ if ( a_subscriber == l_subscription.getSubscriber()
+ && a_type.equals( l_subscription.getType() ) )
+ {
+ l_list.remove() ;
+ m_monitor.removedSubscription( l_subscription ) ;
+ }
+ }
+ }
+ }
+
+
+ /**
+ * (non-Javadoc)
+ * @see org.apache.eve.event.EventRouter#unsubscribe(java.lang.Class,
+ * org.apache.eve.event.Subscriber)
+ */
+ public void unsubscribe( Class a_type, Filter a_filter,
+ Subscriber a_subscriber )
+ {
+ if ( ! EventObject.class.isAssignableFrom( a_type ) )
+ {
+ throw new IllegalArgumentException( "Invalid event class: "
+ + a_type.getName() ) ;
+ }
+
+ final Subscription l_subscription = new Subscription( a_type, a_filter,
+ a_subscriber ) ;
+
+ synchronized ( m_subscriptions )
+ {
+ m_subscriptions.remove( l_subscription ) ;
+ }
+ }
+
+
+ /**
+ * (non-Javadoc)
+ * @see org.apache.eve.event.EventRouter#publish(org.apache.eve.event.Event)
+ */
+ public void publish( EventObject a_event )
+ {
+ final Subscription [] l_subscriptions ;
+
+ synchronized ( m_subscriptions )
+ {
+ l_subscriptions = ( Subscription [] ) m_subscriptions
+ .toArray( new Subscription [ m_subscriptions.size() ] ) ;
+ }
+
+ for ( int ii = 0; ii < l_subscriptions.length; ii++ )
+ {
+ boolean isAssignable = l_subscriptions[ii].getType()
+ .isAssignableFrom( a_event.getClass() ) ;
+
+ if ( ! isAssignable )
+ {
+ continue ;
+ }
+
+ if ( l_subscriptions[ii].getFilter() != null &&
+ l_subscriptions[ii].getFilter().apply( a_event ) )
+ {
+ l_subscriptions[ii].getSubscriber().inform( a_event ) ;
+ }
+ }
+ }
+
+
+ /**
+ * Sets the event router's monitor.
+ *
+ * @param a_monitor the monitor
+ */
+ void setMonitor( EventRouterMonitor a_monitor )
+ {
+ m_monitor = a_monitor ;
+ }
+
+
+ /**
+ * Gets the event router's monitor.
+ *
+ * @return the monitor
+ */
+ EventRouterMonitor getMonitor()
+ {
+ return m_monitor ;
+ }
+}