Author: hlship
Date: Fri Mar 2 17:05:39 2007
New Revision: 514037
URL: http://svn.apache.org/viewvc?view=rev&rev=514037
Log:
TAPESTRY-1284: Simple, built-in Spring integration.
Added:
tapestry/tapestry5/tapestry-spring-integration/trunk/src/main/java/org/
tapestry/tapestry5/tapestry-spring-integration/trunk/src/main/java/org/apache/
tapestry/tapestry5/tapestry-spring-integration/trunk/src/main/java/org/apache/tapestry/
tapestry/tapestry5/tapestry-spring-integration/trunk/src/main/java/org/apache/tapestry/internal/
tapestry/tapestry5/tapestry-spring-integration/trunk/src/main/java/org/apache/tapestry/internal/spring/
tapestry/tapestry5/tapestry-spring-integration/trunk/src/main/java/org/apache/tapestry/internal/spring/SpringMessages.java
tapestry/tapestry5/tapestry-spring-integration/trunk/src/main/java/org/apache/tapestry/internal/spring/SpringObjectProvider.java
tapestry/tapestry5/tapestry-spring-integration/trunk/src/main/java/org/apache/tapestry/spring/
tapestry/tapestry5/tapestry-spring-integration/trunk/src/main/java/org/apache/tapestry/spring/SpringModule.java
tapestry/tapestry5/tapestry-spring-integration/trunk/src/main/resources/
tapestry/tapestry5/tapestry-spring-integration/trunk/src/main/resources/org/
tapestry/tapestry5/tapestry-spring-integration/trunk/src/main/resources/org/apache/
tapestry/tapestry5/tapestry-spring-integration/trunk/src/main/resources/org/apache/tapestry/
tapestry/tapestry5/tapestry-spring-integration/trunk/src/main/resources/org/apache/tapestry/internal/
tapestry/tapestry5/tapestry-spring-integration/trunk/src/main/resources/org/apache/tapestry/internal/spring/
tapestry/tapestry5/tapestry-spring-integration/trunk/src/main/resources/org/apache/tapestry/internal/spring/SpringStrings.properties
tapestry/tapestry5/tapestry-spring-integration/trunk/src/site/
tapestry/tapestry5/tapestry-spring-integration/trunk/src/site/apt/
tapestry/tapestry5/tapestry-spring-integration/trunk/src/site/apt/index.apt
tapestry/tapestry5/tapestry-spring-integration/trunk/src/site/site.xml
tapestry/tapestry5/tapestry-spring-integration/trunk/src/test/
tapestry/tapestry5/tapestry-spring-integration/trunk/src/test/conf/
tapestry/tapestry5/tapestry-spring-integration/trunk/src/test/conf/testng.xml
tapestry/tapestry5/tapestry-spring-integration/trunk/src/test/java/
tapestry/tapestry5/tapestry-spring-integration/trunk/src/test/java/org/
tapestry/tapestry5/tapestry-spring-integration/trunk/src/test/java/org/apache/
tapestry/tapestry5/tapestry-spring-integration/trunk/src/test/java/org/apache/tapestry/
tapestry/tapestry5/tapestry-spring-integration/trunk/src/test/java/org/apache/tapestry/internal/
tapestry/tapestry5/tapestry-spring-integration/trunk/src/test/java/org/apache/tapestry/internal/spring/
tapestry/tapestry5/tapestry-spring-integration/trunk/src/test/java/org/apache/tapestry/internal/spring/SpringObjectProviderTest.java
Modified:
tapestry/tapestry5/tapestry-core/trunk/NOTICE.txt
tapestry/tapestry5/tapestry-core/trunk/pom.xml
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/ContextImpl.java
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/Context.java
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/ContextForPageTester.java
tapestry/tapestry5/tapestry-core/trunk/src/site/site.xml
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ContextImplTest.java
tapestry/tapestry5/tapestry-ioc/trunk/src/site/site.xml
tapestry/tapestry5/tapestry-project/trunk/pom.xml
tapestry/tapestry5/tapestry-project/trunk/src/site/site.xml
tapestry/tapestry5/tapestry-spring-integration/trunk/ (props changed)
tapestry/tapestry5/tapestry-spring-integration/trunk/.classpath
tapestry/tapestry5/tapestry-spring-integration/trunk/pom.xml
Modified: tapestry/tapestry5/tapestry-core/trunk/NOTICE.txt
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/NOTICE.txt?view=diff&rev=514037&r1=514036&r2=514037
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/NOTICE.txt (original)
+++ tapestry/tapestry5/tapestry-core/trunk/NOTICE.txt Fri Mar 2 17:05:39 2007
@@ -5,10 +5,13 @@
the terms of the Mozilla Public License.
http://www.jboss.com/products/javassist
-This product makes use of the script.aculo.us JavaScript library,
+This product includes the script.aculo.us JavaScript library,
distributed under the terms of an MIT-style license.
http://script.aculo.us
-this product makes use of the prototype JavaScript library,
-distributed under the termso f an MIT-style license.
+This product includes the prototype JavaScript library,
+distributed under the terms of an MIT-style license.
+http://prototypejs.org/
+
+
Modified: tapestry/tapestry5/tapestry-core/trunk/pom.xml
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/pom.xml?view=diff&rev=514037&r1=514036&r2=514037
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/pom.xml (original)
+++ tapestry/tapestry5/tapestry-core/trunk/pom.xml Fri Mar 2 17:05:39 2007
@@ -106,7 +106,7 @@
<tags>
<tag>
<name>todo</name>
- <!- - Should be a combinaison of the letters
Xaoptcmf - ->
+ <!- - Should be a combinaition of the letters
Xaoptcmf - ->
<placement>a</placement>
<head>To do something:</head>
</tag>
Modified:
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/ContextImpl.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/ContextImpl.java?view=diff&rev=514037&r1=514036&r2=514037
==============================================================================
---
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/ContextImpl.java
(original)
+++
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/ContextImpl.java
Fri Mar 2 17:05:39 2007
@@ -90,4 +90,10 @@
return result;
}
+
+ public Object getAttribute(String name)
+ {
+ return _servletContext.getAttribute(name);
+ }
+
}
Modified:
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/Context.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/Context.java?view=diff&rev=514037&r1=514036&r2=514037
==============================================================================
---
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/Context.java
(original)
+++
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/Context.java
Fri Mar 2 17:05:39 2007
@@ -45,4 +45,13 @@
* @return the matches, sorted alphabetically
*/
List<String> getResourcePaths(String path);
+
+ /**
+ * Returns an attribute previously stored into the context with the given
name.
+ *
+ * @param name
+ * used to retrieve the attribute
+ * @return the attribute, or null if not found
+ */
+ Object getAttribute(String name);
}
Modified:
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/ContextForPageTester.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/ContextForPageTester.java?view=diff&rev=514037&r1=514036&r2=514037
==============================================================================
---
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/ContextForPageTester.java
(original)
+++
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/pagelevel/ContextForPageTester.java
Fri Mar 2 17:05:39 2007
@@ -59,4 +59,10 @@
"getResourcePaths() is not supported for
ContextForPageTester.");
}
+ public Object getAttribute(String name)
+ {
+ throw new UnsupportedOperationException(
+ "getAttribute() is not supported for ContextForPageTester.");
+ }
+
}
Modified: tapestry/tapestry5/tapestry-core/trunk/src/site/site.xml
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/site/site.xml?view=diff&rev=514037&r1=514036&r2=514037
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/site/site.xml (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/site/site.xml Fri Mar 2
17:05:39 2007
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
- 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.
@@ -17,8 +17,8 @@
<project name="Tapestry Core">
<bannerLeft>
- <name>Tapestry</name>
- <href>http://tapestry.apache.org/</href>
+ <name>Tapestry 5</name>
+ <href>http://tapestry.apache.org/tapestry5/</href>
<src>images/tapestry_banner.gif</src>
</bannerLeft>
<bannerRight>
Modified:
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ContextImplTest.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ContextImplTest.java?view=diff&rev=514037&r1=514036&r2=514037
==============================================================================
---
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ContextImplTest.java
(original)
+++
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ContextImplTest.java
Fri Mar 2 17:05:39 2007
@@ -24,6 +24,7 @@
import org.apache.tapestry.internal.test.InternalBaseTestCase;
import org.apache.tapestry.ioc.internal.util.CollectionFactory;
+import org.apache.tapestry.services.Context;
import org.testng.annotations.Test;
public class ContextImplTest extends InternalBaseTestCase
@@ -102,6 +103,25 @@
"/foo/beta/b.html",
"/foo/beta/c/c.html",
"/foo/gamma.html"));
+
+ verify();
+ }
+
+ @Test
+ public void get_attribute()
+ {
+ String name = "foo";
+ Object value = new Object();
+
+ ServletContext servletContext = newServletContext();
+
+ expect(servletContext.getAttribute(name)).andReturn(value);
+
+ replay();
+
+ Context context = new ContextImpl(servletContext);
+
+ assertSame(context.getAttribute(name), value);
verify();
}
Modified: tapestry/tapestry5/tapestry-ioc/trunk/src/site/site.xml
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-ioc/trunk/src/site/site.xml?view=diff&rev=514037&r1=514036&r2=514037
==============================================================================
--- tapestry/tapestry5/tapestry-ioc/trunk/src/site/site.xml (original)
+++ tapestry/tapestry5/tapestry-ioc/trunk/src/site/site.xml Fri Mar 2 17:05:39
2007
@@ -17,8 +17,8 @@
<project name="Tapestry IoC">
<bannerLeft>
- <name>Tapestry</name>
- <href>http://tapestry.apache.org/</href>
+ <name>Tapestry 5</name>
+ <href>http://tapestry.apache.org/tapestry5/</href>
<src>images/tapestry_banner.gif</src>
</bannerLeft>
<bannerRight>
Modified: tapestry/tapestry5/tapestry-project/trunk/pom.xml
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-project/trunk/pom.xml?view=diff&rev=514037&r1=514036&r2=514037
==============================================================================
--- tapestry/tapestry5/tapestry-project/trunk/pom.xml (original)
+++ tapestry/tapestry5/tapestry-project/trunk/pom.xml Fri Mar 2 17:05:39 2007
@@ -6,7 +6,7 @@
<artifactId>tapestry-project</artifactId>
<packaging>pom</packaging>
<version>5.0.3-SNAPSHOT</version>
- <name>Tapestry Project</name>
+ <name>Tapestry 5 Project</name>
<inceptionYear>2006</inceptionYear>
<url>http://tapestry.apache.org/tapestry5/</url>
<licenses>
@@ -83,6 +83,8 @@
<modules>
<module>../tapestry-ioc</module>
<module>../tapestry-core</module>
+ <module>../tapestry-spring-integration</module>
+
<!-- Temporarily removed until the project is named correctly
and set up with a trunk, etc.
<module>../tapestry-Workbench</module>
-->
@@ -135,7 +137,14 @@
<version>0.8.1</version>
<scope>test</scope>
</dependency>
-
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <version>5.1</version>
+ <classifier>jdk15</classifier>
+ <scope>test</scope>
+ </dependency>
+
<!-- Now, artifacts created by Tapestry sub-projects.
-->
<dependency>
@@ -148,6 +157,7 @@
<groupId>org.apache.tapestry</groupId>
<artifactId>tapestry-core</artifactId>
<version>5.0.3-SNAPSHOT</version>
+ <scope>compile</scope>
</dependency>
</dependencies>
</dependencyManagement>
Modified: tapestry/tapestry5/tapestry-project/trunk/src/site/site.xml
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-project/trunk/src/site/site.xml?view=diff&rev=514037&r1=514036&r2=514037
==============================================================================
--- tapestry/tapestry5/tapestry-project/trunk/src/site/site.xml (original)
+++ tapestry/tapestry5/tapestry-project/trunk/src/site/site.xml Fri Mar 2
17:05:39 2007
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="Apache Tapestry">
<bannerLeft>
- <name>Tapestry</name>
- <href>http://tapestry.apache.org/</href>
+ <name>Tapestry 5</name>
+ <href>http://tapestry.apache.org/tapestry5/</href>
<src>images/tapestry_banner.gif</src>
</bannerLeft>
<bannerRight>
Propchange: tapestry/tapestry5/tapestry-spring-integration/trunk/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Fri Mar 2 17:05:39 2007
@@ -1 +1,3 @@
bin
+target
+temp-testng-customsuite.xml
Modified: tapestry/tapestry5/tapestry-spring-integration/trunk/.classpath
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-spring-integration/trunk/.classpath?view=diff&rev=514037&r1=514036&r2=514037
==============================================================================
--- tapestry/tapestry5/tapestry-spring-integration/trunk/.classpath (original)
+++ tapestry/tapestry5/tapestry-spring-integration/trunk/.classpath Fri Mar 2
17:05:39 2007
@@ -1,7 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/java"/>
+ <classpathentry kind="src" path="src/test/java"/>
<classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con"
path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+ <classpathentry kind="lib" path="src/main/resources"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Modified: tapestry/tapestry5/tapestry-spring-integration/trunk/pom.xml
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-spring-integration/trunk/pom.xml?view=diff&rev=514037&r1=514036&r2=514037
==============================================================================
--- tapestry/tapestry5/tapestry-spring-integration/trunk/pom.xml (original)
+++ tapestry/tapestry5/tapestry-spring-integration/trunk/pom.xml Fri Mar 2
17:05:39 2007
@@ -1,3 +1,4 @@
+
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -5,6 +6,139 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.tapestry</groupId>
<artifactId>tapestry-spring-integration</artifactId>
+ <name>Tapestry-Spring Integration Library</name>
+ <packaging>jar</packaging>
<version>5.0.3-SNAPSHOT</version>
- <description>Provides integration of Tapestry with the Spring IoC
container</description>
+ <description>Provides integration of Tapestry with the Spring IoC
container.</description>
+ <parent>
+ <groupId>org.apache.tapestry</groupId>
+ <artifactId>tapestry-project</artifactId>
+ <version>5.0.3-SNAPSHOT</version>
+ <relativePath>../tapestry-project/pom.xml</relativePath>
+ </parent>
+ <inceptionYear>2007</inceptionYear>
+ <!-- Due to Maven 2 bugs, this has to be copied into each module POM. -->
+ <url>http://tapestry.apache.org/tapestry5/${pom.artifactId}/</url>
+ <scm>
+
<connection>scm:svn:https://svn.apache.org/repos/asf/tapestry/tapestry5/${pom.artifactId}/trunk/</connection>
+
<url>http://svn.apache.org/viewvc/tapestry/tapestry5/${pom.artifactId}/trunk/</url>
+ </scm>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tapestry</groupId>
+ <artifactId>tapestry-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-web</artifactId>
+ <version>1.2.8</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <version>5.1</version>
+ <classifier>jdk15</classifier>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ </plugin>
+ <!-- This gets the plugin to clean up the cobertura.ser file left
+ in the root directory. -->
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>cobertura-maven-plugin</artifactId>
+ <version>${cobertura-plugin-version}</version>
+ <executions>
+ <execution>
+ <id>clean</id>
+ <goals>
+ <goal>clean</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifestEntries>
+
<Tapestry-Module-Classes>org.apache.tapestry.spring.SpringModule</Tapestry-Module-Classes>
+ </manifestEntries>
+ </archive>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <!--
+ <tags>
+ <tag>
+ <name>todo</name>
+ <!- - Should be a combinaison of the letters Xaoptcmf - ->
+ <placement>a</placement>
+ <head>To do something:</head>
+ </tag>
+ </tags> -->
+ <linksource>true</linksource>
+ <links>
+ <link>http://java.sun.com/j2se/1.5.0/docs/api/</link>
+ <link>http://jakarta.apache.org/commons/logging/apidocs/</link>
+
<link>http://tapestry.apache.org/tapestry5/tapestry-ioc/apidocs/</link>
+
<link>http://tapestry.apache.org/tapestry5/tapestry-core/apidocs/</link>
+ </links>
+
<stylesheetfile>${basedir}/src/site/resources/css/jdstyle.css</stylesheetfile>
+ </configuration>
+ </plugin> <!--
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>cobertura-maven-plugin</artifactId>
+ <version>${cobertura-plugin-version}</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-report-plugin</artifactId>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.tapestry</groupId>
+ <artifactId>tapestry-component-report</artifactId>
+ <version>5.0.2</version>
+ <configuration>
+ <rootPackage>org.apache.tapestry.corelib</rootPackage>
+ </configuration>
+ </plugin> -->
+ </plugins>
+ </reporting>
</project>
Added:
tapestry/tapestry5/tapestry-spring-integration/trunk/src/main/java/org/apache/tapestry/internal/spring/SpringMessages.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-spring-integration/trunk/src/main/java/org/apache/tapestry/internal/spring/SpringMessages.java?view=auto&rev=514037
==============================================================================
---
tapestry/tapestry5/tapestry-spring-integration/trunk/src/main/java/org/apache/tapestry/internal/spring/SpringMessages.java
(added)
+++
tapestry/tapestry5/tapestry-spring-integration/trunk/src/main/java/org/apache/tapestry/internal/spring/SpringMessages.java
Fri Mar 2 17:05:39 2007
@@ -0,0 +1,47 @@
+// Copyright 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.
+// 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.tapestry.internal.spring;
+
+import org.apache.tapestry.ioc.Messages;
+import org.apache.tapestry.ioc.internal.util.MessagesImpl;
+import org.springframework.web.context.ContextLoaderListener;
+import org.springframework.web.context.WebApplicationContext;
+
+class SpringMessages
+{
+ private static final Messages MESSAGES =
MessagesImpl.forClass(SpringMessages.class);
+
+ static String failureObtainingContext(Throwable cause)
+ {
+ return MESSAGES.format("failure-obtaining-context", cause);
+ }
+
+ static String missingContext()
+ {
+ return MESSAGES.format("missing-context",
ContextLoaderListener.class.getName());
+ }
+
+ static String usingContext(WebApplicationContext context)
+ {
+ // context.getDisplayName() ?
+
+ return MESSAGES.format("using-context", context);
+ }
+
+ static String beanAccessFailure(String beanName, Class beanType, Throwable
cause)
+ {
+ return MESSAGES.format("bean-access-failure", beanName,
beanType.getName(), cause);
+ }
+}
Added:
tapestry/tapestry5/tapestry-spring-integration/trunk/src/main/java/org/apache/tapestry/internal/spring/SpringObjectProvider.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-spring-integration/trunk/src/main/java/org/apache/tapestry/internal/spring/SpringObjectProvider.java?view=auto&rev=514037
==============================================================================
---
tapestry/tapestry5/tapestry-spring-integration/trunk/src/main/java/org/apache/tapestry/internal/spring/SpringObjectProvider.java
(added)
+++
tapestry/tapestry5/tapestry-spring-integration/trunk/src/main/java/org/apache/tapestry/internal/spring/SpringObjectProvider.java
Fri Mar 2 17:05:39 2007
@@ -0,0 +1,75 @@
+// Copyright 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.
+// 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.tapestry.internal.spring;
+
+import org.apache.commons.logging.Log;
+import org.apache.tapestry.ioc.ObjectProvider;
+import org.apache.tapestry.ioc.ServiceLocator;
+import org.apache.tapestry.services.Context;
+import org.springframework.web.context.WebApplicationContext;
+
+/**
+ * Provides an object from the Spring bean context (configured in web.xml).
+ * <p>
+ * This is just a first pass; later we'll have the provider check to see if
beans are singletons,
+ * and provide a proxy to the singleton rather than the raw object itself.
+ */
+public class SpringObjectProvider implements ObjectProvider
+{
+ private final Log _log;
+
+ private final Context _context;
+
+ private final WebApplicationContext _springApplicationContext;
+
+ public SpringObjectProvider(Log log, Context context)
+ {
+ _log = log;
+ _context = context;
+
+ try
+ {
+ _springApplicationContext = (WebApplicationContext) _context
+
.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
+ }
+ catch (Exception ex)
+ {
+ throw new RuntimeException(SpringMessages.failureObtainingContext(ex),
ex);
+ }
+
+ if (_springApplicationContext == null)
+ throw new RuntimeException(SpringMessages.missingContext());
+
+ _log.info(SpringMessages.usingContext(_springApplicationContext));
+ }
+
+ /**
+ * The expression is the name of a spring bean inside the context.
+ */
+ public <T> T provide(String expression, Class<T> objectType, ServiceLocator
locator)
+ {
+ try
+ {
+ Object raw = _springApplicationContext.getBean(expression, objectType);
+
+ return objectType.cast(raw);
+ }
+ catch (Exception ex)
+ {
+ throw new RuntimeException(SpringMessages.beanAccessFailure(expression,
objectType, ex), ex);
+ }
+ }
+
+}
Added:
tapestry/tapestry5/tapestry-spring-integration/trunk/src/main/java/org/apache/tapestry/spring/SpringModule.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-spring-integration/trunk/src/main/java/org/apache/tapestry/spring/SpringModule.java?view=auto&rev=514037
==============================================================================
---
tapestry/tapestry5/tapestry-spring-integration/trunk/src/main/java/org/apache/tapestry/spring/SpringModule.java
(added)
+++
tapestry/tapestry5/tapestry-spring-integration/trunk/src/main/java/org/apache/tapestry/spring/SpringModule.java
Fri Mar 2 17:05:39 2007
@@ -0,0 +1,57 @@
+// Copyright 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.
+// 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.tapestry.spring;
+
+import org.apache.commons.logging.Log;
+import org.apache.tapestry.internal.spring.SpringObjectProvider;
+import org.apache.tapestry.ioc.MappedConfiguration;
+import org.apache.tapestry.ioc.ObjectProvider;
+import org.apache.tapestry.ioc.annotations.Contribute;
+import org.apache.tapestry.ioc.annotations.Id;
+import org.apache.tapestry.ioc.annotations.Inject;
+import org.apache.tapestry.ioc.annotations.InjectService;
+import org.apache.tapestry.services.Context;
+import org.springframework.web.context.WebApplicationContext;
+
[EMAIL PROTECTED]("tapestry.spring")
+public class SpringModule
+{
+ /**
+ * Provider that interprets expressions as the names of beans within the
Spring
+ * [EMAIL PROTECTED] WebApplicationContext}. Spring <em>is case
sensitive</em>, unlike Tapestry 5 IoC.
+ * The context must be configured in the <a
+ *
href="http://static.springframework.org/spring/docs/1.2.x/reference/beans.html#context-create">standard
+ * way</a> (which involves adding a listener to the web.xml deployment
descriptor).
+ */
+ public static ObjectProvider buildSpringObjectProvider(Log log,
@Inject("infrastructure:context")
+ Context context)
+ {
+ return new SpringObjectProvider(log, context);
+ }
+
+ /**
+ * Contributes a "spring:" provider, that obtains beans from the
+ * [EMAIL PROTECTED] #buildSpringObjectProvider(Log, Context)
SpringObjectProvider service}.
+ */
+ @Contribute("tapestry.ioc.MasterObjectProvider")
+ public static void
contributeMasterObjectProvider(@InjectService("SpringObjectProvider")
+ ObjectProvider springObjectProvider,
+
+ MappedConfiguration<String, ObjectProvider> configuration)
+ {
+ configuration.add("spring", springObjectProvider);
+ }
+
+}
Added:
tapestry/tapestry5/tapestry-spring-integration/trunk/src/main/resources/org/apache/tapestry/internal/spring/SpringStrings.properties
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-spring-integration/trunk/src/main/resources/org/apache/tapestry/internal/spring/SpringStrings.properties?view=auto&rev=514037
==============================================================================
---
tapestry/tapestry5/tapestry-spring-integration/trunk/src/main/resources/org/apache/tapestry/internal/spring/SpringStrings.properties
(added)
+++
tapestry/tapestry5/tapestry-spring-integration/trunk/src/main/resources/org/apache/tapestry/internal/spring/SpringStrings.properties
Fri Mar 2 17:05:39 2007
@@ -0,0 +1,18 @@
+# Copyright 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.
+# 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.
+
+failure-obtaining-context=An exception occurred obtained the Spring
WebApplicationContext: %s
+missing-context=The Spring WebApplicationContext is not present. The likely
cause is that the %s listener was not declared inside the application's web.xml
deployment descriptor.
+using-context=Using Spring WebApplicationContext %s.
+bean-access-failure=Failure to obtain Spring bean '%s' (of type %s): %s
Added:
tapestry/tapestry5/tapestry-spring-integration/trunk/src/site/apt/index.apt
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-spring-integration/trunk/src/site/apt/index.apt?view=auto&rev=514037
==============================================================================
--- tapestry/tapestry5/tapestry-spring-integration/trunk/src/site/apt/index.apt
(added)
+++ tapestry/tapestry5/tapestry-spring-integration/trunk/src/site/apt/index.apt
Fri Mar 2 17:05:39 2007
@@ -0,0 +1,10 @@
+ ----
+ Tapestry/Spring Integration
+ ----
+
+Tapestry/Spring Integration
+
+ Provides integration between Tapestry and Spring, allowing beans defined by
Spring to be injected into Tapestry IoC services, and into
+ Tapestry components.
+
+
\ No newline at end of file
Added: tapestry/tapestry5/tapestry-spring-integration/trunk/src/site/site.xml
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-spring-integration/trunk/src/site/site.xml?view=auto&rev=514037
==============================================================================
--- tapestry/tapestry5/tapestry-spring-integration/trunk/src/site/site.xml
(added)
+++ tapestry/tapestry5/tapestry-spring-integration/trunk/src/site/site.xml Fri
Mar 2 17:05:39 2007
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ Copyright 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.
+ 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.
+-->
+
+<project name="Tapestry IoC">
+ <bannerLeft>
+ <name>Tapestry 5</name>
+ <href>http://tapestry.apache.org/tapestry5/</href>
+ <src>images/tapestry_banner.gif</src>
+ </bannerLeft>
+ <bannerRight>
+ <name>Apache</name>
+ <href>http://www.apache.org</href>
+ <src>images/asf_logo_wide.gif</src>
+ </bannerRight>
+ <skin>
+ <groupId>org.apache.tapestry</groupId>
+ <artifactId>maven-skin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </skin>
+
+ <publishDate format="dd MMM yyyy" />
+
+ <body>
+ <links>
+ <item name="Apache" href="http://www.apache.org/" />
+ </links>
+
+ <menu name="Quick Links">
+ <item name="Download" href="http://tapestry.apache.org/download.html"/>
+ </menu>
+
+ <menu ref="reports"/>
+
+ </body>
+</project>
Added:
tapestry/tapestry5/tapestry-spring-integration/trunk/src/test/conf/testng.xml
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-spring-integration/trunk/src/test/conf/testng.xml?view=auto&rev=514037
==============================================================================
---
tapestry/tapestry5/tapestry-spring-integration/trunk/src/test/conf/testng.xml
(added)
+++
tapestry/tapestry5/tapestry-spring-integration/trunk/src/test/conf/testng.xml
Fri Mar 2 17:05:39 2007
@@ -0,0 +1,24 @@
+<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
+<!--
+ Copyright 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.
+ 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.
+-->
+
+<suite name="Tapestry Spring Integration" parallel="false" thread-count="10"
annotations="1.5" verbose="2">
+ <test name="Tapestry Spring Integration">
+ <packages>
+ <package name="org.apache.tapestry.internal.spring"/>
+ </packages>
+ </test>
+</suite>
Added:
tapestry/tapestry5/tapestry-spring-integration/trunk/src/test/java/org/apache/tapestry/internal/spring/SpringObjectProviderTest.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-spring-integration/trunk/src/test/java/org/apache/tapestry/internal/spring/SpringObjectProviderTest.java?view=auto&rev=514037
==============================================================================
---
tapestry/tapestry5/tapestry-spring-integration/trunk/src/test/java/org/apache/tapestry/internal/spring/SpringObjectProviderTest.java
(added)
+++
tapestry/tapestry5/tapestry-spring-integration/trunk/src/test/java/org/apache/tapestry/internal/spring/SpringObjectProviderTest.java
Fri Mar 2 17:05:39 2007
@@ -0,0 +1,79 @@
+// Copyright 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.
+// 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.tapestry.internal.spring;
+
+import org.apache.commons.logging.Log;
+import org.apache.tapestry.services.Context;
+import org.apache.tapestry.test.TapestryTestCase;
+import org.springframework.web.context.WebApplicationContext;
+import org.testng.annotations.Test;
+
+public class SpringObjectProviderTest extends TapestryTestCase
+{
+ @Test
+ public void missing_spring_context()
+ {
+ Log log = newLog();
+ Context context = newContext(null);
+
+ replay();
+
+ try
+ {
+ new SpringObjectProvider(log, context);
+ unreachable();
+ }
+ catch (RuntimeException ex)
+ {
+ assertEquals(
+ ex.getMessage(),
+ "The Spring WebApplicationContext is not present. The likely cause
is that the org.springframework.web.context.ContextLoaderListener listener was
not declared inside the application\'s web.xml deployment descriptor.");
+ }
+
+ verify();
+ }
+
+ @Test
+ public void error_getting_spring_context()
+ {
+ Log log = newLog();
+ Context context = newContext("[Placeholder]");
+
+ replay();
+
+ try
+ {
+ new SpringObjectProvider(log, context);
+ unreachable();
+ }
+ catch (RuntimeException ex)
+ {
+ assertTrue(ex.getMessage().startsWith(
+ "An exception occurred obtained the Spring WebApplicationContext"));
+ }
+
+ verify();
+ }
+
+ private Context newContext(Object webApplicationContext)
+ {
+ Context context = newContext();
+
+
expect(context.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE))
+ .andReturn(webApplicationContext);
+
+ return context;
+ }
+}