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 2011/10/18 00:31:19 UTC
svn commit: r1185405 - in /tapestry/tapestry5/trunk:
tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/
tapestry-core/src/main/java/org/apache/tapestry5/internal/services/
tapestry-core/src/main/java/org/apache/tapestry5/services/ tap...
Author: hlship
Date: Mon Oct 17 22:31:19 2011
New Revision: 1185405
URL: http://svn.apache.org/viewvc?rev=1185405&view=rev
Log:
TAP5-892: Use of Injection to provide Locale instances to components breaks when multiple Locales are configured as Spring Beans in AppContext
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/CommonResourcesInjectionProvider.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DefaultInjectionProvider.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
tapestry/tapestry5/trunk/tapestry-core/src/test/app1/BadMixinIdDemo.tml
tapestry/tapestry5/trunk/tapestry-core/src/test/app1/DupeMixinDemo.tml
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/CoreBehaviorsTests.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/components/Publish3.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/DupeMixinDemo.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ComponentEventDispatcherTest.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ComponentEventLinkEncoderImplTest.java
tapestry/tapestry5/trunk/tapestry-spring/src/test/java/org/apache/tapestry5/spring/TapestrySpringIntegrationTest.java
tapestry/tapestry5/trunk/tapestry-spring/src/test/java/org/example/testapp/pages/Start.java
tapestry/tapestry5/trunk/tapestry-spring/src/test/webapp/Start.tml
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java?rev=1185405&r1=1185404&r2=1185405&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java Mon Oct 17 22:31:19 2011
@@ -20,7 +20,6 @@ import org.apache.tapestry5.corelib.Clie
import org.apache.tapestry5.corelib.internal.ComponentActionSink;
import org.apache.tapestry5.corelib.internal.FormSupportImpl;
import org.apache.tapestry5.corelib.internal.InternalFormSupport;
-import org.apache.tapestry5.corelib.mixins.RenderInformals;
import org.apache.tapestry5.dom.Element;
import org.apache.tapestry5.internal.*;
import org.apache.tapestry5.internal.services.HeartbeatImpl;
@@ -232,9 +231,6 @@ public class Form implements ClientEleme
private ComponentActionSink actionSink;
- @Mixin
- private RenderInformals renderInformals;
-
@Environmental
private ClientBehaviorSupport clientBehaviorSupport;
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/CommonResourcesInjectionProvider.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/CommonResourcesInjectionProvider.java?rev=1185405&r1=1185404&r2=1185405&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/CommonResourcesInjectionProvider.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/CommonResourcesInjectionProvider.java Mon Oct 17 22:31:19 2011
@@ -92,13 +92,6 @@ public class CommonResourcesInjectionPro
}
};
- private static ResourceProvider<String> completeIdProvider = new ResourceProvider<String>()
- {
- public String get(ComponentResources resources)
- {
- return resources.getCompleteId();
- }
- };
private static ResourceProvider<ComponentResources> resourcesProvider = new ResourceProvider<ComponentResources>()
{
@@ -116,7 +109,6 @@ public class CommonResourcesInjectionPro
add(Messages.class, messagesProvider);
add(Locale.class, localeProvider);
add(Logger.class, loggerProvider);
- add(String.class, completeIdProvider);
}
private static void add(Class type, ResourceProvider provider)
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DefaultInjectionProvider.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DefaultInjectionProvider.java?rev=1185405&r1=1185404&r2=1185405&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DefaultInjectionProvider.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DefaultInjectionProvider.java Mon Oct 17 22:31:19 2011
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007, 2010 The Apache Software Foundation
+// Copyright 2006, 2007, 2010, 2011 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.
@@ -15,7 +15,6 @@
package org.apache.tapestry5.internal.services;
import org.apache.tapestry5.ioc.AnnotationProvider;
-import org.apache.tapestry5.ioc.Messages;
import org.apache.tapestry5.ioc.ObjectLocator;
import org.apache.tapestry5.ioc.services.MasterObjectProvider;
import org.apache.tapestry5.model.MutableComponentModel;
@@ -40,8 +39,6 @@ public class DefaultInjectionProvider im
private final ComponentClassCache classCache;
- private final static String MESSAGES_TYPE = Messages.class.getName();
-
public DefaultInjectionProvider(MasterObjectProvider masterObjectProvider, ObjectLocator locator, ComponentClassCache classCache)
{
this.masterObjectProvider = masterObjectProvider;
@@ -51,17 +48,6 @@ public class DefaultInjectionProvider im
public boolean provideInjection(final PlasticField field, ObjectLocator locator, MutableComponentModel componentModel)
{
- // I hate special cases, but we have a conflict between the ObjectProvider contributed so as to inject
- // the global application messages into services, and the injection of per-component Messages into components.
- // For yet other reasons, this InjectionProvider gets invoked before CommonResources, and will attempt
- // to inject the wrong Messages (the global application messages, not the component messages) ... so we
- // make a special check here.
-
- if (field.getTypeName().equals(MESSAGES_TYPE))
- {
- return false;
- }
-
Class fieldType = classCache.forName(field.getTypeName());
Object injectionValue = masterObjectProvider.provide(fieldType, new AnnotationProvider()
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java?rev=1185405&r1=1185404&r2=1185405&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java Mon Oct 17 22:31:19 2011
@@ -778,9 +778,10 @@ public final class TapestryModule
configuration.add("Block", new BlockInjectionProvider());
configuration.add("Asset", new AssetInjectionProvider(symbolSource, assetSource));
+ configuration.add("CommonResources", new CommonResourcesInjectionProvider());
+
configuration.addInstance("Default", DefaultInjectionProvider.class);
- configuration.add("CommonResources", new CommonResourcesInjectionProvider());
// This needs to be the last one, since it matches against services
// and might blow up if there is no match.
configuration.addInstance("Service", ServiceInjectionProvider.class, "after:*");
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/app1/BadMixinIdDemo.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/BadMixinIdDemo.tml?rev=1185405&r1=1185404&r2=1185405&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/BadMixinIdDemo.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/BadMixinIdDemo.tml Mon Oct 17 22:31:19 2011
@@ -1,6 +1,9 @@
<t:border xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd"
xmlns:p="tapestry:parameter">
- <t:form unknownmixinid.foo="bar"/>
+ <t:form>
+ <t:textfield t:id="value" unknownmixinid.foo="bar"/>
+ </t:form>
-</t:border>
\ No newline at end of file
+</t:border>
+ </t:border>
\ No newline at end of file
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/app1/DupeMixinDemo.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/DupeMixinDemo.tml?rev=1185405&r1=1185404&r2=1185405&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/DupeMixinDemo.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/DupeMixinDemo.tml Mon Oct 17 22:31:19 2011
@@ -1,6 +1,8 @@
<t:border xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd"
xmlns:p="tapestry:parameter">
- <t:form t:mixins="renderInformals"/>
+ <t:form>
+ <t:textfield t:id="value" t:mixins="discardbody"/>
+ </t:form>
</t:border>
\ No newline at end of file
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/CoreBehaviorsTests.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/CoreBehaviorsTests.java?rev=1185405&r1=1185404&r2=1185405&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/CoreBehaviorsTests.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/CoreBehaviorsTests.java Mon Oct 17 22:31:19 2011
@@ -1169,7 +1169,7 @@ public class CoreBehaviorsTests extends
{
openLinks("Bad Mixin Id Demo");
- assertTextPresent("Mixin id for parameter 'unknownmixinid.foo' not found. Attached mixins: RenderInformals.");
+ assertTextPresent("Mixin id for parameter 'unknownmixinid.foo' not found. Attached mixins: DiscardBody, RenderDisabled.");
}
@Test
@@ -1177,9 +1177,9 @@ public class CoreBehaviorsTests extends
{
openLinks("Duplicate Mixin Demo");
- assertTextPresent("Failure creating embedded component 'form' of "
+ assertTextPresent("Failure creating embedded component 'value' of "
+ "org.apache.tapestry5.integration.app1.pages.DupeMixinDemo: "
- + "Mixins applied to a component must be unique. Mixin 'RenderInformals' has already been applied.");
+ + "Mixins applied to a component must be unique. Mixin 'DiscardBody' has already been applied.");
}
@Test
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/components/Publish3.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/components/Publish3.java?rev=1185405&r1=1185404&r2=1185405&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/components/Publish3.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/components/Publish3.java Mon Oct 17 22:31:19 2011
@@ -15,6 +15,7 @@
package org.apache.tapestry5.integration.app1.components;
import org.apache.tapestry5.BindingConstants;
+import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.ioc.annotations.Inject;
@@ -29,7 +30,11 @@ public class Publish3
@Parameter(defaultPrefix = BindingConstants.LITERAL)
private String value;
- @Property
@Inject
- private String id;
+ private ComponentResources resources;
+
+ public String getId()
+ {
+ return resources.getCompleteId();
+ }
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/DupeMixinDemo.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/DupeMixinDemo.java?rev=1185405&r1=1185404&r2=1185405&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/DupeMixinDemo.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/DupeMixinDemo.java Mon Oct 17 22:31:19 2011
@@ -1,4 +1,4 @@
-// Copyright 2009 The Apache Software Foundation
+// Copyright 2009, 2011 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.
@@ -14,6 +14,10 @@
package org.apache.tapestry5.integration.app1.pages;
+import org.apache.tapestry5.annotations.Property;
+
public class DupeMixinDemo
{
+ @Property
+ private String value;
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ComponentEventDispatcherTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ComponentEventDispatcherTest.java?rev=1185405&r1=1185404&r2=1185405&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ComponentEventDispatcherTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ComponentEventDispatcherTest.java Mon Oct 17 22:31:19 2011
@@ -26,6 +26,7 @@ import org.testng.annotations.BeforeClas
import org.testng.annotations.Test;
import java.io.IOException;
+import java.util.Locale;
public class ComponentEventDispatcherTest extends InternalBaseTestCase
{
@@ -157,6 +158,8 @@ public class ComponentEventDispatcherTes
train_getParameter(request, InternalConstants.CONTAINER_PAGE_NAME, null);
+ train_for_request_locale(request, ls);
+
handler.handleComponentEvent(expectedParameters);
replay();
@@ -198,6 +201,8 @@ public class ComponentEventDispatcherTes
train_canonicalizePageName(resolver, "mypage", "mypage");
+ train_for_request_locale(request, ls);
+
handler.handleComponentEvent(expectedParameters);
replay();
@@ -263,6 +268,8 @@ public class ComponentEventDispatcherTes
handler.handleComponentEvent(expectedParameters);
+ train_for_request_locale(request, localizationSetter);
+
replay();
Dispatcher dispatcher = new ComponentEventDispatcher(handler,
@@ -274,6 +281,12 @@ public class ComponentEventDispatcherTes
verify();
}
+ private void train_for_request_locale(Request request, LocalizationSetter localizationSetter)
+ {
+ train_getLocale(request, Locale.CANADA_FRENCH);
+ localizationSetter.setNonPeristentLocaleFromLocaleName("fr_CA");
+ }
+
@Test
public void request_for_whitelist_only_page_from_valid_client() throws IOException
{
@@ -306,6 +319,8 @@ public class ComponentEventDispatcherTes
train_getParameter(request, InternalConstants.CONTAINER_PAGE_NAME, null);
+ train_for_request_locale(request, localizationSetter);
+
handler.handleComponentEvent(expectedParameters);
replay();
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ComponentEventLinkEncoderImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ComponentEventLinkEncoderImplTest.java?rev=1185405&r1=1185404&r2=1185405&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ComponentEventLinkEncoderImplTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ComponentEventLinkEncoderImplTest.java Mon Oct 17 22:31:19 2011
@@ -25,6 +25,8 @@ import org.apache.tapestry5.services.sec
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import java.util.Locale;
+
/**
* Most of the testing is implemented through legacy tests against code that uses CELE.
*
@@ -232,6 +234,9 @@ public class ComponentEventLinkEncoderIm
train_canonicalizePageName(resolver, "", "index");
+ train_getLocale(request, Locale.ITALIAN);
+ ls.setNonPeristentLocaleFromLocaleName("it");
+
replay();
ComponentEventLinkEncoderImpl linkEncoder = new ComponentEventLinkEncoderImpl(resolver, contextPathEncoder, ls,
Modified: tapestry/tapestry5/trunk/tapestry-spring/src/test/java/org/apache/tapestry5/spring/TapestrySpringIntegrationTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-spring/src/test/java/org/apache/tapestry5/spring/TapestrySpringIntegrationTest.java?rev=1185405&r1=1185404&r2=1185405&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-spring/src/test/java/org/apache/tapestry5/spring/TapestrySpringIntegrationTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-spring/src/test/java/org/apache/tapestry5/spring/TapestrySpringIntegrationTest.java Mon Oct 17 22:31:19 2011
@@ -1,4 +1,4 @@
-// Copyright 2007, 2008, 2009 The Apache Software Foundation
+// Copyright 2007, 2008, 2009, 2011 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.
@@ -68,7 +68,7 @@ public class TapestrySpringIntegrationTe
assertEquals(getText("viaFactory"), "Instantiated via a factory bean.");
}
-
+
@Test
public void symbol_bean_factory_post_processor() throws Exception
{
@@ -76,4 +76,13 @@ public class TapestrySpringIntegrationTe
assertEquals(getText("symbolValueHolder"), "Start page is 'start', Value from Spring is 'Hello'");
}
+
+ @Test
+ public void no_conflict_on_injected_locale() throws Exception
+ {
+ open(BASE_URL);
+
+ assertEquals(getText("locale"), "en");
+ assertEquals(getText("selector"), "en");
+ }
}
Modified: tapestry/tapestry5/trunk/tapestry-spring/src/test/java/org/example/testapp/pages/Start.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-spring/src/test/java/org/example/testapp/pages/Start.java?rev=1185405&r1=1185404&r2=1185405&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-spring/src/test/java/org/example/testapp/pages/Start.java (original)
+++ tapestry/tapestry5/trunk/tapestry-spring/src/test/java/org/example/testapp/pages/Start.java Mon Oct 17 22:31:19 2011
@@ -1,4 +1,4 @@
-// Copyright 2007 The Apache Software Foundation
+// Copyright 2007, 2011 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.
@@ -18,6 +18,7 @@ import org.apache.tapestry5.annotations.
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.ioc.internal.util.InternalUtils;
+import org.apache.tapestry5.services.pageload.ComponentResourceSelector;
import org.example.testapp.services.SpringStatusProvider;
import org.example.testapp.services.SymbolValueHolder;
import org.example.testapp.services.Upcase;
@@ -55,6 +56,10 @@ public class Start
@Inject
private Locale locale;
+ @Property
+ @Inject
+ private ComponentResourceSelector selector;
+
void onSuccess()
{
input = upcaseBean.toUpperCase(input);
Modified: tapestry/tapestry5/trunk/tapestry-spring/src/test/webapp/Start.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-spring/src/test/webapp/Start.tml?rev=1185405&r1=1185404&r2=1185405&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-spring/src/test/webapp/Start.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-spring/src/test/webapp/Start.tml Mon Oct 17 22:31:19 2011
@@ -27,6 +27,8 @@
</dd>
<dt>Page Locale:</dt>
<dd id="locale">${locale}</dd>
+ <dt>Page selector:</dt>
+ <dd id="selector">${selector.toShortString()}</dd>
</dl>
</body>