[CVS spice] Make exceptions unchecked. Provide facilities for a Subscriber to request a rebuild of the event rulebase.

proyal-yCVjj/[email protected] 12 Mar 2005 17:40:48 -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</tt></b><span id="info"> on MAIN</span></td></tr>
<tr><td><tt>event/src/java/org/codehaus/spice/event/<a href="#file1">DefaultEventManager.java</a></tt></td><td align="right" id="added">+40</td><td></td><td nowrap="nowrap" align="center">1.1 -&gt; 1.2</td></tr>
<tr class="alt"><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file2">EventRegister.java</a></tt></td><td align="right" id="added">+2</td><td></td><td nowrap="nowrap" align="center">1.1 -&gt; 1.2</td></tr>
<tr><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file3">NoSuchSubscriberException.java</a></tt></td><td align="right" id="added">+1</td><td align="right" id="removed">-1</td><td nowrap="nowrap" align="center">1.1 -&gt; 1.2</td></tr>
<tr class="alt"><td><tt>message/src/java/org/codehaus/spice/message/<a href="#file4">MessageException.java</a></tt></td><td align="right" id="added">+1</td><td align="right" id="removed">-1</td><td nowrap="nowrap" align="center">1.1 -&gt; 1.2</td></tr>
<tr><td></td><td align="right" id="added">+44</td><td align="right" id="removed">-2</td><td></td></tr>
</table>
<small id="info">4 modified files</small><br />
<pre class="comment">
Make exceptions unchecked. Provide facilities for a Subscriber to request a rebuild of the event rulebase.
Also provide method to get at the created RuleBase (to, say, dump the RETE)
</pre>
<hr /><a name="file1" /><div class="file">
<span class="pathname">spice/components/event/src/java/org/codehaus/spice/event<br /></span>
<div class="fileheader"><big><b>DefaultEventManager.java</b></big> <small id="info">1.1 -&gt; 1.2</small></div>
<pre class="diff"><small id="info">diff -u -r1.1 -r1.2
--- DefaultEventManager.java	8 Mar 2005 02:58:25 -0000	1.1
+++ DefaultEventManager.java	12 Mar 2005 17:40:47 -0000	1.2
@@ -127,6 +127,10 @@
</small></pre><pre class="diff" id="context">         {
             throw new NullPointerException( "subscriber" );
         }
</pre><pre class="diff" id="added">+        else if( m_subscribers.contains( subscriber ) )
+        {
+            throw new EventManagerRuntimeException( "Already subscribed" );
+        }
</pre><pre class="diff" id="context"> 
         if( getLogger().isDebugEnabled() ) getLogger().debug( "Adding subscriber: " + subscriber );
 
</pre><pre class="diff"><small id="info">@@ -152,6 +156,37 @@
</small></pre><pre class="diff" id="context">         }
     }
 
</pre><pre class="diff" id="added">+    public void rebuild( final Subscriber subscriber )
+    {
+        if( m_subscribers.contains( subscriber ) )
+        {
+            try
+            {
+                rebuildRuleBase();
+            }
+            catch( RuleIntegrationException e )
+            {
+                final String msg = "Unable to rebuild RuleBase after notification from Subscriber. "
+                    + "Subscriber modified rulesafter 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 notification from Subscriber. "
+                    + "Subscriber modified rulesafter initial subscription or internal drools error. "
+                    + "Reported '" + e.getMessage() + "' on ruleset: " + e.getRuleSet().getName();
+
+                throw new EventManagerRuntimeException( msg, e );
+            }
+        }
+        else
+        {
+            throw new NoSuchSubscriberException();
+        }
+    }
+
</pre><pre class="diff" id="context">     public void unsubscribe( final Subscriber subscriber ) throws NoSuchSubscriberException
     {
         if( m_subscribers.remove( subscriber ) )
</pre><pre class="diff"><small id="info">@@ -223,5 +258,10 @@
</small></pre><pre class="diff" id="context">     private Logger getLogger()
     {
         return m_logger;
</pre><pre class="diff" id="added">+    }
+
+    public RuleBase getRuleBase()
+    {
+        return m_ruleBase;
</pre><pre class="diff" id="context">     }
 }
</pre></div>
<hr /><a name="file2" /><div class="file">
<span class="pathname">spice/components/event/src/java/org/codehaus/spice/event<br /></span>
<div class="fileheader"><big><b>EventRegister.java</b></big> <small id="info">1.1 -&gt; 1.2</small></div>
<pre class="diff"><small id="info">diff -u -r1.1 -r1.2
--- EventRegister.java	8 Mar 2005 02:58:26 -0000	1.1
+++ EventRegister.java	12 Mar 2005 17:40:48 -0000	1.2
@@ -16,4 +16,6 @@
</small></pre><pre class="diff" id="context">     void subscribe( Subscriber subscriber );
 
     void unsubscribe( Subscriber subscriber ) throws NoSuchSubscriberException;
</pre><pre class="diff" id="added">+
+    void rebuild( Subscriber subscriber );
</pre><pre class="diff" id="context"> }
</pre></div>
<hr /><a name="file3" /><div class="file">
<span class="pathname">spice/components/event/src/java/org/codehaus/spice/event<br /></span>
<div class="fileheader"><big><b>NoSuchSubscriberException.java</b></big> <small id="info">1.1 -&gt; 1.2</small></div>
<pre class="diff"><small id="info">diff -u -r1.1 -r1.2
--- NoSuchSubscriberException.java	8 Mar 2005 02:58:26 -0000	1.1
+++ NoSuchSubscriberException.java	12 Mar 2005 17:40:48 -0000	1.2
@@ -10,7 +10,7 @@
</small></pre><pre class="diff" id="context"> /**
  * @author &lt;a href="mailto:[email protected]"&gt;peter royal&lt;/a&gt;
  */
</pre><pre class="diff" id="removed">-public class NoSuchSubscriberException extends Exception
</pre><pre class="diff" id="added">+public class NoSuchSubscriberException extends <span id="addedchars">Runtime</span>Exception
</pre><pre class="diff" id="context"> {
     public NoSuchSubscriberException()
     {
</pre></div>
<hr /><a name="file4" /><div class="file">
<span class="pathname">spice/components/message/src/java/org/codehaus/spice/message<br /></span>
<div class="fileheader"><big><b>MessageException.java</b></big> <small id="info">1.1 -&gt; 1.2</small></div>
<pre class="diff"><small id="info">diff -u -r1.1 -r1.2
--- MessageException.java	8 Mar 2005 02:58:48 -0000	1.1
+++ MessageException.java	12 Mar 2005 17:40:48 -0000	1.2
@@ -10,7 +10,7 @@
</small></pre><pre class="diff" id="context"> /**
  * @author &lt;a href="mailto:[email protected]"&gt;peter royal&lt;/a&gt;
  */
</pre><pre class="diff" id="removed">-public class MessageException extends Exception
</pre><pre class="diff" id="added">+public class MessageException extends <span id="addedchars">Runtime</span>Exception
</pre><pre class="diff" id="context"> {
     public MessageException( final String message )
     {
</pre></div>
<center><small><a href="http://www.badgers-in-foil.co.uk/projects/cvsspam/" title="commit -&gt; email">CVSspam</a> 0.2.8</small></center>
</body></html>