You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2007/10/11 17:44:58 UTC

svn commit: r583859 - in /tapestry/tapestry5/trunk/tapestry-core/src: main/java/org/apache/tapestry/ main/java/org/apache/tapestry/annotations/ main/java/org/apache/tapestry/corelib/mixins/ main/java/org/apache/tapestry/internal/ main/java/org/apache/t...

Author: hlship
Date: Thu Oct 11 08:44:52 2007
New Revision: 583859

URL: http://svn.apache.org/viewvc?rev=583859&view=rev
Log:
TAPESTRY-1815: The InjectComponent annotation is misnamed, should be InjectContainer

Added:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/annotations/InjectContainer.java
      - copied, changed from r583831, tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/annotations/InjectComponent.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InjectContainerWorker.java
      - copied, changed from r583831, tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InjectComponentWorker.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/InjectContainerMismatch.java
      - copied, changed from r583831, tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/InjectComponentMismatch.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry/integration/app1/pages/InjectContainerMismatch.tml
      - copied unchanged from r583831, tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry/integration/app1/pages/InjectComponentMismatch.tml
Removed:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/annotations/InjectComponent.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InjectComponentWorker.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/InjectComponentMismatch.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry/integration/app1/pages/InjectComponentMismatch.tml
Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/ComponentResources.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/mixins/RenderDisabled.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/InternalComponentResources.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/structure/InternalComponentResourcesImpl.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/app1/Start.tml
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/ComponentResources.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/ComponentResources.java?rev=583859&r1=583858&r2=583859&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/ComponentResources.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/ComponentResources.java Thu Oct 11 08:44:52 2007
@@ -45,6 +45,7 @@
 
     /**
      * Returns the component which contains this component, or null for the root component.
+     * For mixins, this returns the componet to which the mixin is attached.
      */
     Component getContainer();
 

Copied: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/annotations/InjectContainer.java (from r583831, tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/annotations/InjectComponent.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/annotations/InjectContainer.java?p2=tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/annotations/InjectContainer.java&p1=tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/annotations/InjectComponent.java&r1=583831&r2=583859&rev=583859&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/annotations/InjectComponent.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/annotations/InjectContainer.java Thu Oct 11 08:44:52 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -22,11 +22,13 @@
 import java.lang.annotation.Target;
 
 /**
- * Used exclusively inside a mixin to connect the mixin to the component to which it is attached.
+ * Used in inject the container of a component as a field of the component. The container of a mixin
+ * is the component to which the mixin is attached.
  */
 @Target(FIELD)
 @Documented
 @Retention(RUNTIME)
-public @interface InjectComponent {
+public @interface InjectContainer
+{
 
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/mixins/RenderDisabled.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/mixins/RenderDisabled.java?rev=583859&r1=583858&r2=583859&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/mixins/RenderDisabled.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/mixins/RenderDisabled.java Thu Oct 11 08:44:52 2007
@@ -16,7 +16,7 @@
 
 import org.apache.tapestry.Field;
 import org.apache.tapestry.MarkupWriter;
-import org.apache.tapestry.annotations.InjectComponent;
+import org.apache.tapestry.annotations.InjectContainer;
 import org.apache.tapestry.annotations.MixinAfter;
 
 /**
@@ -25,7 +25,7 @@
 @MixinAfter
 public class RenderDisabled
 {
-    @InjectComponent
+    @InjectContainer
     private Field _field;
 
     void beginRender(MarkupWriter writer)

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/InternalComponentResources.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/InternalComponentResources.java?rev=583859&r1=583858&r2=583859&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/InternalComponentResources.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/InternalComponentResources.java Thu Oct 11 08:44:52 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -16,7 +16,6 @@
 
 import org.apache.tapestry.ComponentResources;
 import org.apache.tapestry.internal.structure.Page;
-import org.apache.tapestry.runtime.Component;
 import org.apache.tapestry.services.PersistentFieldManager;
 
 /**
@@ -54,7 +53,7 @@
     /**
      * Returns true if the named parameter's {@link org.apache.tapestry.Binding} is invariant, false
      * if otherwise, or if the parameter is not bound. Invariant bindings are cached more
-     * aggresively than variant bindings.
+     * aggressively than variant bindings.
      * 
      * @param parameterName
      *            the name of parameter to check for invariance
@@ -63,14 +62,8 @@
     boolean isInvariant(String parameterName);
 
     /**
-     * For a normal component, the same as {@link #getComponent()}, but for a mixin, returns the
-     * component to which the mixin is attached.
-     */
-    Component getCoreComponent();
-
-    /**
      * Posts a change to a persistent field. If the component is still loading, then this change is
-     * ignored. Otherwise, it is propogated, via the
+     * ignored. Otherwise, it is propagated, via the
      * {@link Page#persistFieldChange(org.apache.tapestry.internal.structure.ComponentPageElement, String, Object) page}
      * to the {@link PersistentFieldManager}.
      */

Copied: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InjectContainerWorker.java (from r583831, tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InjectComponentWorker.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InjectContainerWorker.java?p2=tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InjectContainerWorker.java&p1=tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InjectComponentWorker.java&r1=583831&r2=583859&rev=583859&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InjectComponentWorker.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InjectContainerWorker.java Thu Oct 11 08:44:52 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
 
 import java.util.List;
 
-import org.apache.tapestry.annotations.InjectComponent;
+import org.apache.tapestry.annotations.InjectContainer;
 import org.apache.tapestry.ioc.util.BodyBuilder;
 import org.apache.tapestry.model.MutableComponentModel;
 import org.apache.tapestry.runtime.Component;
@@ -25,15 +25,15 @@
 import org.apache.tapestry.services.TransformConstants;
 
 /**
- * Identifies the {@link InjectComponent} annotation and adds code to initialize it to the core
+ * Identifies the {@link InjectContainer} annotation and adds code to initialize it to the core
  * component.
  */
-public class InjectComponentWorker implements ComponentClassTransformWorker
+public class InjectContainerWorker implements ComponentClassTransformWorker
 {
 
     public void transform(ClassTransformation transformation, MutableComponentModel model)
     {
-        List<String> names = transformation.findFieldsWithAnnotation(InjectComponent.class);
+        List<String> names = transformation.findFieldsWithAnnotation(InjectContainer.class);
 
         if (names.isEmpty())
             return;
@@ -44,26 +44,26 @@
         BodyBuilder builder = new BodyBuilder();
         builder.begin();
 
-        builder.addln("%s core = %s.getCoreComponent();", Component.class.getName(), transformation
+        builder.addln("%s container = %s.getContainer();", Component.class.getName(), transformation
                 .getResourcesFieldName());
 
         for (String fieldName : names)
         {
-            InjectComponent annotation = transformation.getFieldAnnotation(
+            InjectContainer annotation = transformation.getFieldAnnotation(
                     fieldName,
-                    InjectComponent.class);
+                    InjectContainer.class);
 
             String fieldType = transformation.getFieldType(fieldName);
 
             builder.addln("try");
             builder.begin();
-            builder.addln("%s = (%s) core;", fieldName, fieldType);
+            builder.addln("%s = (%s) container;", fieldName, fieldType);
             builder.end();
             builder.addln("catch (ClassCastException ex)");
             builder.begin();
             builder.addln(
-                    "String message = %s.buildCastExceptionMessage(core, \"%s.%s\", \"%s\");",
-                    InjectComponentWorker.class.getName(),
+                    "String message = %s.buildCastExceptionMessage(container, \"%s.%s\", \"%s\");",
+                    InjectContainerWorker.class.getName(),
                     model.getComponentClassName(),
                     fieldName,
                     fieldType);

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/structure/InternalComponentResourcesImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/structure/InternalComponentResourcesImpl.java?rev=583859&r1=583858&r2=583859&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/structure/InternalComponentResourcesImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/structure/InternalComponentResourcesImpl.java Thu Oct 11 08:44:52 2007
@@ -292,9 +292,9 @@
 
     public Component getContainer()
     {
-        ComponentPageElement containerElement = _element.getContainerElement();
+        if (_containerResources == null) return null;
 
-        return containerElement == null ? null : containerElement.getComponent();
+        return _containerResources.getComponent();
     }
 
     public ComponentResources getContainerResources()
@@ -318,11 +318,6 @@
             _messages = _messagesSource.getMessages(_componentModel, getLocale());
 
         return _messages;
-    }
-
-    public Component getCoreComponent()
-    {
-        return _element.getComponent();
     }
 
     public String getElementName()

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java?rev=583859&r1=583858&r2=583859&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java Thu Oct 11 08:44:52 2007
@@ -111,7 +111,7 @@
 import org.apache.tapestry.internal.services.FlashPersistentFieldStrategy;
 import org.apache.tapestry.internal.services.GenericValueEncoderFactory;
 import org.apache.tapestry.internal.services.HeartbeatImpl;
-import org.apache.tapestry.internal.services.InjectComponentWorker;
+import org.apache.tapestry.internal.services.InjectContainerWorker;
 import org.apache.tapestry.internal.services.InjectPageWorker;
 import org.apache.tapestry.internal.services.InjectStandardStylesheetCommand;
 import org.apache.tapestry.internal.services.InjectWorker;
@@ -421,7 +421,7 @@
         configuration.add("OnEvent", new OnEventWorker());
         configuration.add("SupportsInformalParameters", new SupportsInformalParametersWorker());
         configuration.add("InjectPage", new InjectPageWorker(requestPageCache, resolver));
-        configuration.add("InjectComponent", new InjectComponentWorker());
+        configuration.add("InjectComponent", new InjectContainerWorker());
         configuration.add("RenderCommand", new RenderCommandWorker());
 
         // Default values for parameters are often some form of injection, so make sure

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/app1/Start.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/Start.tml?rev=583859&r1=583858&r2=583859&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/Start.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/Start.tml Thu Oct 11 08:44:52 2007
@@ -70,10 +70,10 @@
             -- components can inherit templates from base classes
           </li>
           <li>
-            <a href="InjectComponentMismatch">
-              InjectComponentMismatch
+            <a href="InjectContainerMismatch">
+              InjectContainerMismatch
             </a>
-            -- check error reporting when @InjectComponent doesn't match
+            -- check error reporting when @InjectContainer doesn't match
             the actual field type
           </li>
 

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java?rev=583859&r1=583858&r2=583859&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java Thu Oct 11 08:44:52 2007
@@ -20,7 +20,7 @@
 import java.net.URL;
 
 import org.apache.tapestry.corelib.mixins.RenderDisabled;
-import org.apache.tapestry.internal.services.InjectComponentWorker;
+import org.apache.tapestry.internal.services.InjectContainerWorker;
 import org.apache.tapestry.ioc.Resource;
 import org.apache.tapestry.ioc.internal.util.ClasspathResource;
 import org.apache.tapestry.test.AbstractIntegrationTestSuite;
@@ -157,18 +157,18 @@
     }
 
     /**
-     * {@link InjectComponentWorker} is largely tested by the forms tests ({@link RenderDisabled}
+     * {@link InjectContainerWorker} is largely tested by the forms tests ({@link RenderDisabled}
      * is built on it). test is for the failure case, where a mixin class is used with the wrong
      * type of component.
      */
     @Test
-    public void inject_component_failure() throws Exception
+    public void inject_container_failure() throws Exception
     {
-        start("InjectComponentMismatch");
+        start("InjectContainerMismatch");
 
         // And exception message:
 
-        assertTextPresent("Component InjectComponentMismatch is not assignable to field org.apache.tapestry.corelib.mixins.RenderDisabled._field (of type org.apache.tapestry.Field).");
+        assertTextPresent("Component InjectContainerMismatch is not assignable to field org.apache.tapestry.corelib.mixins.RenderDisabled._field (of type org.apache.tapestry.Field).");
     }
 
     @Test

Copied: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/InjectContainerMismatch.java (from r583831, tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/InjectComponentMismatch.java)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/InjectContainerMismatch.java?p2=tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/InjectContainerMismatch.java&p1=tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/InjectComponentMismatch.java&r1=583831&r2=583859&rev=583859&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/InjectComponentMismatch.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/InjectContainerMismatch.java Thu Oct 11 08:44:52 2007
@@ -18,7 +18,7 @@
 import org.apache.tapestry.annotations.Mixin;
 import org.apache.tapestry.corelib.mixins.RenderDisabled;
 
-public class InjectComponentMismatch
+public class InjectContainerMismatch
 {
     /**
      * This mixin only works with components of type {@link Field}. That's the mismatch right