You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2005/07/01 19:26:05 UTC

cvs commit: jakarta-tapestry/annotations/src/descriptor/META-INF hivemodule.xml

hlship      2005/07/01 10:26:05

  Modified:    .        status.xml
               examples/Workbench/src/java/org/apache/tapestry/workbench/components
                        Border.java
               annotations/src/java/org/apache/tapestry/annotations
                        AssetAnnotationWorker.java
               annotations/src/test/org/apache/tapestry/annotations
                        TestAssetAnnotationWorker.java
               examples/Workbench/src/context/WEB-INF Border.jwc
               annotations/src/descriptor/META-INF hivemodule.xml
  Log:
  TAPESTRY-361: Using @Asset annotation causes NullPointerException
  
  Revision  Changes    Path
  1.148     +1 -0      jakarta-tapestry/status.xml
  
  Index: status.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/status.xml,v
  retrieving revision 1.147
  retrieving revision 1.148
  diff -u -r1.147 -r1.148
  --- status.xml	1 Jul 2005 16:41:03 -0000	1.147
  +++ status.xml	1 Jul 2005 17:26:05 -0000	1.148
  @@ -55,6 +55,7 @@
       <release version="4.0-beta-2" date="unreleased">
         <action type="fix" dev="HLS" fixes-bug="TAPESTRY-356">FormConditional extends BaseComponent but has no template</action>
         <action type="fix" dev="HLS" fixes-bug="TAPESTRY-357">AbstractComponent: getMessages() and format() were removed, but should have been deprecated</action>
  +      <action type="fix" dev="HLS" fixes-bug="TAPESTRY-361">Using @Asset annotation causes NullPointerException</action>
       </release>
       <release version="4.0-beta-1" date="Jun 24 2005">
          <action type="add" dev="HLS">Add InvokeListener component.</action>
  
  
  
  1.8       +26 -9     jakarta-tapestry/examples/Workbench/src/java/org/apache/tapestry/workbench/components/Border.java
  
  Index: Border.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/examples/Workbench/src/java/org/apache/tapestry/workbench/components/Border.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Border.java	22 Jun 2005 12:47:21 -0000	1.7
  +++ Border.java	1 Jul 2005 17:26:05 -0000	1.8
  @@ -18,6 +18,8 @@
   import org.apache.tapestry.IAsset;
   import org.apache.tapestry.IRequestCycle;
   import org.apache.tapestry.TapestryUtils;
  +import org.apache.tapestry.annotations.Asset;
  +import org.apache.tapestry.annotations.InjectAsset;
   import org.apache.tapestry.annotations.InjectState;
   import org.apache.tapestry.annotations.Message;
   import org.apache.tapestry.event.PageBeginRenderListener;
  @@ -88,25 +90,40 @@
           return getMessages().getMessage(getPageName());
       }
   
  +    // Arbitrary mix of @Asset and @InjectAsset just to
  +    // test the annotations.
  +
  +    @Asset("images/tab-active-left.gif")
  +    public abstract IAsset getActiveLeft();
  +
  +    @InjectAsset("inactiveLeft")
  +    public abstract IAsset getInactiveLeft();
  +
  +    @Asset("images/tab-active-mid.gif")
  +    public abstract IAsset getActiveMid();
  +
  +    @InjectAsset("inactiveMid")
  +    public abstract IAsset getInactiveMid();
  +
  +    @Asset("images/tab-active-right.gif")
  +    public abstract IAsset getActiveRight();
  +
  +    @InjectAsset("inactiveRight")
  +    public abstract IAsset getInactiveRight();
  +
       public IAsset getLeftTabAsset()
       {
  -        String name = isActivePage() ? "activeLeft" : "inactiveLeft";
  -
  -        return getAsset(name);
  +        return isActivePage() ? getActiveLeft() : getInactiveLeft();
       }
   
       public IAsset getMidTabAsset()
       {
  -        String name = isActivePage() ? "activeMid" : "inactiveMid";
  -
  -        return getAsset(name);
  +        return isActivePage() ? getActiveMid() : getInactiveMid();
       }
   
       public IAsset getRightTabAsset()
       {
  -        String name = isActivePage() ? "activeRight" : "inactiveRight";
  -
  -        return getAsset(name);
  +        return isActivePage() ? getActiveRight() : getInactiveRight();
       }
   
       public void selectPage(IRequestCycle cycle, String newPageName)
  
  
  
  1.3       +6 -0      jakarta-tapestry/annotations/src/java/org/apache/tapestry/annotations/AssetAnnotationWorker.java
  
  Index: AssetAnnotationWorker.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/annotations/src/java/org/apache/tapestry/annotations/AssetAnnotationWorker.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AssetAnnotationWorker.java	15 Jun 2005 13:34:30 -0000	1.2
  +++ AssetAnnotationWorker.java	1 Jul 2005 17:26:05 -0000	1.3
  @@ -16,6 +16,7 @@
   
   import java.lang.reflect.Method;
   
  +import org.apache.hivemind.impl.LocationImpl;
   import org.apache.tapestry.enhance.EnhancementOperation;
   import org.apache.tapestry.spec.AssetSpecification;
   import org.apache.tapestry.spec.IAssetSpecification;
  @@ -42,6 +43,11 @@
           as.setPath(asset.value());
           as.setPropertyName(propertyName);
   
  +        // Very important for assets, as they need a location (really, the Resource
  +        // of a location) to figure out what kind of asset they are.
  +
  +        as.setLocation(new LocationImpl(spec.getSpecificationLocation()));
  +
           spec.addAsset(propertyName, as);
       }
   
  
  
  
  1.3       +6 -1      jakarta-tapestry/annotations/src/test/org/apache/tapestry/annotations/TestAssetAnnotationWorker.java
  
  Index: TestAssetAnnotationWorker.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/annotations/src/test/org/apache/tapestry/annotations/TestAssetAnnotationWorker.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestAssetAnnotationWorker.java	15 Jun 2005 13:34:31 -0000	1.2
  +++ TestAssetAnnotationWorker.java	1 Jul 2005 17:26:05 -0000	1.3
  @@ -16,6 +16,9 @@
   
   import java.lang.reflect.Method;
   
  +import org.apache.hivemind.Location;
  +import org.apache.hivemind.Resource;
  +import org.apache.hivemind.impl.LocationImpl;
   import org.apache.tapestry.enhance.EnhancementOperation;
   import org.apache.tapestry.spec.ComponentSpecification;
   import org.apache.tapestry.spec.IAssetSpecification;
  @@ -32,8 +35,10 @@
   {
       public void testSuccess()
       {
  +        Resource r = (Resource) newMock(Resource.class);
           EnhancementOperation op = newOp();
           IComponentSpecification spec = new ComponentSpecification();
  +        spec.setSpecificationLocation(r);
   
           replayControls();
   
  @@ -45,7 +50,7 @@
   
           IAssetSpecification as = spec.getAsset("globalStylesheet");
           assertEquals("/style/global.css", as.getPath());
  -        assertNull(as.getLocation());
  +        assertEquals(new LocationImpl(r), as.getLocation());
           assertEquals("globalStylesheet", as.getPropertyName());
       }
   }
  
  
  
  1.8       +0 -4      jakarta-tapestry/examples/Workbench/src/context/WEB-INF/Border.jwc
  
  Index: Border.jwc
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/examples/Workbench/src/context/WEB-INF/Border.jwc,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Border.jwc	18 Apr 2005 17:09:03 -0000	1.7
  +++ Border.jwc	1 Jul 2005 17:26:05 -0000	1.8
  @@ -49,10 +49,6 @@
       </binding>
     </component>
   
  -  <asset name="activeLeft" path="images/tab-active-left.gif"/>
  -  <asset name="activeMid" path="images/tab-active-mid.gif"/>
  -  <asset name="activeRight" path="images/tab-active-right.gif"/>
  -
     <asset name="inactiveLeft" path="images/tab-inactive-left.gif"/>
     <asset name="inactiveMid" path="images/tab-inactive-mid.gif"/>
     <asset name="inactiveRight" path="images/tab-inactive-right.gif"/>
  
  
  
  1.11      +1 -1      jakarta-tapestry/annotations/src/descriptor/META-INF/hivemodule.xml
  
  Index: hivemodule.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/annotations/src/descriptor/META-INF/hivemodule.xml,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- hivemodule.xml	22 Jun 2005 13:58:46 -0000	1.10
  +++ hivemodule.xml	1 Jul 2005 17:26:05 -0000	1.11
  @@ -101,7 +101,6 @@
       <worker annotation="InjectObject" object="service:InjectObjectAnnotationWorker"/>
       <worker annotation="InjectComponent" object="instance:InjectComponentAnnotationWorker"/>
       <worker annotation="InjectState" object="service:InjectStateAnnotationWorker"/>
  -    <worker annotation="InjectAsset" object="instance:InjectAssetAnnotationWorker"/>
       <worker annotation="Message" object="instance:MessageAnnotationWorker"/>
       
       <!-- These update the component specification with new sub-elements. Later, the 
  @@ -109,6 +108,7 @@
            specified in the XML. This is actually a lot easier and just as powerful, and
            the delegating style will probably go pretty soon.  -->
            
  +    <worker annotation="InjectAsset" object="instance:InjectAssetAnnotationWorker"/>
       <worker annotation="Persist" object="instance:PersistAnnotationWorker"/>
       <worker annotation="Bean" object="instance:BeanAnnotationWorker"/>
       <worker annotation="Asset" object="instance:AssetAnnotationWorker"/>
  
  
  

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