[CVS spice] first cut of event processing component
proyal-yCVjj/[email protected] 2 Mar 2005 19:33:52 -0000
| Newsgroups | gmane.comp.java.spice.cvs |
|---|---|
| Message-ID | <[email protected]> |
<html>
<head>
<style><!--
body {background-color:#ffffff;}
.file {border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;}
.pathname {font-family:monospace; float:right;}
.fileheader {margin-bottom:.5em;}
.diff {margin:0;}
.tasklist {padding:4px;border:1px dashed #000000;margin-top:1em;}
.tasklist ul {margin-top:0;margin-bottom:0;}
tr.alt {background-color:#eeeeee}
#added {background-color:#ddffdd;}
#addedchars {background-color:#99ff99;font-weight:bolder;}
tr.alt #added {background-color:#ccf7cc;}
#removed {background-color:#ffdddd;}
#removedchars {background-color:#ff9999;font-weight:bolder;}
tr.alt #removed {background-color:#f7cccc;}
#info {color:#888888;}
#context {background-color:#eeeeee;}
td {padding-left:.3em;padding-right:.3em;}
tr.head {border-bottom-width:1px;border-bottom-style:solid;}
tr.head td {padding:0;padding-top:.2em;}
.task {background-color:#ffff00;}
.comment {padding:4px;border:1px dashed #000000;background-color:#ffffdd}
.error {color:red;}
hr {border-width:0px;height:2px;background:black;}
--></style>
</head>
<body>
<table cellspacing="0" cellpadding="0" border="0" rules="cols">
<tr class="head"><td colspan="4">Commit in <b><tt>spice/components/event</tt></b><span id="info"> on MAIN</span></td></tr>
<tr><td><tt>src/java/org/spice/event/<a href="#file1"><span id="added">ClassObjectType.java</span></a></tt></td><td align="right" id="added">+55</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt> /<a href="#file2"><span id="added">DefaultEventManager.java</span></a></tt></td><td align="right" id="added">+227</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr><td><tt> /<a href="#file3"><span id="added">EventManagerRuntimeException.java</span></a></tt></td><td align="right" id="added">+24</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt> /<a href="#file4"><span id="added">EventPublisher.java</span></a></tt></td><td align="right" id="added">+18</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr><td><tt> /<a href="#file5"><span id="added">EventRegister.java</span></a></tt></td><td align="right" id="added">+19</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt> /<a href="#file6"><span id="added">NoSuchSubscriberException.java</span></a></tt></td><td align="right" id="added">+18</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr><td><tt> /<a href="#file7"><span id="added">PublicationException.java</span></a></tt></td><td align="right" id="added">+32</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt> /<a href="#file8"><span id="added">Subscriber.java</span></a></tt></td><td align="right" id="added">+25</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr><td><tt> /<a href="#file9"><span id="added">TupleMemberNotNullCondition.java</span></a></tt></td><td align="right" id="added">+41</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt>src/test/org/spice/event/<a href="#file10"><span id="added">DefaultEventManagerTestCase.java</span></a></tt></td><td align="right" id="added">+94</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr><td><tt><a href="#file11"><span id="added">project.xml</span></a></tt></td><td align="right" id="added">+81</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr><td></td><td align="right" id="added">+634</td><td></td><td></td></tr>
</table>
<small id="info">11 added files</small><br />
<pre class="comment">
first cut of event processing component
</pre>
<hr /><a name="file1" /><div class="file">
<span class="pathname" id="added">spice/components/event/src/java/org/spice/event<br /></span>
<div class="fileheader" id="added"><big><b>ClassObjectType.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N ClassObjectType.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ClassObjectType.java 2 Mar 2005 19:33:52 -0000 1.1
@@ -0,0 +1,55 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.spice.event;
+
+import org.drools.spi.ObjectType;
+
+/**
+ * @author <a href="mailto:[email protected]">peter royal</a>
+ */
+public class ClassObjectType implements ObjectType
+{
+ private final Class m_clazz;
+
+ public ClassObjectType( final Class clazz )
+ {
+ if( null == clazz )
+ {
+ throw new NullPointerException( "clazz" );
+ }
+
+ m_clazz = clazz;
+ }
+
+ public Class getType()
+ {
+ return m_clazz;
+ }
+
+ public boolean matches( final Object object )
+ {
+ return getType().isInstance( object );
+ }
+
+ public boolean equals( final Object o )
+ {
+ if( this == o ) return true;
+ if( !( o instanceof ClassObjectType ) ) return false;
+
+ final ClassObjectType classObjectType = (ClassObjectType)o;
+
+ if( !getType().equals( classObjectType.getType() ) ) return false;
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ return m_clazz.hashCode();
+ }
+}
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file2" /><div class="file">
<span class="pathname" id="added">spice/components/event/src/java/org/spice/event<br /></span>
<div class="fileheader" id="added"><big><b>DefaultEventManager.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N DefaultEventManager.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ DefaultEventManager.java 2 Mar 2005 19:33:52 -0000 1.1
@@ -0,0 +1,227 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.spice.event;
+
+import java.util.EventObject;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.WeakHashMap;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+
+import org.apache.avalon.framework.logger.Logger;
+
+import EDU.oswego.cs.dl.util.concurrent.CopyOnWriteArraySet;
+import EDU.oswego.cs.dl.util.concurrent.ReadWriteLock;
+import EDU.oswego.cs.dl.util.concurrent.ReaderPreferenceReadWriteLock;
+import EDU.oswego.cs.dl.util.concurrent.SyncMap;
+import EDU.oswego.cs.dl.util.concurrent.WriterPreferenceReadWriteLock;
+import org.drools.FactException;
+import org.drools.RuleBase;
+import org.drools.RuleBaseBuilder;
+import org.drools.RuleIntegrationException;
+import org.drools.RuleSetIntegrationException;
+import org.drools.WorkingMemory;
+import org.drools.rule.RuleSet;
+
+/**
+ * @author <a href="mailto:[email protected]">peter royal</a>
+ */
+public class DefaultEventManager implements EventPublisher, EventRegister
+{
+ private final Set m_subscribers = new CopyOnWriteArraySet();
+ private final ReadWriteLock m_lock = new WriterPreferenceReadWriteLock();
+ private final Map m_workingMemories = new SyncMap( new WeakHashMap(), new ReaderPreferenceReadWriteLock() );
+
+ private final Logger m_logger;
+ private final TransactionManager m_transactionManager;
+
+ private RuleBase m_ruleBase;
+
+ public DefaultEventManager( final TransactionManager transactionManager,
+ final Logger logger )
+ throws RuleIntegrationException, RuleSetIntegrationException
+ {
+ m_transactionManager = transactionManager;
+ m_logger = logger;
+
+ rebuildRuleBase();
+ }
+
+ public void publish( final EventObject event )
+ {
+ try
+ {
+ m_lock.readLock().acquire();
+ }
+ catch( InterruptedException e )
+ {
+ throw new RuntimeException( "Unable to aquire read lock on RuleBase", e );
+ }
+
+ try
+ {
+ final WorkingMemory workingMemory = getWorkingMemory();
+
+ workingMemory.assertObject( event );
+ workingMemory.fireAllRules();
+ }
+ catch( FactException e )
+ {
+ throw new PublicationException( event, e );
+ }
+ catch( SystemException e )
+ {
+ throw new RuntimeException( "Transaction failure when processing event '" + event + "'", e );
+ }
+ finally
+ {
+ m_lock.readLock().release();
+ }
+ }
+
+ /**
+ * Get the <code>WorkingMemory</code> for the in-progress transaction. If there is no transaction in progress, a new
+ * <code>WorkingMemory</code> is returned.
+ *
+ * We are only checking against the current Transaction instance, and not registering an XAResource since we don't
+ * care about doing anything on commit/rollback.
+ *
+ * @return <code>WorkingMemory</code> instance
+ *
+ * @throws SystemException on failure to get current <code>Transaction</code>
+ */
+ private WorkingMemory getWorkingMemory() throws SystemException
+ {
+ final Transaction transaction = m_transactionManager.getTransaction();
+
+ if( null == transaction )
+ {
+ return m_ruleBase.newWorkingMemory();
+ }
+ else
+ {
+ WorkingMemory workingMemory = (WorkingMemory)m_workingMemories.get( transaction );
+
+ if( null == workingMemory )
+ {
+ workingMemory = m_ruleBase.newWorkingMemory();
+
+ m_workingMemories.put( transaction, workingMemory );
+ }
+
+ return workingMemory;
+ }
+ }
+
+ public void subscribe( final Subscriber subscriber )
+ {
+ if( null == subscriber )
+ {
+ throw new NullPointerException( "subscriber" );
+ }
+
+ if( getLogger().isDebugEnabled() ) getLogger().debug( "Adding subscriber: " + subscriber );
+
+ m_subscribers.add( subscriber );
+
+ try
+ {
+ rebuildRuleBase();
+ }
+ catch( RuleIntegrationException e )
+ {
+ final String msg = "Unable to rebuild RuleBase after adding Subscriber. "
+ + "Reported '" + e.getMessage() + "' on rule: " + e.getRule();
+
+ throw new EventManagerRuntimeException( msg, e );
+ }
+ catch( RuleSetIntegrationException e )
+ {
+ final String msg = "Unable to rebuild RuleBase after adding Subscriber. "
+ + "Reported '" + e.getMessage() + "' on ruleset: " + e.getRuleSet().getName();
+
+ throw new EventManagerRuntimeException( msg, e );
+ }
+ }
+
+ public void unsubscribe( final Subscriber subscriber ) throws NoSuchSubscriberException
+ {
+ if( m_subscribers.remove( subscriber ) )
+ {
+ try
+ {
+ rebuildRuleBase();
+ }
+ catch( RuleIntegrationException e )
+ {
+ final String msg = "Unable to rebuild RuleBase after removing Subscriber. Subscriber modified rules "
+ + "after initial subscription or internal drools error. "
+ + "Reported '" + e.getMessage() + "' on rule: " + e.getRule();
+
+ throw new EventManagerRuntimeException( msg, e );
+ }
+ catch( RuleSetIntegrationException e )
+ {
+ final String msg = "Unable to rebuild RuleBase after removing Subscriber. Subscriber modified rules "
+ + "after initial subscription or internal drools error. "
+ + "Reported '" + e.getMessage() + "' on ruleset: " + e.getRuleSet().getName();
+
+ throw new EventManagerRuntimeException( msg, e );
+ }
+ }
+ else
+ {
+ throw new NoSuchSubscriberException();
+ }
+ }
+
+ private void rebuildRuleBase() throws RuleIntegrationException, RuleSetIntegrationException
+ {
+ try
+ {
+ m_lock.writeLock().acquire();
+ }
+ catch( InterruptedException e )
+ {
+ throw new RuntimeException( "Unable to aquire write lock on RuleBase", e );
+ }
+
+ try
+ {
+ final RuleBaseBuilder builder = new RuleBaseBuilder();
+ final Iterator i = m_subscribers.iterator();
+
+ while( i.hasNext() )
+ {
+ final Subscriber subscriber = (Subscriber)i.next();
+ final RuleSet ruleSet = subscriber.getRuleSet();
+
+ if( null == ruleSet )
+ {
+ throw new EventManagerRuntimeException( "Subscriber had null RuleSet" );
+ }
+
+ builder.addRuleSet( ruleSet );
+ }
+
+ m_ruleBase = builder.build();
+ }
+ finally
+ {
+ m_lock.writeLock().release();
+ }
+ }
+
+ private Logger getLogger()
+ {
+ return m_logger;
+ }
+}
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file3" /><div class="file">
<span class="pathname" id="added">spice/components/event/src/java/org/spice/event<br /></span>
<div class="fileheader" id="added"><big><b>EventManagerRuntimeException.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N EventManagerRuntimeException.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ EventManagerRuntimeException.java 2 Mar 2005 19:33:52 -0000 1.1
@@ -0,0 +1,24 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.spice.event;
+
+/**
+ * @author <a href="mailto:[email protected]">peter royal</a>
+ */
+public class EventManagerRuntimeException extends RuntimeException
+{
+ public EventManagerRuntimeException( final String message, final Throwable cause )
+ {
+ super( message, cause );
+ }
+
+ public EventManagerRuntimeException( final String message )
+ {
+ super( message );
+ }
+}
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file4" /><div class="file">
<span class="pathname" id="added">spice/components/event/src/java/org/spice/event<br /></span>
<div class="fileheader" id="added"><big><b>EventPublisher.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N EventPublisher.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ EventPublisher.java 2 Mar 2005 19:33:52 -0000 1.1
@@ -0,0 +1,18 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.spice.event;
+
+import java.util.EventObject;
+
+/**
+ * @author <a href="mailto:[email protected]">peter royal</a>
+ */
+public interface EventPublisher
+{
+ void publish( EventObject event );
+}
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file5" /><div class="file">
<span class="pathname" id="added">spice/components/event/src/java/org/spice/event<br /></span>
<div class="fileheader" id="added"><big><b>EventRegister.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N EventRegister.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ EventRegister.java 2 Mar 2005 19:33:52 -0000 1.1
@@ -0,0 +1,19 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.spice.event;
+
+
+/**
+ * @author <a href="mailto:[email protected]">peter royal</a>
+ */
+public interface EventRegister
+{
+ void subscribe( Subscriber subscriber );
+
+ void unsubscribe( Subscriber subscriber ) throws NoSuchSubscriberException;
+}
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file6" /><div class="file">
<span class="pathname" id="added">spice/components/event/src/java/org/spice/event<br /></span>
<div class="fileheader" id="added"><big><b>NoSuchSubscriberException.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N NoSuchSubscriberException.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ NoSuchSubscriberException.java 2 Mar 2005 19:33:52 -0000 1.1
@@ -0,0 +1,18 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.spice.event;
+
+/**
+ * @author <a href="mailto:[email protected]">peter royal</a>
+ */
+public class NoSuchSubscriberException extends Exception
+{
+ public NoSuchSubscriberException()
+ {
+ }
+}
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file7" /><div class="file">
<span class="pathname" id="added">spice/components/event/src/java/org/spice/event<br /></span>
<div class="fileheader" id="added"><big><b>PublicationException.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N PublicationException.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ PublicationException.java 2 Mar 2005 19:33:52 -0000 1.1
@@ -0,0 +1,32 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.spice.event;
+
+import java.util.EventObject;
+
+import org.drools.FactException;
+
+/**
+ * @author <a href="mailto:[email protected]">peter royal</a>
+ */
+public class PublicationException extends RuntimeException
+{
+ private final EventObject m_event;
+
+ public PublicationException( final EventObject event, final FactException e )
+ {
+ super( "Unable to publish event '" + event + "' due to " + e.getMessage(), e );
+
+ m_event = event;
+ }
+
+ public EventObject getEvent()
+ {
+ return m_event;
+ }
+}
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file8" /><div class="file">
<span class="pathname" id="added">spice/components/event/src/java/org/spice/event<br /></span>
<div class="fileheader" id="added"><big><b>Subscriber.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N Subscriber.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Subscriber.java 2 Mar 2005 19:33:52 -0000 1.1
@@ -0,0 +1,25 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.spice.event;
+
+import java.util.EventListener;
+
+import org.drools.rule.RuleSet;
+
+/**
+ * @author <a href="mailto:[email protected]">peter royal</a>
+ */
+public interface Subscriber extends EventListener
+{
+ /**
+ * Get the {@link RuleSet} that will drive the events that this Subscriber gets notified of.
+ *
+ * @return RuleSet instance. Must never be null.
+ */
+ RuleSet getRuleSet();
+}
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file9" /><div class="file">
<span class="pathname" id="added">spice/components/event/src/java/org/spice/event<br /></span>
<div class="fileheader" id="added"><big><b>TupleMemberNotNullCondition.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N TupleMemberNotNullCondition.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ TupleMemberNotNullCondition.java 2 Mar 2005 19:33:52 -0000 1.1
@@ -0,0 +1,41 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.spice.event;
+
+import org.drools.rule.Declaration;
+import org.drools.spi.Condition;
+import org.drools.spi.ConditionException;
+import org.drools.spi.Tuple;
+
+/**
+ * @author <a href="mailto:[email protected]">peter royal</a>
+ */
+public class TupleMemberNotNullCondition implements Condition
+{
+ private final Declaration m_declaration;
+
+ public TupleMemberNotNullCondition( final Declaration declaration )
+ {
+ if( null == declaration )
+ {
+ throw new NullPointerException( "declaration" );
+ }
+
+ m_declaration = declaration;
+ }
+
+ public Declaration[] getRequiredTupleMembers()
+ {
+ return new Declaration[]{m_declaration};
+ }
+
+ public boolean isAllowed( final Tuple tuple ) throws ConditionException
+ {
+ return null != tuple.get( m_declaration );
+ }
+}
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file10" /><div class="file">
<span class="pathname" id="added">spice/components/event/src/test/org/spice/event<br /></span>
<div class="fileheader" id="added"><big><b>DefaultEventManagerTestCase.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N DefaultEventManagerTestCase.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ DefaultEventManagerTestCase.java 2 Mar 2005 19:33:52 -0000 1.1
@@ -0,0 +1,94 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.spice.event;
+
+import org.apache.avalon.framework.logger.ConsoleLogger;
+
+import junit.framework.TestCase;
+import org.drools.RuleIntegrationException;
+import org.drools.rule.RuleSet;
+
+/**
+ * @author <a href="mailto:[email protected]">peter royal</a>
+ */
+public class DefaultEventManagerTestCase extends TestCase
+{
+ private DefaultEventManager m_eventManager;
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ m_eventManager = new DefaultEventManager( null, new ConsoleLogger() );
+ }
+
+ public void testRegisterUnregister() throws Exception
+ {
+ final MockSubscriber subscriber = new MockSubscriber( new RuleSet( "test" ) );
+
+ m_eventManager.subscribe( subscriber );
+ m_eventManager.unsubscribe( subscriber );
+ }
+
+ public void testUnregisterWithoutRegister() throws Exception
+ {
+ try
+ {
+ m_eventManager.unsubscribe( new MockSubscriber( null ) );
+
+ fail( "Do not allow unsubscribe without subscribe" );
+ }
+ catch( NoSuchSubscriberException e )
+ {
+ assertTrue( "nothing registered", true );
+ }
+ }
+
+ public void testRegisterNull() throws RuleIntegrationException
+ {
+ try
+ {
+ m_eventManager.subscribe( null );
+
+ fail( "Did not throw NPE upon registering null" );
+ }
+ catch( NullPointerException e )
+ {
+ assertEquals( "subscriber", e.getMessage() );
+ }
+ }
+
+ public void testRegisterWithNullRuleset() throws RuleIntegrationException
+ {
+ try
+ {
+ m_eventManager.subscribe( new MockSubscriber( null ) );
+
+ fail( "Cannot register null ruleset" );
+ }
+ catch( EventManagerRuntimeException e )
+ {
+ assertEquals( "Subscriber had null RuleSet", e.getMessage() );
+ }
+ }
+
+ private static class MockSubscriber implements Subscriber
+ {
+ private final RuleSet m_ruleSet;
+
+ public MockSubscriber( final RuleSet ruleSet )
+ {
+ m_ruleSet = ruleSet;
+ }
+
+ public RuleSet getRuleSet()
+ {
+ return m_ruleSet;
+ }
+ }
+}
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file11" /><div class="file">
<span class="pathname" id="added">spice/components/event<br /></span>
<div class="fileheader" id="added"><big><b>project.xml</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N project.xml
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ project.xml 2 Mar 2005 19:33:52 -0000 1.1
@@ -0,0 +1,81 @@
</small></pre><pre class="diff" id="added">+<?xml version="1.0"?>
+<project>
+ <extend>${basedir}/../../project.xml</extend>
+ <name>Spice Event</name>
+
+ <artifactId>spice-event</artifactId>
+ <currentVersion>1.0-M1</currentVersion>
+ <inceptionYear>2005</inceptionYear>
+
+ <shortDescription>A component process events with a rules engine</shortDescription>
+
+ <description>
+ Spice Event is a simple component that lets you utilize the Drools rule engine in the processing of events.
+ </description>
+
+ <versions>
+ <version>
+ <id>current</id>
+ <name>Current</name>
+ <tag>HEAD</tag>
+ </version>
+ </versions>
+
+ <dependencies>
+ <dependency>
+ <groupId>avalon</groupId>
+ <artifactId>avalon-framework</artifactId>
+ <version>4.1.4</version>
+ <properties>
+ <category>runtime</category>
+ </properties>
+ </dependency>
+
+ <dependency>
+ <groupId>concurrent</groupId>
+ <artifactId>concurrent</artifactId>
+ <version>1.3.4</version>
+ <properties>
+ <category>runtime</category>
+ </properties>
+ </dependency>
+
+ <dependency>
+ <groupId>geronimo-spec</groupId>
+ <artifactId>geronimo-spec-jta</artifactId>
+ <version>1.0.1B-rc4</version>
+ <properties>
+ <category>runtime</category>
+ </properties>
+ </dependency>
+
+ <dependency>
+ <groupId>drools</groupId>
+ <artifactId>drools-core</artifactId>
+ <version>2.0-beta-21</version>
+ <properties>
+ <category>runtime</category>
+ </properties>
+ </dependency>
+
+ <dependency>
+ <groupId>drools</groupId>
+ <artifactId>drools-smf</artifactId>
+ <version>2.0-beta-21</version>
+ <properties>
+ <category>runtime</category>
+ </properties>
+ </dependency>
+ </dependencies>
+
+ <developers>
+ <developer>
+ <name>Peter Royal</name>
+ <id>proyal</id>
+ <email>[email protected]</email>
+ <roles>
+ <role>Developer</role>
+ </roles>
+ </developer>
+ </developers>
+</project>
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<center><small><a href="http://www.badgers-in-foil.co.uk/projects/cvsspam/" title="commit -> email">CVSspam</a> 0.2.8</small></center>
</body></html>