commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject cvs commit: jakarta-commons-sandbox/hivemind/src/META-INF hivemodule.xml
Date Thu, 21 Aug 2003 14:52:09 GMT
hlship      2003/08/21 07:52:09

  Modified:    hivemind/src/test/hivemind/test/services DemoService.java
                        ComplexModule.xml
               hivemind/src/java/org/apache/commons/hivemind/service/impl
                        AbstractServiceInterceptorFactory.java
                        LoggingInterceptorFactory.java
               hivemind/src/META-INF hivemodule.xml
  Added:       hivemind/src/java/org/apache/commons/hivemind/service/impl
                        DefaultsSymbolSource.java
  Removed:     hivemind/src/java/org/apache/commons/hivemind/service/impl
                        FactoryDefaultsSymbolSource.java
  Log:
  Add an ApplicationDefaults extension point to complement FactoryDefaults extension point.
  Have the LoggingInterceptor log all runtime exceptions (in addition to declared checked
exceptions).
  Change AbstractServiceInterceptorFactory to not use the Initializable interface; change
the MDD to configure it using BuilderFactory.
  
  Revision  Changes    Path
  1.2       +3 -3      jakarta-commons-sandbox/hivemind/src/test/hivemind/test/services/DemoService.java
  
  Index: DemoService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/test/hivemind/test/services/DemoService.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DemoService.java	30 Jun 2003 23:04:45 -0000	1.1
  +++ DemoService.java	21 Aug 2003 14:52:09 -0000	1.2
  @@ -74,7 +74,7 @@
   
       /**
        * Used to test runtime failures.  This implementation
  -     * always throws an exception.
  +     * always throws a runtime exception.
        */
  -    public void alwaysFail() throws RuntimeException;
  +    public void alwaysFail();
   }
  
  
  
  1.4       +8 -2      jakarta-commons-sandbox/hivemind/src/test/hivemind/test/services/ComplexModule.xml
  
  Index: ComplexModule.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/test/hivemind/test/services/ComplexModule.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ComplexModule.xml	29 Jul 2003 22:20:41 -0000	1.3
  +++ ComplexModule.xml	21 Aug 2003 14:52:09 -0000	1.4
  @@ -9,6 +9,12 @@
   	</service>
   	
   	<service id="CountFactory" interface="org.apache.commons.hivemind.ServiceInterceptorFactory">
  -	  <create-instance class="hivemind.test.services.impl.CountFactory"/>
  +		<invoke-factory service-id="hivemind.BuilderFactory">
  +			<construct
  +        class="hivemind.test.services.impl.CountFactory"
  +        point-id-property="extensionId">
  +				<set-service property="factory" service-id="hivemind.ClassFactory"/>		
  +			</construct>
  +		</invoke-factory>
   	</service>
   </module>
  
  
  
  1.11      +21 -17    jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/service/impl/AbstractServiceInterceptorFactory.java
  
  Index: AbstractServiceInterceptorFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/service/impl/AbstractServiceInterceptorFactory.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- AbstractServiceInterceptorFactory.java	20 Aug 2003 20:40:46 -0000	1.10
  +++ AbstractServiceInterceptorFactory.java	21 Aug 2003 14:52:09 -0000	1.11
  @@ -62,24 +62,29 @@
   
   import org.apache.commons.hivemind.ApplicationRuntimeException;
   import org.apache.commons.hivemind.HiveMind;
  -import org.apache.commons.hivemind.Initializable;
   import org.apache.commons.hivemind.InterceptorStack;
   import org.apache.commons.hivemind.Module;
  -import org.apache.commons.hivemind.ServiceExtensionPoint;
   import org.apache.commons.hivemind.ServiceInterceptorFactory;
  -import org.apache.commons.hivemind.service.*;
   import org.apache.commons.hivemind.service.ClassFab;
  +import org.apache.commons.hivemind.service.ClassFabUtils;
   import org.apache.commons.hivemind.service.ClassFactory;
   
   /**
    * Base class for creating new service interceptors.  Most implementations
    * merely have to implement {@link #createMethod(ClassFab, String, Class, Class[], Class[])}.
  + * 
  + * <p>
  + * Implementations of this service must be configured with:
  + * <ul>
  + * <li>The extension point id assigned to the <code>extensionId</code>
property
  + * <li>The <code>hivemind.ClassFactory</code> service assigned to the
<code>factory</code> property
  + * </ul>
    *
    * @author Howard Lewis Ship
    * @version $Id$
    */
   public abstract class AbstractServiceInterceptorFactory
  -    implements ServiceInterceptorFactory, Initializable
  +    implements ServiceInterceptorFactory
   {
       private ClassFactory _factory;
       private String _extensionId;
  @@ -128,18 +133,6 @@
           }
       }
   
  -    /**
  -     * Looks up the {@link ClassFactory} in the registry.
  -     */
  -    public void initializeService(ServiceExtensionPoint point, Object service)
  -    {
  -        _extensionId = point.getExtensionPointId();
  -
  -        _factory =
  -            (ClassFactory) point.getModule().getRegistry().getService(
  -                HiveMind.CLASS_FACTORY_SERVICE_ID,
  -                ClassFactory.class);
  -    }
   
       /**
        * Overridden in subclasses to identify the super-class
  @@ -242,4 +235,15 @@
                   + ")>");
   
       }
  +    
  +    public void setExtensionId(String string)
  +    {
  +        _extensionId = string;
  +    }
  +
  +    public void setFactory(ClassFactory factory)
  +    {
  +        _factory = factory;
  +    }
  +
   }
  
  
  
  1.8       +10 -8     jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/service/impl/LoggingInterceptorFactory.java
  
  Index: LoggingInterceptorFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/service/impl/LoggingInterceptorFactory.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- LoggingInterceptorFactory.java	20 Aug 2003 20:40:46 -0000	1.7
  +++ LoggingInterceptorFactory.java	21 Aug 2003 14:52:09 -0000	1.8
  @@ -151,11 +151,6 @@
                   exceptions,
                   builder.toString());
   
  -        int count = exceptions == null ? 0 : exceptions.length;
  -
  -        if (count == 0)
  -            return;
  -
           builder.clear();
   
           builder.begin();
  @@ -165,12 +160,19 @@
           builder.addln("throw $e;");
           builder.end();
   
  -		String body = builder.toString();
  -		
  +        String body = builder.toString();
  +
  +        int count = exceptions == null ? 0 : exceptions.length;
  +
           for (int i = 0; i < count; i++)
           {
               methodFab.addCatch(exceptions[i], body);
           }
  +
  +        // Catch and log any runtime exceptions, in addition to the
  +        // checked exceptions.
  +
  +        methodFab.addCatch(RuntimeException.class, body);
       }
   
       protected Class getInterceptorSuperclass()
  
  
  
  1.1                  jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/service/impl/DefaultsSymbolSource.java
  
  Index: DefaultsSymbolSource.java
  ===================================================================
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, 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 acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", 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 names without prior written
   *    permission of the Apache Group.
   *
   * 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 (INCLUDING, 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.commons.hivemind.service.impl;
  
  import java.util.HashMap;
  import java.util.List;
  import java.util.Map;
  
  import org.apache.commons.hivemind.Initializable;
  import org.apache.commons.hivemind.ServiceExtensionPoint;
  import org.apache.commons.hivemind.SymbolSource;
  import org.apache.commons.hivemind.impl.BaseLocatable;
  
  /**
   * Implementation of {@link org.apache.commons.hivemind.SymbolSource} driven
   * off of an extension point.
   *
   * @author Howard Lewis Ship
   * @version $Id: DefaultsSymbolSource.java,v 1.1 2003/08/21 14:52:09 hlship Exp $
   */
  public class DefaultsSymbolSource
      extends BaseLocatable
      implements SymbolSource, Initializable
  {
      private List _defaults;
      private Map _symbols = new HashMap();
  
      public String valueForSymbol(String name)
      {
          return (String) _symbols.get(name);
      }
  
      public void initializeService(ServiceExtensionPoint point, Object service)
      {
          int count = _defaults.size();
          for (int i = 0; i < count; i++)
          {
              FactoryDefault fd = (FactoryDefault) _defaults.get(i);
  
              _symbols.put(fd.getSymbol(), fd.getValue());
          }
      }
  
      public void setDefaults(List list)
      {
          _defaults = list;
      }
  
  }
  
  
  
  1.17      +36 -6     jakarta-commons-sandbox/hivemind/src/META-INF/hivemodule.xml
  
  Index: hivemodule.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/META-INF/hivemodule.xml,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- hivemodule.xml	20 Aug 2003 20:40:46 -0000	1.16
  +++ hivemodule.xml	21 Aug 2003 14:52:09 -0000	1.17
  @@ -42,6 +42,7 @@
   	
   	<extension point-id="SymbolSource">
   		
  +		<source order="900000" service-id="ApplicationDefaultsSymbolSource"/>
   		<source order="1000000" service-id="FactoryDefaultsSymbolSource"/>
   		
   	</extension>
  @@ -52,7 +53,7 @@
   		Extension point for setting "factory defaults" for symbol values.
   		</description>	
   		
  -		<schema>
  +		<schema id="defaults">
   		
   			<element name="default">
   			
  @@ -84,18 +85,40 @@
   		
   	</extension-point>
   	
  +	<extension-point id="ApplicationDefaults">
  +		
  +		<description>
  +		Extension point for setting application defaults; these defaults will override
  +		factory defaults specified in the FactoryDefaults extension point.	
  +		</description>	
  +		
  +		<schema ref-id="defaults"/>
  +		
  +	</extension-point>
  +	
   	<service id="FactoryDefaultsSymbolSource" interface="org.apache.commons.hivemind.SymbolSource">
   		<description>
   		SymbolSource implementation driven by the FactoryDefaults extension point.	
   		</description>
   		
   		<invoke-factory service-id="BuilderFactory">
  -			<construct class="org.apache.commons.hivemind.service.impl.FactoryDefaultsSymbolSource">
  -			  <set-extension-point point-id="FactoryDefaults" property="factoryDefaults"/>
  +			<construct class="org.apache.commons.hivemind.service.impl.DefaultsSymbolSource">
  +			  <set-extension-point point-id="FactoryDefaults" property="defaults"/>
   			</construct>
   		</invoke-factory>
   	</service>
   	
  +	<service id="ApplicationDefaultsSymbolSource" interface="org.apache.commons.hivemind.SymbolSource">
  +		<description>
  +		SymbolSource implementation driven by the ApplicationDefaults extension point.	
  +		</description>
  +		
  +		<invoke-factory service-id="BuilderFactory">
  +			<construct class="org.apache.commons.hivemind.service.impl.DefaultsSymbolSource">
  +			  <set-extension-point point-id="ApplicationDefaults" property="defaults"/>
  +			</construct>
  +		</invoke-factory>
  +	</service>	
   	
   	<service id="ClassFactory" interface="org.apache.commons.hivemind.service.ClassFactory"
deferrable="false">
   		<description>Wrapper around Javassist used to dynamically create classes such as
service interceptors.</description>
  @@ -107,8 +130,15 @@
   			An interceptor factory for adding method-level logging to a service. 
   			Logging occurs at level DEBUG and uses the service id as the logger. 
   		  Method entry (with parameters) and method exit (with return value) are logged,
  -		  as are any checked exceptions.</description>
  -		<create-instance class="org.apache.commons.hivemind.service.impl.LoggingInterceptorFactory"/>
  +		  as are any exceptions.
  +		 </description>
  +		<invoke-factory service-id="BuilderFactory">
  +			<construct
  +        class="org.apache.commons.hivemind.service.impl.LoggingInterceptorFactory"
  +        point-id-property="extensionId">
  +				<set-service property="factory" service-id="ClassFactory"/>		
  +			</construct>
  +		</invoke-factory>
   	</service>
   	
   	<service id="RemoteExceptionCoordinator"
  
  
  

Mime
View raw message