Author: hlship
Date: Fri Jun 15 18:39:48 2007
New Revision: 547842
URL: http://svn.apache.org/viewvc?view=rev&rev=547842
Log:
TAPESTRY-1472: The module and filter are coded against Spring's
WebApplicationContext, but doesn't use any APIs not present in
ApplicationContext
Modified:
tapestry/tapestry5/trunk/tapestry-spring/src/main/java/org/apache/tapestry/internal/spring/SpringModuleDef.java
tapestry/tapestry5/trunk/tapestry-spring/src/main/java/org/apache/tapestry/spring/TapestrySpringFilter.java
tapestry/tapestry5/trunk/tapestry-spring/src/test/java/org/apache/tapestry/spring/TapestrySpringFilterTest.java
Modified:
tapestry/tapestry5/trunk/tapestry-spring/src/main/java/org/apache/tapestry/internal/spring/SpringModuleDef.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-spring/src/main/java/org/apache/tapestry/internal/spring/SpringModuleDef.java?view=diff&rev=547842&r1=547841&r2=547842
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-spring/src/main/java/org/apache/tapestry/internal/spring/SpringModuleDef.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-spring/src/main/java/org/apache/tapestry/internal/spring/SpringModuleDef.java
Fri Jun 15 18:39:48 2007
@@ -1,5 +1,21 @@
+// 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 static
org.apache.tapestry.ioc.internal.util.CollectionFactory.newCaseInsensitiveMap;
+
import java.util.Collections;
import java.util.Map;
import java.util.Set;
@@ -11,12 +27,12 @@
import org.apache.tapestry.ioc.def.DecoratorDef;
import org.apache.tapestry.ioc.def.ModuleDef;
import org.apache.tapestry.ioc.def.ServiceDef;
-import org.apache.tapestry.ioc.internal.util.CollectionFactory;
import org.springframework.beans.factory.BeanFactoryUtils;
+import org.springframework.context.ApplicationContext;
import org.springframework.web.context.WebApplicationContext;
/**
- * A wrapper that converts a Spring [EMAIL PROTECTED] WebApplicationContext}
into a set of service definitions,
+ * A wrapper that converts a Spring [EMAIL PROTECTED] ApplicationContext} into
a set of service definitions,
* compatible with Tapestry 5 IoC, for the beans defined in the context, as
well as the context
* itself.
*/
@@ -24,11 +40,11 @@
{
private static final String CONTEXT_SERVICE_ID =
WebApplicationContext.class.getSimpleName();
- private final WebApplicationContext _context;
+ private final ApplicationContext _context;
- private final Map<String, ServiceDef> _serviceDefs =
CollectionFactory.newCaseInsensitiveMap();
+ private final Map<String, ServiceDef> _serviceDefs =
newCaseInsensitiveMap();
- public SpringModuleDef(final WebApplicationContext context)
+ public SpringModuleDef(final ApplicationContext context)
{
_context = context;
Modified:
tapestry/tapestry5/trunk/tapestry-spring/src/main/java/org/apache/tapestry/spring/TapestrySpringFilter.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-spring/src/main/java/org/apache/tapestry/spring/TapestrySpringFilter.java?view=diff&rev=547842&r1=547841&r2=547842
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-spring/src/main/java/org/apache/tapestry/spring/TapestrySpringFilter.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-spring/src/main/java/org/apache/tapestry/spring/TapestrySpringFilter.java
Fri Jun 15 18:39:48 2007
@@ -1,3 +1,17 @@
+// 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 javax.servlet.ServletContext;
@@ -5,23 +19,24 @@
import org.apache.tapestry.TapestryFilter;
import org.apache.tapestry.internal.spring.SpringModuleDef;
import org.apache.tapestry.ioc.def.ModuleDef;
+import org.springframework.context.ApplicationContext;
import org.springframework.web.context.WebApplicationContext;
/**
* Adds a [EMAIL PROTECTED] ModuleDef} that contains all the beans defined by
the Spring
- * [EMAIL PROTECTED] WebApplicationContext}, as if they were Tapestry IoC
services.
+ * [EMAIL PROTECTED] ApplicationContext}, as if they were Tapestry IoC
services. This is done using a filter,
+ * so that the Spring beans can be "mixed into" the Tapestry IoC Registry
before it even starts up.
*/
public class TapestrySpringFilter extends TapestryFilter
{
-
@Override
protected ModuleDef[] provideExtraModuleDefs(ServletContext context)
{
- WebApplicationContext springContext = null;
+ ApplicationContext springContext = null;
try
{
- springContext = (WebApplicationContext) context
+ springContext = (ApplicationContext) context
.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
}
catch (Exception ex)
Modified:
tapestry/tapestry5/trunk/tapestry-spring/src/test/java/org/apache/tapestry/spring/TapestrySpringFilterTest.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-spring/src/test/java/org/apache/tapestry/spring/TapestrySpringFilterTest.java?view=diff&rev=547842&r1=547841&r2=547842
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-spring/src/test/java/org/apache/tapestry/spring/TapestrySpringFilterTest.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-spring/src/test/java/org/apache/tapestry/spring/TapestrySpringFilterTest.java
Fri Jun 15 18:39:48 2007
@@ -1,3 +1,17 @@
+// 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 javax.servlet.ServletContext;