Author: drobiazko Date: Thu Dec 15 10:29:34 2011 New Revision: 1214690 URL: http://svn.apache.org/viewvc?rev=1214690&view=rev Log: TAP5-1788: Avoid collision with Service id 'environment' that has already been defined in Spring 3.1 (5.3-branch backport)
Added: tapestry/tapestry5/branches/5.3/tapestry-spring/src/test/java/org/apache/tapestry5/spring/TapestryExternalSpringContextIntegrationTest.java tapestry/tapestry5/branches/5.3/tapestry-spring/src/test/java/org/example/testapp1/ tapestry/tapestry5/branches/5.3/tapestry-spring/src/test/java/org/example/testapp1/pages/ tapestry/tapestry5/branches/5.3/tapestry-spring/src/test/java/org/example/testapp1/pages/Index.java tapestry/tapestry5/branches/5.3/tapestry-spring/src/test/java/org/example/testapp1/services/ tapestry/tapestry5/branches/5.3/tapestry-spring/src/test/java/org/example/testapp1/services/AppModule.java tapestry/tapestry5/branches/5.3/tapestry-spring/src/test/webapp1/ tapestry/tapestry5/branches/5.3/tapestry-spring/src/test/webapp1/Index.tml tapestry/tapestry5/branches/5.3/tapestry-spring/src/test/webapp1/WEB-INF/ tapestry/tapestry5/branches/5.3/tapestry-spring/src/test/webapp1/WEB-INF/applicationContext.xml tapestry/tapestry5/branches/5.3/tapestry-spring/src/test/webapp1/WEB-INF/web.xml Modified: tapestry/tapestry5/branches/5.3/tapestry-spring/src/main/java/org/apache/tapestry5/internal/spring/SpringModuleDef.java tapestry/tapestry5/branches/5.3/tapestry-spring/src/test/java/org/apache/tapestry5/internal/spring/SpringModuleDefTest.java Modified: tapestry/tapestry5/branches/5.3/tapestry-spring/src/main/java/org/apache/tapestry5/internal/spring/SpringModuleDef.java URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.3/tapestry-spring/src/main/java/org/apache/tapestry5/internal/spring/SpringModuleDef.java?rev=1214690&r1=1214689&r2=1214690&view=diff ============================================================================== --- tapestry/tapestry5/branches/5.3/tapestry-spring/src/main/java/org/apache/tapestry5/internal/spring/SpringModuleDef.java (original) +++ tapestry/tapestry5/branches/5.3/tapestry-spring/src/main/java/org/apache/tapestry5/internal/spring/SpringModuleDef.java Thu Dec 15 10:29:34 2011 @@ -153,7 +153,7 @@ public class SpringModuleDef implements private void addServiceDefsForSpringBeans(ApplicationContext context) { - for (final String beanName : BeanFactoryUtils.beanNamesIncludingAncestors(context)) + for (final String beanName : context.getBeanDefinitionNames()) { String trueName = beanName.startsWith("&") ? beanName.substring(1) : beanName; Modified: tapestry/tapestry5/branches/5.3/tapestry-spring/src/test/java/org/apache/tapestry5/internal/spring/SpringModuleDefTest.java URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.3/tapestry-spring/src/test/java/org/apache/tapestry5/internal/spring/SpringModuleDefTest.java?rev=1214690&r1=1214689&r2=1214690&view=diff ============================================================================== --- tapestry/tapestry5/branches/5.3/tapestry-spring/src/test/java/org/apache/tapestry5/internal/spring/SpringModuleDefTest.java (original) +++ tapestry/tapestry5/branches/5.3/tapestry-spring/src/test/java/org/apache/tapestry5/internal/spring/SpringModuleDefTest.java Thu Dec 15 10:29:34 2011 @@ -41,11 +41,7 @@ public class SpringModuleDefTest extends train_getInitParameter(servletContext, SpringConstants.USE_EXTERNAL_SPRING_CONTEXT, "true"); train_getAttribute(servletContext, WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ac); - - // Simulate barney as a factory bean. - - expect(ac.getBeanNamesForType(Object.class)).andReturn(new String[] {"fred", "&barney"}); - expect(ac.getParentBeanFactory()).andReturn(null); + expect(ac.getBeanDefinitionNames()).andReturn(new String[] {"fred", "&barney"}); replay(); Added: tapestry/tapestry5/branches/5.3/tapestry-spring/src/test/java/org/apache/tapestry5/spring/TapestryExternalSpringContextIntegrationTest.java URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.3/tapestry-spring/src/test/java/org/apache/tapestry5/spring/TapestryExternalSpringContextIntegrationTest.java?rev=1214690&view=auto ============================================================================== --- tapestry/tapestry5/branches/5.3/tapestry-spring/src/test/java/org/apache/tapestry5/spring/TapestryExternalSpringContextIntegrationTest.java (added) +++ tapestry/tapestry5/branches/5.3/tapestry-spring/src/test/java/org/apache/tapestry5/spring/TapestryExternalSpringContextIntegrationTest.java Thu Dec 15 10:29:34 2011 @@ -0,0 +1,34 @@ +// Copyright 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. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package org.apache.tapestry5.spring; + +import org.apache.tapestry5.test.AbstractIntegrationTestSuite; +import org.testng.annotations.Test; + +public class TapestryExternalSpringContextIntegrationTest extends AbstractIntegrationTestSuite +{ + public TapestryExternalSpringContextIntegrationTest() + { + super("src/test/webapp1"); + } + + @Test + public void external_context_integration_test() throws Exception + { + open(BASE_URL); + + assertTextPresent("Demonstrates Spring Context Configured Externally", "Instantiated via a factory bean."); + } +} Added: tapestry/tapestry5/branches/5.3/tapestry-spring/src/test/java/org/example/testapp1/pages/Index.java URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.3/tapestry-spring/src/test/java/org/example/testapp1/pages/Index.java?rev=1214690&view=auto ============================================================================== --- tapestry/tapestry5/branches/5.3/tapestry-spring/src/test/java/org/example/testapp1/pages/Index.java (added) +++ tapestry/tapestry5/branches/5.3/tapestry-spring/src/test/java/org/example/testapp1/pages/Index.java Thu Dec 15 10:29:34 2011 @@ -0,0 +1,29 @@ +// Copyright 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. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package org.example.testapp1.pages; + +import org.apache.tapestry5.ioc.annotations.Inject; +import org.example.testapp.services.ViaFactory; + +public class Index +{ + @Inject + private ViaFactory viaFactory; + + public String getMessage() + { + return viaFactory.getMessage(); + } +} Added: tapestry/tapestry5/branches/5.3/tapestry-spring/src/test/java/org/example/testapp1/services/AppModule.java URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.3/tapestry-spring/src/test/java/org/example/testapp1/services/AppModule.java?rev=1214690&view=auto ============================================================================== --- tapestry/tapestry5/branches/5.3/tapestry-spring/src/test/java/org/example/testapp1/services/AppModule.java (added) +++ tapestry/tapestry5/branches/5.3/tapestry-spring/src/test/java/org/example/testapp1/services/AppModule.java Thu Dec 15 10:29:34 2011 @@ -0,0 +1,29 @@ +// Copyright 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. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package org.example.testapp1.services; + +import org.apache.tapestry5.SymbolConstants; +import org.apache.tapestry5.ioc.MappedConfiguration; +import org.apache.tapestry5.ioc.annotations.SubModule; +import org.apache.tapestry5.spring.SpringModule; + +@SubModule(SpringModule.class) +public class AppModule +{ + public static void contributeApplicationDefaults(MappedConfiguration<String, String> configuration) + { + configuration.add(SymbolConstants.PRODUCTION_MODE, "false"); + } +} Added: tapestry/tapestry5/branches/5.3/tapestry-spring/src/test/webapp1/Index.tml URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.3/tapestry-spring/src/test/webapp1/Index.tml?rev=1214690&view=auto ============================================================================== --- tapestry/tapestry5/branches/5.3/tapestry-spring/src/test/webapp1/Index.tml (added) +++ tapestry/tapestry5/branches/5.3/tapestry-spring/src/test/webapp1/Index.tml Thu Dec 15 10:29:34 2011 @@ -0,0 +1,12 @@ +<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd"> + <head> + <title>Start Page</title> + </head> + <body> + + <h1>Demonstrates Spring Context Configured Externally</h1> + + <div>${message}</div> + + </body> +</html> Added: tapestry/tapestry5/branches/5.3/tapestry-spring/src/test/webapp1/WEB-INF/applicationContext.xml URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.3/tapestry-spring/src/test/webapp1/WEB-INF/applicationContext.xml?rev=1214690&view=auto ============================================================================== --- tapestry/tapestry5/branches/5.3/tapestry-spring/src/test/webapp1/WEB-INF/applicationContext.xml (added) +++ tapestry/tapestry5/branches/5.3/tapestry-spring/src/test/webapp1/WEB-INF/applicationContext.xml Thu Dec 15 10:29:34 2011 @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright 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. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:context="http://www.springframework.org/schema/context" + xsi:schemaLocation="http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans-3.0.xsd + http://www.springframework.org/schema/context + http://www.springframework.org/schema/context/spring-context-3.0.xsd"> + + <context:annotation-config/> + + + <bean id="fred" class="org.example.testapp.services.FlintstoneImpl"/> + <bean id="viaFactory" class="org.example.testapp.services.ViaFactoryFactory"/> + +</beans> + Added: tapestry/tapestry5/branches/5.3/tapestry-spring/src/test/webapp1/WEB-INF/web.xml URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.3/tapestry-spring/src/test/webapp1/WEB-INF/web.xml?rev=1214690&view=auto ============================================================================== --- tapestry/tapestry5/branches/5.3/tapestry-spring/src/test/webapp1/WEB-INF/web.xml (added) +++ tapestry/tapestry5/branches/5.3/tapestry-spring/src/test/webapp1/WEB-INF/web.xml Thu Dec 15 10:29:34 2011 @@ -0,0 +1,45 @@ +<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" + "http://java.sun.com/dtd/web-app_2_3.dtd"> +<!-- + Copyright 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. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<web-app> + <display-name>Tapestry-Spring Integration Test Application</display-name> + + <context-param> + <param-name>tapestry.app-package</param-name> + <param-value>org.example.testapp1</param-value> + </context-param> + + <context-param> + <param-name>tapestry.use-external-spring-context</param-name> + <param-value>true</param-value> + </context-param> + <filter> + <filter-name>app</filter-name> + <filter-class>org.apache.tapestry5.spring.TapestrySpringFilter</filter-class> + </filter> + <filter-mapping> + <filter-name>app</filter-name> + <url-pattern>/*</url-pattern> + </filter-mapping> + + <listener> + <listener-class> + org.springframework.web.context.ContextLoaderListener + </listener-class> + </listener> +</web-app>