tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject cvs commit: jakarta-tapestry/framework/src/test/org/apache/tapestry/markup TestMarkupWriter.java
Date Wed, 08 Jun 2005 19:58:44 GMT
hlship      2005/06/08 12:58:44

  Modified:    .        status.xml
               framework/src/java/org/apache/tapestry/enhance
                        InjectSpecificationWorker.java
                        InjectBeanWorker.java InjectStateWorker.java
                        InjectMetaWorker.java InjectObjectWorker.java
                        InjectScriptWorker.java InjectAssetWorker.java
                        InjectComponentWorker.java
                        SpecifiedPropertyWorker.java
                        ParameterPropertyWorker.java
                        InjectMessagesWorker.java
               framework/src/test/org/apache/tapestry/markup
                        TestMarkupWriter.java
  Log:
  Refactor enhancement workers to facilitate annotation support.
  
  Revision  Changes    Path
  1.118     +1 -1      jakarta-tapestry/status.xml
  
  Index: status.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/status.xml,v
  retrieving revision 1.117
  retrieving revision 1.118
  diff -u -r1.117 -r1.118
  --- status.xml	7 Jun 2005 21:26:54 -0000	1.117
  +++ status.xml	8 Jun 2005 19:58:42 -0000	1.118
  @@ -278,7 +278,7 @@
       </release>
     </changes>
     <votes>
  -    <vote title="Tapestry 4.0-alpha-2" date="May 12 2005" dev="HLS">
  +    <vote title="Tapestry 4.0-alpha-3" date="May 12 2005" dev="HLS">
         <motion>Although it hasn't been long since alpha-2, I'd like to release the
next alpha of Tapestry 4.0. Why? A few things have settled down, some bugs have been fixed,
a few really key features have been added, and I think the Portlet support is now complete.</motion>
         <response>HLS, PF, HK, EH, RLS, DS, GL, TSV: +1</response>
       </vote>
  
  
  
  1.6       +5 -1      jakarta-tapestry/framework/src/java/org/apache/tapestry/enhance/InjectSpecificationWorker.java
  
  Index: InjectSpecificationWorker.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/enhance/InjectSpecificationWorker.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- InjectSpecificationWorker.java	7 Jun 2005 17:41:40 -0000	1.5
  +++ InjectSpecificationWorker.java	8 Jun 2005 19:58:42 -0000	1.6
  @@ -15,6 +15,7 @@
   package org.apache.tapestry.enhance;
   
   import org.apache.hivemind.ErrorLog;
  +import org.apache.hivemind.util.Defense;
   import org.apache.tapestry.spec.IComponentSpecification;
   
   /**
  @@ -43,8 +44,11 @@
           }
       }
   
  -    private void injectSpecification(EnhancementOperation op, IComponentSpecification spec)
  +    public void injectSpecification(EnhancementOperation op, IComponentSpecification spec)
       {
  +        Defense.notNull(op, "op");
  +        Defense.notNull(spec, "spec");
  +
           op.claimProperty(SPECIFICATION_PROPERTY_NAME);
   
           String fieldName = op.addInjectedField(
  
  
  
  1.3       +6 -1      jakarta-tapestry/framework/src/java/org/apache/tapestry/enhance/InjectBeanWorker.java
  
  Index: InjectBeanWorker.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/enhance/InjectBeanWorker.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- InjectBeanWorker.java	18 Apr 2005 17:06:34 -0000	1.2
  +++ InjectBeanWorker.java	8 Jun 2005 19:58:43 -0000	1.3
  @@ -20,6 +20,7 @@
   import org.apache.hivemind.ErrorLog;
   import org.apache.hivemind.service.ClassFabUtils;
   import org.apache.hivemind.service.MethodSignature;
  +import org.apache.hivemind.util.Defense;
   import org.apache.tapestry.spec.IBeanSpecification;
   import org.apache.tapestry.spec.IComponentSpecification;
   
  @@ -59,8 +60,12 @@
           }
       }
   
  -    private void injectBean(EnhancementOperation op, String beanName, String propertyName)
  +    public void injectBean(EnhancementOperation op, String beanName, String propertyName)
       {
  +        Defense.notNull(op, "op");
  +        Defense.notNull(beanName, "beanName");
  +        Defense.notNull(propertyName, "propertyName");
  +
           op.claimProperty(propertyName);
   
           Class propertyType = EnhanceUtils.extractPropertyType(op, propertyName, null);
  
  
  
  1.7       +6 -1      jakarta-tapestry/framework/src/java/org/apache/tapestry/enhance/InjectStateWorker.java
  
  Index: InjectStateWorker.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/enhance/InjectStateWorker.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- InjectStateWorker.java	7 Jun 2005 17:41:40 -0000	1.6
  +++ InjectStateWorker.java	8 Jun 2005 19:58:43 -0000	1.7
  @@ -19,6 +19,7 @@
   import org.apache.hivemind.service.BodyBuilder;
   import org.apache.hivemind.service.ClassFabUtils;
   import org.apache.hivemind.service.MethodSignature;
  +import org.apache.hivemind.util.Defense;
   import org.apache.tapestry.engine.state.ApplicationStateManager;
   import org.apache.tapestry.event.PageDetachListener;
   import org.apache.tapestry.spec.InjectSpecification;
  @@ -41,8 +42,12 @@
           injectState(op, spec.getProperty(), spec.getObject());
       }
   
  -    private void injectState(EnhancementOperation op, String propertyName, String objectName)
  +    public void injectState(EnhancementOperation op, String propertyName, String objectName)
       {
  +        Defense.notNull(op, "op");
  +        Defense.notNull(propertyName, "propertyName");
  +        Defense.notNull(objectName, "objectName");
  +
           Class propertyType = EnhanceUtils.extractPropertyType(op, propertyName, null);
           String fieldName = "_$" + propertyName;
   
  
  
  
  1.4       +22 -11    jakarta-tapestry/framework/src/java/org/apache/tapestry/enhance/InjectMetaWorker.java
  
  Index: InjectMetaWorker.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/enhance/InjectMetaWorker.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- InjectMetaWorker.java	7 Jun 2005 17:41:40 -0000	1.3
  +++ InjectMetaWorker.java	8 Jun 2005 19:58:43 -0000	1.4
  @@ -21,6 +21,7 @@
   import org.apache.hivemind.service.BodyBuilder;
   import org.apache.hivemind.service.ClassFabUtils;
   import org.apache.hivemind.service.MethodSignature;
  +import org.apache.hivemind.util.Defense;
   import org.apache.tapestry.coerce.ValueConverter;
   import org.apache.tapestry.services.ComponentPropertySource;
   import org.apache.tapestry.spec.InjectSpecification;
  @@ -55,6 +56,17 @@
       public void performEnhancement(EnhancementOperation op, InjectSpecification spec)
       {
           String propertyName = spec.getProperty();
  +        String metaKey = spec.getObject();
  +
  +        injectMetaValue(op, propertyName, metaKey);
  +    }
  +
  +    public void injectMetaValue(EnhancementOperation op, String propertyName, String metaKey)
  +    {
  +        Defense.notNull(op, "op");
  +        Defense.notNull(propertyName, "propertyName");
  +        Defense.notNull(metaKey, "metaKey");
  +
           Class propertyType = op.getPropertyType(propertyName);
   
           op.claimProperty(propertyName);
  @@ -69,36 +81,35 @@
   
           if (parser != null)
           {
  -            addPrimitive(op, spec, propertyName, sig, sourceName, parser);
  +            addPrimitive(op, metaKey, propertyName, sig, sourceName, parser);
               return;
           }
   
           if (propertyType == char.class)
           {
  -            addCharacterPrimitive(op, spec, propertyName, sig, sourceName);
  +            addCharacterPrimitive(op, metaKey, propertyName, sig, sourceName);
               return;
           }
   
  -        addObject(op, spec, propertyName, propertyType, sig, sourceName);
  -
  +        addObject(op, metaKey, propertyName, propertyType, sig, sourceName);
       }
   
  -    private void addPrimitive(EnhancementOperation op, InjectSpecification spec,
  -            String propertyName, MethodSignature sig, String sourceName, String parser)
  +    private void addPrimitive(EnhancementOperation op, String metaKey, String propertyName,
  +            MethodSignature sig, String sourceName, String parser)
       {
           BodyBuilder builder = new BodyBuilder();
           builder.begin();
           builder.addln(
                   "java.lang.String meta = {0}.getComponentProperty(this, \"{1}\");",
                   sourceName,
  -                spec.getObject());
  +                metaKey);
           builder.addln("return {0}(meta);", parser);
           builder.end();
   
           op.addMethod(Modifier.PUBLIC, sig, builder.toString());
       }
   
  -    private void addCharacterPrimitive(EnhancementOperation op, InjectSpecification spec,
  +    private void addCharacterPrimitive(EnhancementOperation op, String metaKey,
               String propertyName, MethodSignature sig, String sourceName)
       {
           BodyBuilder builder = new BodyBuilder();
  @@ -106,14 +117,14 @@
           builder.addln(
                   "java.lang.String meta = {0}.getComponentProperty(this, \"{1}\");",
                   sourceName,
  -                spec.getObject());
  +                metaKey);
           builder.addln("return meta.charAt(0);");
           builder.end();
   
           op.addMethod(Modifier.PUBLIC, sig, builder.toString());
       }
   
  -    private void addObject(EnhancementOperation op, InjectSpecification spec, String propertyName,
  +    private void addObject(EnhancementOperation op, String metaKey, String propertyName,
               Class propertyType, MethodSignature sig, String sourceName)
       {
           String valueConverterName = op.addInjectedField(
  @@ -127,7 +138,7 @@
           builder.addln(
                   "java.lang.String meta = {0}.getComponentProperty(this, \"{1}\");",
                   sourceName,
  -                spec.getObject());
  +                metaKey);
           builder.addln("return ({0}) {1}.coerceValue(meta, {2});", ClassFabUtils
                   .getJavaClassName(propertyType), valueConverterName, classRef);
           builder.end();
  
  
  
  1.4       +16 -3     jakarta-tapestry/framework/src/java/org/apache/tapestry/enhance/InjectObjectWorker.java
  
  Index: InjectObjectWorker.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/enhance/InjectObjectWorker.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- InjectObjectWorker.java	7 Jun 2005 17:41:40 -0000	1.3
  +++ InjectObjectWorker.java	8 Jun 2005 19:58:43 -0000	1.4
  @@ -17,7 +17,9 @@
   import java.lang.reflect.Modifier;
   
   import org.apache.hivemind.ApplicationRuntimeException;
  +import org.apache.hivemind.Location;
   import org.apache.hivemind.service.MethodSignature;
  +import org.apache.hivemind.util.Defense;
   import org.apache.tapestry.services.InjectedValueProvider;
   import org.apache.tapestry.spec.InjectSpecification;
   
  @@ -36,6 +38,17 @@
       {
           String name = is.getProperty();
           String objectReference = is.getObject();
  +        Location location = is.getLocation();
  +
  +        injectObject(op, name, objectReference, location);
  +    }
  +
  +    public void injectObject(EnhancementOperation op, String name, String objectReference,
  +            Location location)
  +    {
  +        Defense.notNull(op, "op");
  +        Defense.notNull(name, "name");
  +        Defense.notNull(objectReference, "objectReference");
   
           Class propertyType = op.getPropertyType(name);
           if (propertyType == null)
  @@ -45,17 +58,17 @@
   
           op.claimProperty(name);
   
  -        Object injectedValue = _provider.obtainValue(objectReference, is.getLocation());
  +        Object injectedValue = _provider.obtainValue(objectReference, location);
   
           if (injectedValue == null)
               throw new ApplicationRuntimeException(EnhanceMessages
  -                    .locatedValueIsNull(objectReference), is.getLocation(), null);
  +                    .locatedValueIsNull(objectReference), location, null);
   
           if (!propertyType.isAssignableFrom(injectedValue.getClass()))
               throw new ApplicationRuntimeException(EnhanceMessages.incompatibleInjectType(
                       objectReference,
                       injectedValue,
  -                    propertyType), is.getLocation(), null);
  +                    propertyType), location, null);
   
           op.addInjectedField(fieldName, propertyType, injectedValue);
   
  
  
  
  1.4       +31 -2     jakarta-tapestry/framework/src/java/org/apache/tapestry/enhance/InjectScriptWorker.java
  
  Index: InjectScriptWorker.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/enhance/InjectScriptWorker.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- InjectScriptWorker.java	7 Jun 2005 17:41:40 -0000	1.3
  +++ InjectScriptWorker.java	8 Jun 2005 19:58:43 -0000	1.4
  @@ -16,8 +16,10 @@
   
   import java.lang.reflect.Modifier;
   
  +import org.apache.hivemind.Location;
   import org.apache.hivemind.Resource;
   import org.apache.hivemind.service.MethodSignature;
  +import org.apache.hivemind.util.Defense;
   import org.apache.tapestry.IScript;
   import org.apache.tapestry.engine.IScriptSource;
   import org.apache.tapestry.spec.InjectSpecification;
  @@ -35,6 +37,33 @@
       public void performEnhancement(EnhancementOperation op, InjectSpecification spec)
       {
           String propertyName = spec.getProperty();
  +        String scriptName = spec.getObject();
  +        Location location = spec.getLocation();
  +
  +        injectScript(op, propertyName, scriptName, location);
  +    }
  +
  +    /**
  +     * Injects a compiled script.
  +     * 
  +     * @param op
  +     *            the enhancement operation
  +     * @param propertyName
  +     *            the name of the property to inject
  +     * @param scriptName
  +     *            the name of the script (relative to the location)
  +     * @param location
  +     *            the location of the specification; primarily used as the base location
for finding
  +     *            the script.
  +     */
  +
  +    public void injectScript(EnhancementOperation op, String propertyName, String scriptName,
  +            Location location)
  +    {
  +        Defense.notNull(op, "op");
  +        Defense.notNull(propertyName, "propertyName");
  +        Defense.notNull(scriptName, "scriptName");
  +        Defense.notNull(location, "location");
   
           op.claimProperty(propertyName);
   
  @@ -44,9 +73,9 @@
   
           String methodName = op.getAccessorMethodName(propertyName);
   
  -        Resource resource = spec.getLocation().getResource().getRelativeResource(spec.getObject());
  +        Resource resource = location.getResource().getRelativeResource(scriptName);
   
  -        DeferredScript script = new DeferredScriptImpl(resource, _source, spec.getLocation());
  +        DeferredScript script = new DeferredScriptImpl(resource, _source, location);
   
           String fieldName = op.addInjectedField("_$script", IScript.class, script);
   
  
  
  
  1.3       +7 -2      jakarta-tapestry/framework/src/java/org/apache/tapestry/enhance/InjectAssetWorker.java
  
  Index: InjectAssetWorker.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/enhance/InjectAssetWorker.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- InjectAssetWorker.java	18 Apr 2005 17:06:34 -0000	1.2
  +++ InjectAssetWorker.java	8 Jun 2005 19:58:43 -0000	1.3
  @@ -17,6 +17,7 @@
   import java.util.Iterator;
   
   import org.apache.hivemind.ErrorLog;
  +import org.apache.hivemind.util.Defense;
   import org.apache.tapestry.IComponent;
   import org.apache.tapestry.spec.IAssetSpecification;
   import org.apache.tapestry.spec.IComponentSpecification;
  @@ -57,8 +58,12 @@
           }
       }
   
  -    private void injectAsset(EnhancementOperation op, String assetName, String propertyName)
  +    public void injectAsset(EnhancementOperation op, String assetName, String propertyName)
       {
  +        Defense.notNull(op, "op");
  +        Defense.notNull(assetName, "assetName");
  +        Defense.notNull(propertyName, "propertyName");
  +
           Class propertyType = EnhanceUtils.extractPropertyType(op, propertyName, null);
   
           // TODO: Should be compatible with IAsset.
  @@ -72,7 +77,7 @@
           EnhanceUtils.createSimpleAccessor(op, fieldName, propertyName, propertyType);
   
           // i.e. _$fred = getAsset("barney");
  -        
  +
           String code = fieldName + " = getAsset(\"" + assetName + "\");";
   
           op.extendMethodImplementation(IComponent.class, EnhanceUtils.FINISH_LOAD_SIGNATURE,
code);
  
  
  
  1.3       +6 -1      jakarta-tapestry/framework/src/java/org/apache/tapestry/enhance/InjectComponentWorker.java
  
  Index: InjectComponentWorker.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/enhance/InjectComponentWorker.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- InjectComponentWorker.java	18 Apr 2005 17:06:34 -0000	1.2
  +++ InjectComponentWorker.java	8 Jun 2005 19:58:43 -0000	1.3
  @@ -18,6 +18,7 @@
   
   import org.apache.hivemind.ErrorLog;
   import org.apache.hivemind.service.ClassFabUtils;
  +import org.apache.hivemind.util.Defense;
   import org.apache.tapestry.IComponent;
   import org.apache.tapestry.spec.IComponentSpecification;
   import org.apache.tapestry.spec.IContainedComponent;
  @@ -60,8 +61,12 @@
           }
       }
   
  -    private void injectComponent(EnhancementOperation op, String componentId, String propertyName)
  +    public void injectComponent(EnhancementOperation op, String componentId, String propertyName)
       {
  +        Defense.notNull(op, "op");
  +        Defense.notNull(componentId, "componentId");
  +        Defense.notNull(propertyName, "propertyName");
  +
           Class propertyType = EnhanceUtils.extractPropertyType(op, propertyName, null);
   
           op.claimProperty(propertyName);
  
  
  
  1.13      +16 -6     jakarta-tapestry/framework/src/java/org/apache/tapestry/enhance/SpecifiedPropertyWorker.java
  
  Index: SpecifiedPropertyWorker.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/enhance/SpecifiedPropertyWorker.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- SpecifiedPropertyWorker.java	7 Jun 2005 17:41:40 -0000	1.12
  +++ SpecifiedPropertyWorker.java	8 Jun 2005 19:58:43 -0000	1.13
  @@ -77,8 +77,17 @@
           Defense.notNull(ps, "ps");
   
           String propertyName = ps.getName();
  +        String specifiedType = ps.getType();
  +        boolean persistent = ps.isPersistent();
  +        String initialValue = ps.getInitialValue();
  +        Location location = ps.getLocation();
  +
  +        addProperty(op, propertyName, specifiedType, persistent, initialValue, location);
  +    }
   
  -        Class propertyType = EnhanceUtils.extractPropertyType(op, propertyName, ps.getType());
  +    public void addProperty(EnhancementOperation op, String propertyName, String specifiedType,
boolean persistent, String initialValue, Location location)
  +    {
  +        Class propertyType = EnhanceUtils.extractPropertyType(op, propertyName, specifiedType);
   
           op.claimProperty(propertyName);
   
  @@ -92,14 +101,12 @@
   
           EnhanceUtils.createSimpleAccessor(op, field, propertyName, propertyType);
   
  -        addMutator(op, propertyName, propertyType, field, ps.isPersistent());
  -
  -        String initialValue = ps.getInitialValue();
  +        addMutator(op, propertyName, propertyType, field, persistent);
   
           if (initialValue == null)
               addReinitializer(op, propertyType, field);
           else
  -            addInitialValue(op, propertyName, propertyType, field, initialValue, ps.getLocation());
  +            addInitialValue(op, propertyName, propertyType, field, initialValue, location);
       }
   
       private void addReinitializer(EnhancementOperation op, Class propertyType, String fieldName)
  @@ -131,7 +138,10 @@
           InitialValueBindingCreator creator = new InitialValueBindingCreator(_bindingSource,
                   description, initialValue, location);
   
  -        String creatorField = op.addInjectedField(fieldName + "$initialValueBindingCreator",
InitialValueBindingCreator.class, creator);
  +        String creatorField = op.addInjectedField(
  +                fieldName + "$initialValueBindingCreator",
  +                InitialValueBindingCreator.class,
  +                creator);
   
           String bindingField = fieldName + "$initialValueBinding";
           op.addField(bindingField, IBinding.class);
  
  
  
  1.14      +33 -2     jakarta-tapestry/framework/src/java/org/apache/tapestry/enhance/ParameterPropertyWorker.java
  
  Index: ParameterPropertyWorker.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/enhance/ParameterPropertyWorker.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- ParameterPropertyWorker.java	2 May 2005 14:18:38 -0000	1.13
  +++ ParameterPropertyWorker.java	8 Jun 2005 19:58:43 -0000	1.14
  @@ -22,6 +22,7 @@
   import org.apache.hivemind.service.BodyBuilder;
   import org.apache.hivemind.service.ClassFabUtils;
   import org.apache.hivemind.service.MethodSignature;
  +import org.apache.hivemind.util.Defense;
   import org.apache.tapestry.IBinding;
   import org.apache.tapestry.IComponent;
   import org.apache.tapestry.spec.IComponentSpecification;
  @@ -67,8 +68,38 @@
               IParameterSpecification ps)
       {
           String propertyName = ps.getPropertyName();
  +        String specifiedType = ps.getType();
  +        boolean cache = ps.getCache();
   
  -        Class propertyType = EnhanceUtils.extractPropertyType(op, propertyName, ps.getType());
  +        addParameter(op, parameterName, propertyName, specifiedType, cache);
  +    }
  +
  +    /**
  +     * Adds a parameter as a (very smart) property.
  +     * 
  +     * @param op
  +     *            the enhancement operation
  +     * @param parameterName
  +     *            the name of the parameter (used to access the binding)
  +     * @param propertyName
  +     *            the name of the property to create (usually, but not always, matches
the
  +     *            parameterName)
  +     * @param specifiedType
  +     *            the type declared in the DTD (only 3.0 DTD supports this), may be null
(always
  +     *            null for 4.0 DTD)
  +     * @param cache
  +     *            if true, then the value should be cached while the component renders;
false (a
  +     *            much less common case) means that every access will work through binding
object.
  +     */
  +
  +    public void addParameter(EnhancementOperation op, String parameterName, String propertyName,
  +            String specifiedType, boolean cache)
  +    {
  +        Defense.notNull(op, "op");
  +        Defense.notNull(parameterName, "parameterName");
  +        Defense.notNull(propertyName, "propertyName");
  +
  +        Class propertyType = EnhanceUtils.extractPropertyType(op, propertyName, specifiedType);
   
           // 3.0 would allow connected parameter properties to be fully implemented
           // in the component class. This is not supported in 4.0 and an existing
  @@ -95,7 +126,7 @@
                   fieldName,
                   defaultFieldName,
                   cachedFieldName,
  -                ps.getCache());
  +                cache);
   
           buildMutator(
                   op,
  
  
  
  1.6       +25 -17    jakarta-tapestry/framework/src/java/org/apache/tapestry/enhance/InjectMessagesWorker.java
  
  Index: InjectMessagesWorker.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/enhance/InjectMessagesWorker.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- InjectMessagesWorker.java	7 Jun 2005 17:41:40 -0000	1.5
  +++ InjectMessagesWorker.java	8 Jun 2005 19:58:43 -0000	1.6
  @@ -20,6 +20,7 @@
   import org.apache.hivemind.Messages;
   import org.apache.hivemind.service.BodyBuilder;
   import org.apache.hivemind.service.MethodSignature;
  +import org.apache.hivemind.util.Defense;
   import org.apache.tapestry.services.ComponentMessagesSource;
   import org.apache.tapestry.spec.IComponentSpecification;
   
  @@ -45,23 +46,7 @@
       {
           try
           {
  -            op.claimProperty(MESSAGES_PROPERTY);
  -
  -            String sourceField = op.addInjectedField(
  -                    "_$componentMessagesSource",
  -                    ComponentMessagesSource.class,
  -                    _componentMessagesSource);
  -
  -            op.addField("_$messages", Messages.class);
  -
  -            BodyBuilder builder = new BodyBuilder();
  -            builder.begin();
  -            builder.addln("if (_$messages == null)");
  -            builder.addln("  _$messages = {0}.getMessages(this);", sourceField);
  -            builder.addln("return _$messages;");
  -            builder.end();
  -
  -            op.addMethod(Modifier.PUBLIC, METHOD_SIGNATURE, builder.toString());
  +            injectMessages(op);
           }
           catch (Exception ex)
           {
  @@ -70,6 +55,29 @@
           }
       }
   
  +    public void injectMessages(EnhancementOperation op)
  +    {
  +        Defense.notNull(op, "op");
  +
  +        op.claimProperty(MESSAGES_PROPERTY);
  +
  +        String sourceField = op.addInjectedField(
  +                "_$componentMessagesSource",
  +                ComponentMessagesSource.class,
  +                _componentMessagesSource);
  +
  +        op.addField("_$messages", Messages.class);
  +
  +        BodyBuilder builder = new BodyBuilder();
  +        builder.begin();
  +        builder.addln("if (_$messages == null)");
  +        builder.addln("  _$messages = {0}.getMessages(this);", sourceField);
  +        builder.addln("return _$messages;");
  +        builder.end();
  +
  +        op.addMethod(Modifier.PUBLIC, METHOD_SIGNATURE, builder.toString());
  +    }
  +
       public void setComponentMessagesSource(ComponentMessagesSource componentMessagesSource)
       {
           _componentMessagesSource = componentMessagesSource;
  
  
  
  1.5       +7 -0      jakarta-tapestry/framework/src/test/org/apache/tapestry/markup/TestMarkupWriter.java
  
  Index: TestMarkupWriter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/test/org/apache/tapestry/markup/TestMarkupWriter.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TestMarkupWriter.java	3 May 2005 17:41:26 -0000	1.4
  +++ TestMarkupWriter.java	8 Jun 2005 19:58:44 -0000	1.5
  @@ -440,6 +440,11 @@
           verifyControls();
       }
   
  +    /*
  +     * Seems to cause problems with JDK 1.5
  +     * 
  +     *
  +     *
       public void testFlush()
       {
           _writer = new CharArrayWriter();
  @@ -457,6 +462,8 @@
   
           verifyControls();
       }
  +    
  +    */
   
       public void testPrintCharArray()
       {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org


Mime
View raw message