hlship      2004/07/19 06:46:02

  Modified:    framework/src/java/org/apache/hivemind/service/impl
                        BuilderFacet.java BuilderFactoryLogic.java
               framework/src/test/hivemind/test/services
                        TestBuilderFactory.java
  Log:
  Add debugging output to BuilderFactory to show which properties are set (and 
why).
  
  Revision  Changes    Path
  1.8       +21 -18    
jakarta-hivemind/framework/src/java/org/apache/hivemind/service/impl/BuilderFacet.java
  
  Index: BuilderFacet.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/service/impl/BuilderFacet.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- BuilderFacet.java 18 Jul 2004 14:43:12 -0000      1.7
  +++ BuilderFacet.java 19 Jul 2004 13:46:02 -0000      1.8
  @@ -14,6 +14,7 @@
   
   package org.apache.hivemind.service.impl;
   
  +import org.apache.commons.logging.Log;
   import org.apache.hivemind.impl.BaseLocatable;
   import org.apache.hivemind.internal.Module;
   import org.apache.hivemind.util.PropertyUtils;
  @@ -53,19 +54,19 @@
           _propertyName = string;
       }
   
  -     /**
  -      * Attempts to autowire a property of the target.  This requires that
  -      * <ul>
  -      * <li>The facet type defines a default property name and facet type
  -      * <li>The facet instance does not have a specified property name
  -      * <li>The (default) property is writeable
  -      * <li>The (default) property is assignable from the facet type
  -      * </ul>
  -      * 
  -      * If all conditions are met, then the property is updated to the facet 
value, and
  -      * the property name is returned.  In all other cases, null is returned.
  -      */
  -    public String autowire(Object target, String serviceId, Module 
invokingModule)
  +    /**
  +     * Attempts to autowire a property of the target.  This requires that
  +     * <ul>
  +     * <li>The facet type defines a default property name and facet type
  +     * <li>The facet instance does not have a specified property name
  +     * <li>The (default) property is writeable
  +     * <li>The (default) property is assignable from the facet type
  +     * </ul>
  +     * 
  +     * If all conditions are met, then the property is updated to the facet 
value, and
  +     * the property name is returned.  In all other cases, null is returned.
  +     */
  +    public String autowire(Object target, String serviceId, Module 
invokingModule, Log log)
       {
           if (_propertyName != null)
               return null;
  @@ -84,14 +85,16 @@
               && PropertyUtils.getPropertyType(target, 
defaultPropertyName).isAssignableFrom(facetType))
           {
   
  -            PropertyUtils.write(
  -                target,
  -                defaultPropertyName,
  -                getFacetValue(serviceId, invokingModule, facetType));
  +            Object facetValue = getFacetValue(serviceId, invokingModule, 
facetType);
  +
  +            PropertyUtils.write(target, defaultPropertyName, facetValue);
  +
  +            if (log.isDebugEnabled())
  +                log.debug("Autowired property " + defaultPropertyName + " to 
" + facetValue);
   
               return defaultPropertyName;
           }
  -        
  +
           return null;
       }
   
  
  
  
  1.3       +14 -5     
jakarta-hivemind/framework/src/java/org/apache/hivemind/service/impl/BuilderFactoryLogic.java
  
  Index: BuilderFactoryLogic.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/service/impl/BuilderFactoryLogic.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BuilderFactoryLogic.java  18 Jul 2004 14:43:12 -0000      1.2
  +++ BuilderFactoryLogic.java  19 Jul 2004 13:46:02 -0000      1.3
  @@ -220,10 +220,10 @@
   
       }
   
  -     /**
  -      * Wire (or auto-wire) the property; return the name of the property 
actually set
  -      * (if a property is set, which is not always the case).
  -      */
  +    /**
  +     * Wire (or auto-wire) the property; return the name of the property 
actually set
  +     * (if a property is set, which is not always the case).
  +     */
       private String wireProperty(Object service, BuilderFacet facet)
       {
           String propertyName = facet.getPropertyName();
  @@ -232,7 +232,8 @@
           {
               // Autowire the property (if possible).
   
  -            String autowirePropertyName = facet.autowire(service, 
_serviceId, _contributingModule);
  +            String autowirePropertyName =
  +                facet.autowire(service, _serviceId, _contributingModule, 
_log);
   
               if (autowirePropertyName != null)
                   return autowirePropertyName;
  @@ -250,6 +251,9 @@
   
               PropertyUtils.write(service, propertyName, value);
   
  +            if (_log.isDebugEnabled())
  +                _log.debug("Set property " + propertyName + " to " + value);
  +
               return propertyName;
           }
           catch (Exception ex)
  @@ -289,6 +293,11 @@
               Object collaboratingService = 
_contributingModule.getService(propertyType);
   
               PropertyUtils.write(service, propertyName, collaboratingService);
  +
  +            if (_log.isDebugEnabled())
  +                _log.debug(
  +                    "Autowired service property " + propertyName + " to " + 
collaboratingService);
  +
           }
           catch (Exception ex)
           {
  
  
  
  1.11      +5 -1      
jakarta-hivemind/framework/src/test/hivemind/test/services/TestBuilderFactory.java
  
  Index: TestBuilderFactory.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-hivemind/framework/src/test/hivemind/test/services/TestBuilderFactory.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- TestBuilderFactory.java   18 Jul 2004 14:43:12 -0000      1.10
  +++ TestBuilderFactory.java   19 Jul 2004 13:46:02 -0000      1.11
  @@ -282,7 +282,8 @@
           MockControl mc = newControl(Module.class);
           Module module = (Module) mc.getMock();
   
  -        Log log = (Log) newMock(Log.class);
  +             MockControl lc = newControl(Log.class);
  +        Log log = (Log) lc.getMock();
   
           BuilderParameter parameter = new BuilderParameter();
   
  @@ -294,6 +295,9 @@
           module.getService(StringHolder.class);
           mc.setReturnValue(h);
   
  +             log.isDebugEnabled();
  +             lc.setReturnValue(false);
  +             
           replayControls();
   
           parameter.setClassName(ServiceAutowireTarget.class.getName());
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to