Clover coverage report - Drools - 2.0-rc2
Coverage timestamp: Wed May 11 2005 07:12:26 BST
file stats: LOC: 169   Methods: 5
NCLOC: 45   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
RuleAdministratorImpl.java 100% 100% 100% 100%
coverage
 1    package org.drools.jsr94.rules.admin;
 2   
 3    /*
 4    * $Id: RuleAdministratorImpl.java,v 1.14 2004/12/04 04:54:07 dbarnett Exp $
 5    *
 6    * Copyright 2002-2004 (C) The Werken Company. All Rights Reserved.
 7    *
 8    * Redistribution and use of this software and associated documentation
 9    * ("Software"), with or without modification, are permitted provided that the
 10    * following conditions are met:
 11    *
 12    * 1. Redistributions of source code must retain copyright statements and
 13    * notices. Redistributions must also contain a copy of this document.
 14    *
 15    * 2. Redistributions in binary form must reproduce the above copyright notice,
 16    * this list of conditions and the following disclaimer in the documentation
 17    * and/or other materials provided with the distribution.
 18    *
 19    * 3. The name "drools" must not be used to endorse or promote products derived
 20    * from this Software without prior written permission of The Werken Company.
 21    * For written permission, please contact bob@werken.com.
 22    *
 23    * 4. Products derived from this Software may not be called "drools" nor may
 24    * "drools" appear in their names without prior written permission of The Werken
 25    * Company. "drools" is a registered trademark of The Werken Company.
 26    *
 27    * 5. Due credit should be given to The Werken Company.
 28    * (http://drools.werken.com/).
 29    *
 30    * THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS ``AS IS''
 31    * AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 32    * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 33    * ARE DISCLAIMED. IN NO EVENT SHALL THE WERKEN COMPANY OR ITS CONTRIBUTORS BE
 34    * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 35    * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 36    * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 37    * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 38    * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 39    * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 40    * POSSIBILITY OF SUCH DAMAGE.
 41    *
 42    */
 43   
 44    import java.util.Map;
 45   
 46    import javax.rules.admin.LocalRuleExecutionSetProvider;
 47    import javax.rules.admin.RuleAdministrator;
 48    import javax.rules.admin.RuleExecutionSet;
 49    import javax.rules.admin.RuleExecutionSetDeregistrationException;
 50    import javax.rules.admin.RuleExecutionSetProvider;
 51    import javax.rules.admin.RuleExecutionSetRegisterException;
 52   
 53    /**
 54    * The Drools implementation of the <code>RuleAdministrator</code> interface
 55    * which is used by rule execution set administrators to load rule execution
 56    * sets from external sources and create a <code>RuleExecutionSet</code>
 57    * runtime object.
 58    * <p/>
 59    * The <code>RuleAdministrator</code> should be accessed by calling:
 60    * <p/>
 61    * <code>
 62    * RuleServiceProvider ruleServiceProvider =
 63    * RuleServiceProvider.newInstance();<br/>
 64    * RuleAdministrator ruleAdministration =
 65    * ruleServiceProvider.getRuleAdministrator();
 66    * </code>
 67    * <p/>
 68    * In an additional step the administrator may also choose to bind the
 69    * <code>RuleExecutionSet</code> instance to a URI so that it is globally
 70    * accessible and <code>RuleSession</code>s can be created for the
 71    * <code>RuleExecutionSet</code> through the RuleRuntime.
 72    *
 73    * @see RuleAdministrator
 74    *
 75    * @author N. Alex Rupp (n_alex <at>codehaus.org)
 76    * @author <a href="mailto:thomas.diesler@softcon-itec.de">thomas diesler </a>
 77    */
 78    public class RuleAdministratorImpl implements RuleAdministrator
 79    {
 80    /** Default constructor. */
 81  49 public RuleAdministratorImpl( )
 82    {
 83  49 super( );
 84    }
 85   
 86    /**
 87    * Returns a <code>RuleExecutionSetProvider</code> implementation.
 88    *
 89    * @param properties additional properties
 90    *
 91    * @return The created <code>RuleExecutionSetProvider</code>.
 92    */
 93  7 public RuleExecutionSetProvider getRuleExecutionSetProvider(
 94    Map properties )
 95    {
 96  7 return new RuleExecutionSetProviderImpl( );
 97    }
 98   
 99    /**
 100    * Returns a <code>LocalRuleExecutionSetProvider</code> implementation.
 101    *
 102    * Returns a <code>LocalRuleExecutionSetProvider</code> implementation
 103    * or null if this implementation does not support creating a
 104    * <code>RuleExecutionSet</code> from non-serializable resources.
 105    *
 106    * @param properties additional properties
 107    *
 108    * @return The created <code>LocalRuleExecutionSetProvider</code>.
 109    */
 110  56 public LocalRuleExecutionSetProvider getLocalRuleExecutionSetProvider(
 111    Map properties )
 112    {
 113  56 return new LocalRuleExecutionSetProviderImpl( );
 114    }
 115   
 116    /**
 117    * Registers a <code>RuleExecutionSet</code> and associates it with a
 118    * given URI. Once a <code>RuleExecutionSet</code> has been registered it
 119    * is accessible to runtime clients through the <code>RuleRuntime</code>.
 120    * If a <code>RuleExecutionSet</code> has already been associated with
 121    * the URI it should be deregistered (as if
 122    * <code>deregisterRuleExecutionSet/</code> had been called) and the URI
 123    * should be associated with the new <code>RuleExecutionSet</code>.
 124    *
 125    * @param bindUri the URI to associate with the
 126    * <code>RuleExecutionSet</code>.
 127    * @param set the <code>RuleExecutionSet</code> to associate with the URI
 128    * @param properties additional properties used to perform the registration
 129    *
 130    * @throws RuleExecutionSetRegisterException if an error occurred that
 131    * prevented registration
 132    */
 133  48 public void registerRuleExecutionSet(
 134    String bindUri, RuleExecutionSet set, Map properties )
 135    throws RuleExecutionSetRegisterException
 136    {
 137    // Note: an existing RuleExecutionSet is simply replaced
 138  48 RuleExecutionSetRepository repository =
 139    RuleExecutionSetRepository.getInstance( );
 140  48 repository.registerRuleExecutionSet( bindUri, set );
 141    }
 142   
 143    /**
 144    * Unregisters a previously registered <code>RuleExecutionSet</code> from
 145    * a URI.
 146    *
 147    * @param bindUri the URI to disassociate with the
 148    * <code>RuleExecutionSet</code>.
 149    * @param properties additional properties used to perform the
 150    * deregistration
 151    *
 152    * @throws RuleExecutionSetDeregistrationException if an error occurred that
 153    * prevented unregistration
 154    */
 155  9 public void deregisterRuleExecutionSet( String bindUri, Map properties )
 156    throws RuleExecutionSetDeregistrationException
 157    {
 158  9 RuleExecutionSetRepository repository =
 159    RuleExecutionSetRepository.getInstance( );
 160   
 161  9 if ( repository.getRuleExecutionSet( bindUri ) == null )
 162    {
 163  1 throw new RuleExecutionSetDeregistrationException(
 164    "no execution set bound to: " + bindUri );
 165    }
 166   
 167  8 repository.unregisterRuleExecutionSet( bindUri );
 168    }
 169    }