language stringclasses 1
value | owner stringlengths 2 15 | repo stringlengths 2 21 | sha stringlengths 45 45 | message stringlengths 7 36.3k | path stringlengths 1 199 | patch stringlengths 15 102k | is_multipart bool 2
classes |
|---|---|---|---|---|---|---|---|
Other | spring-projects | spring-framework | b4fea47d5cff9f3c85e62c233c2fe86b1d616592.json | Introduce FeatureSpecification support
Introduce FeatureSpecification interface and implementations
FeatureSpecification objects decouple the configuration of
spring container features from the concern of parsing XML
namespaces, allowing for reuse in code-based configuration
(see @Feature* annotations below).
* ComponentScanSpec
* TxAnnotationDriven
* MvcAnnotationDriven
* MvcDefaultServletHandler
* MvcResources
* MvcViewControllers
Refactor associated BeanDefinitionParsers to delegate to new impls above
The following BeanDefinitionParser implementations now deal only
with the concern of XML parsing. Validation is handled by their
corresponding FeatureSpecification object. Bean definition creation
and registration is handled by their corresponding
FeatureSpecificationExecutor type.
* ComponentScanBeanDefinitionParser
* AnnotationDrivenBeanDefinitionParser (tx)
* AnnotationDrivenBeanDefinitionParser (mvc)
* DefaultServletHandlerBeanDefinitionParser
* ResourcesBeanDefinitionParser
* ViewControllerBeanDefinitionParser
Update AopNamespaceUtils to decouple from XML (DOM API)
Methods necessary for executing TxAnnotationDriven specification
(and eventually, the AspectJAutoProxy specification) have been
added that accept boolean arguments for whether to proxy
target classes and whether to expose the proxy via threadlocal.
Methods that accepted and introspected DOM Element objects still
exist but have been deprecated.
Introduce @FeatureConfiguration classes and @Feature methods
Allow for creation and configuration of FeatureSpecification objects
at the user level. A companion for @Configuration classes allowing
for completely code-driven configuration of the Spring container.
See changes in ConfigurationClassPostProcessor for implementation
details.
See Feature*Tests for usage examples.
FeatureTestSuite in .integration-tests is a JUnit test suite designed
to aggregate all BDP and Feature* related tests for a convenient way
to confirm that Feature-related changes don't break anything.
Uncomment this test and execute from Eclipse / IDEA. Due to classpath
issues, this cannot be compiled by Ant/Ivy at the command line.
Introduce @FeatureAnnotation meta-annotation and @ComponentScan impl
@FeatureAnnotation provides an alternate mechanism for creating
and executing FeatureSpecification objects. See @ComponentScan
and its corresponding ComponentScanAnnotationParser implementation
for details. See ComponentScanAnnotationIntegrationTests for usage
examples
Introduce Default[Formatting]ConversionService implementations
Allows for convenient instantiation of ConversionService objects
containing defaults appropriate for most environments. Replaces
similar support originally in ConversionServiceFactory (which is now
deprecated). This change was justified by the need to avoid use
of FactoryBeans in @Configuration classes (such as
FormattingConversionServiceFactoryBean). It is strongly preferred
that users simply instantiate and configure the objects that underlie
our FactoryBeans. In the case of the ConversionService types, the
easiest way to do this is to create Default* subtypes. This also
follows convention with the rest of the framework.
Minor updates to util classes
All in service of changes above. See diffs for self-explanatory
details.
* BeanUtils
* ObjectUtils
* ReflectionUtils | org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/config/MvcViewControllersTests.java | @@ -0,0 +1,131 @@
+/*
+ * Copyright 2002-2011 the original author or authors.
+ *
+ * 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.springframework.web.servlet.config;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.Map;
+
+import org.junit.Test;
+import org.springframework.beans.factory.parsing.FailFastProblemReporter;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+import org.springframework.context.annotation.Feature;
+import org.springframework.context.annotation.FeatureConfiguration;
+import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping;
+import org.springframework.web.servlet.mvc.ParameterizableViewController;
+import org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter;
+
+/**
+ * Test fixture for {@link MvcViewControllers} feature specification.
+ * @author Rossen Stoyanchev
+ * @since 3.1
+ */
+public class MvcViewControllersTests {
+
+ @Test
+ public void testMvcViewControllers() {
+ AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
+ ctx.register(MvcViewControllersFeature.class);
+ ctx.refresh();
+ SimpleControllerHandlerAdapter adapter = ctx.getBean(SimpleControllerHandlerAdapter.class);
+ assertNotNull(adapter);
+ SimpleUrlHandlerMapping handler = ctx.getBean(SimpleUrlHandlerMapping.class);
+ assertNotNull(handler);
+ Map<String, ?> urlMap = handler.getUrlMap();
+ assertNotNull(urlMap);
+ assertEquals(2, urlMap.size());
+ ParameterizableViewController controller = (ParameterizableViewController) urlMap.get("/");
+ assertNotNull(controller);
+ assertEquals("home", controller.getViewName());
+ controller = (ParameterizableViewController) urlMap.get("/account");
+ assertNotNull(controller);
+ assertNull(controller.getViewName());
+ }
+
+ @Test
+ public void testEmptyPath() {
+ AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
+ ctx.register(EmptyPathViewControllersFeature.class);
+ try {
+ ctx.refresh();
+ fail("expected exception");
+ } catch (Exception ex) {
+ assertTrue(ex.getCause().getMessage().contains("path attribute"));
+ }
+ }
+
+ @Test
+ public void testEmptyViewName() {
+ AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
+ ctx.register(EmptyViewNameViewControllersFeature.class);
+ try {
+ ctx.refresh();
+ fail("expected exception");
+ } catch (Exception ex) {
+ assertTrue(ex.getCause().getMessage().contains("not empty"));
+ }
+ }
+
+ @Test
+ public void testNullViewName() {
+ FailFastProblemReporter problemReporter = new FailFastProblemReporter();
+ assertThat(new MvcViewControllers("/some/path").validate(problemReporter), is(true));
+ }
+
+
+ @FeatureConfiguration
+ private static class MvcViewControllersFeature {
+
+ @SuppressWarnings("unused")
+ @Feature
+ public MvcViewControllers mvcViewControllers() {
+ return new MvcViewControllers("/", "home").viewController("/account");
+ }
+
+ }
+
+
+ @FeatureConfiguration
+ private static class EmptyViewNameViewControllersFeature {
+
+ @SuppressWarnings("unused")
+ @Feature
+ public MvcViewControllers mvcViewControllers() {
+ return new MvcViewControllers("/some/path", "");
+ }
+
+ }
+
+
+ @FeatureConfiguration
+ private static class EmptyPathViewControllersFeature {
+
+ @SuppressWarnings("unused")
+ @Feature
+ public MvcViewControllers mvcViewControllers() {
+ return new MvcViewControllers("", "someViewName");
+ }
+
+ }
+
+}
+ | true |
Other | spring-projects | spring-framework | b4fea47d5cff9f3c85e62c233c2fe86b1d616592.json | Introduce FeatureSpecification support
Introduce FeatureSpecification interface and implementations
FeatureSpecification objects decouple the configuration of
spring container features from the concern of parsing XML
namespaces, allowing for reuse in code-based configuration
(see @Feature* annotations below).
* ComponentScanSpec
* TxAnnotationDriven
* MvcAnnotationDriven
* MvcDefaultServletHandler
* MvcResources
* MvcViewControllers
Refactor associated BeanDefinitionParsers to delegate to new impls above
The following BeanDefinitionParser implementations now deal only
with the concern of XML parsing. Validation is handled by their
corresponding FeatureSpecification object. Bean definition creation
and registration is handled by their corresponding
FeatureSpecificationExecutor type.
* ComponentScanBeanDefinitionParser
* AnnotationDrivenBeanDefinitionParser (tx)
* AnnotationDrivenBeanDefinitionParser (mvc)
* DefaultServletHandlerBeanDefinitionParser
* ResourcesBeanDefinitionParser
* ViewControllerBeanDefinitionParser
Update AopNamespaceUtils to decouple from XML (DOM API)
Methods necessary for executing TxAnnotationDriven specification
(and eventually, the AspectJAutoProxy specification) have been
added that accept boolean arguments for whether to proxy
target classes and whether to expose the proxy via threadlocal.
Methods that accepted and introspected DOM Element objects still
exist but have been deprecated.
Introduce @FeatureConfiguration classes and @Feature methods
Allow for creation and configuration of FeatureSpecification objects
at the user level. A companion for @Configuration classes allowing
for completely code-driven configuration of the Spring container.
See changes in ConfigurationClassPostProcessor for implementation
details.
See Feature*Tests for usage examples.
FeatureTestSuite in .integration-tests is a JUnit test suite designed
to aggregate all BDP and Feature* related tests for a convenient way
to confirm that Feature-related changes don't break anything.
Uncomment this test and execute from Eclipse / IDEA. Due to classpath
issues, this cannot be compiled by Ant/Ivy at the command line.
Introduce @FeatureAnnotation meta-annotation and @ComponentScan impl
@FeatureAnnotation provides an alternate mechanism for creating
and executing FeatureSpecification objects. See @ComponentScan
and its corresponding ComponentScanAnnotationParser implementation
for details. See ComponentScanAnnotationIntegrationTests for usage
examples
Introduce Default[Formatting]ConversionService implementations
Allows for convenient instantiation of ConversionService objects
containing defaults appropriate for most environments. Replaces
similar support originally in ConversionServiceFactory (which is now
deprecated). This change was justified by the need to avoid use
of FactoryBeans in @Configuration classes (such as
FormattingConversionServiceFactoryBean). It is strongly preferred
that users simply instantiate and configure the objects that underlie
our FactoryBeans. In the case of the ConversionService types, the
easiest way to do this is to create Default* subtypes. This also
follows convention with the rest of the framework.
Minor updates to util classes
All in service of changes above. See diffs for self-explanatory
details.
* BeanUtils
* ObjectUtils
* ReflectionUtils | org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/annotation/Spr7766Tests.java | @@ -1,10 +1,26 @@
+/*
+ * Copyright 2002-2011 the original author or authors.
+ *
+ * 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.springframework.web.servlet.mvc.annotation;
import java.awt.Color;
import org.junit.Test;
import org.springframework.core.convert.converter.Converter;
-import org.springframework.core.convert.support.ConversionServiceFactory;
+import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.core.convert.support.GenericConversionService;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
@@ -16,7 +32,7 @@ public class Spr7766Tests {
public void test() throws Exception {
AnnotationMethodHandlerAdapter adapter = new AnnotationMethodHandlerAdapter();
ConfigurableWebBindingInitializer binder = new ConfigurableWebBindingInitializer();
- GenericConversionService service = ConversionServiceFactory.createDefaultConversionService();
+ GenericConversionService service = new DefaultConversionService();
service.addConverter(new ColorConverter());
binder.setConversionService(service);
adapter.setWebBindingInitializer(binder); | true |
Other | spring-projects | spring-framework | b4fea47d5cff9f3c85e62c233c2fe86b1d616592.json | Introduce FeatureSpecification support
Introduce FeatureSpecification interface and implementations
FeatureSpecification objects decouple the configuration of
spring container features from the concern of parsing XML
namespaces, allowing for reuse in code-based configuration
(see @Feature* annotations below).
* ComponentScanSpec
* TxAnnotationDriven
* MvcAnnotationDriven
* MvcDefaultServletHandler
* MvcResources
* MvcViewControllers
Refactor associated BeanDefinitionParsers to delegate to new impls above
The following BeanDefinitionParser implementations now deal only
with the concern of XML parsing. Validation is handled by their
corresponding FeatureSpecification object. Bean definition creation
and registration is handled by their corresponding
FeatureSpecificationExecutor type.
* ComponentScanBeanDefinitionParser
* AnnotationDrivenBeanDefinitionParser (tx)
* AnnotationDrivenBeanDefinitionParser (mvc)
* DefaultServletHandlerBeanDefinitionParser
* ResourcesBeanDefinitionParser
* ViewControllerBeanDefinitionParser
Update AopNamespaceUtils to decouple from XML (DOM API)
Methods necessary for executing TxAnnotationDriven specification
(and eventually, the AspectJAutoProxy specification) have been
added that accept boolean arguments for whether to proxy
target classes and whether to expose the proxy via threadlocal.
Methods that accepted and introspected DOM Element objects still
exist but have been deprecated.
Introduce @FeatureConfiguration classes and @Feature methods
Allow for creation and configuration of FeatureSpecification objects
at the user level. A companion for @Configuration classes allowing
for completely code-driven configuration of the Spring container.
See changes in ConfigurationClassPostProcessor for implementation
details.
See Feature*Tests for usage examples.
FeatureTestSuite in .integration-tests is a JUnit test suite designed
to aggregate all BDP and Feature* related tests for a convenient way
to confirm that Feature-related changes don't break anything.
Uncomment this test and execute from Eclipse / IDEA. Due to classpath
issues, this cannot be compiled by Ant/Ivy at the command line.
Introduce @FeatureAnnotation meta-annotation and @ComponentScan impl
@FeatureAnnotation provides an alternate mechanism for creating
and executing FeatureSpecification objects. See @ComponentScan
and its corresponding ComponentScanAnnotationParser implementation
for details. See ComponentScanAnnotationIntegrationTests for usage
examples
Introduce Default[Formatting]ConversionService implementations
Allows for convenient instantiation of ConversionService objects
containing defaults appropriate for most environments. Replaces
similar support originally in ConversionServiceFactory (which is now
deprecated). This change was justified by the need to avoid use
of FactoryBeans in @Configuration classes (such as
FormattingConversionServiceFactoryBean). It is strongly preferred
that users simply instantiate and configure the objects that underlie
our FactoryBeans. In the case of the ConversionService types, the
easiest way to do this is to create Default* subtypes. This also
follows convention with the rest of the framework.
Minor updates to util classes
All in service of changes above. See diffs for self-explanatory
details.
* BeanUtils
* ObjectUtils
* ReflectionUtils | org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/annotation/Spr7839Tests.java | @@ -1,3 +1,19 @@
+/*
+ * Copyright 2002-2011 the original author or authors.
+ *
+ * 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.springframework.web.servlet.mvc.annotation;
import static org.junit.Assert.assertEquals;
@@ -9,7 +25,7 @@
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.core.convert.converter.Converter;
-import org.springframework.core.convert.support.ConversionServiceFactory;
+import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.core.convert.support.GenericConversionService;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
@@ -30,7 +46,7 @@ public class Spr7839Tests {
@Before
public void setUp() {
ConfigurableWebBindingInitializer binder = new ConfigurableWebBindingInitializer();
- GenericConversionService service = ConversionServiceFactory.createDefaultConversionService();
+ GenericConversionService service = new DefaultConversionService();
service.addConverter(new Converter<String, NestedBean>() {
public NestedBean convert(String source) {
return new NestedBean(source); | true |
Other | spring-projects | spring-framework | b4fea47d5cff9f3c85e62c233c2fe86b1d616592.json | Introduce FeatureSpecification support
Introduce FeatureSpecification interface and implementations
FeatureSpecification objects decouple the configuration of
spring container features from the concern of parsing XML
namespaces, allowing for reuse in code-based configuration
(see @Feature* annotations below).
* ComponentScanSpec
* TxAnnotationDriven
* MvcAnnotationDriven
* MvcDefaultServletHandler
* MvcResources
* MvcViewControllers
Refactor associated BeanDefinitionParsers to delegate to new impls above
The following BeanDefinitionParser implementations now deal only
with the concern of XML parsing. Validation is handled by their
corresponding FeatureSpecification object. Bean definition creation
and registration is handled by their corresponding
FeatureSpecificationExecutor type.
* ComponentScanBeanDefinitionParser
* AnnotationDrivenBeanDefinitionParser (tx)
* AnnotationDrivenBeanDefinitionParser (mvc)
* DefaultServletHandlerBeanDefinitionParser
* ResourcesBeanDefinitionParser
* ViewControllerBeanDefinitionParser
Update AopNamespaceUtils to decouple from XML (DOM API)
Methods necessary for executing TxAnnotationDriven specification
(and eventually, the AspectJAutoProxy specification) have been
added that accept boolean arguments for whether to proxy
target classes and whether to expose the proxy via threadlocal.
Methods that accepted and introspected DOM Element objects still
exist but have been deprecated.
Introduce @FeatureConfiguration classes and @Feature methods
Allow for creation and configuration of FeatureSpecification objects
at the user level. A companion for @Configuration classes allowing
for completely code-driven configuration of the Spring container.
See changes in ConfigurationClassPostProcessor for implementation
details.
See Feature*Tests for usage examples.
FeatureTestSuite in .integration-tests is a JUnit test suite designed
to aggregate all BDP and Feature* related tests for a convenient way
to confirm that Feature-related changes don't break anything.
Uncomment this test and execute from Eclipse / IDEA. Due to classpath
issues, this cannot be compiled by Ant/Ivy at the command line.
Introduce @FeatureAnnotation meta-annotation and @ComponentScan impl
@FeatureAnnotation provides an alternate mechanism for creating
and executing FeatureSpecification objects. See @ComponentScan
and its corresponding ComponentScanAnnotationParser implementation
for details. See ComponentScanAnnotationIntegrationTests for usage
examples
Introduce Default[Formatting]ConversionService implementations
Allows for convenient instantiation of ConversionService objects
containing defaults appropriate for most environments. Replaces
similar support originally in ConversionServiceFactory (which is now
deprecated). This change was justified by the need to avoid use
of FactoryBeans in @Configuration classes (such as
FormattingConversionServiceFactoryBean). It is strongly preferred
that users simply instantiate and configure the objects that underlie
our FactoryBeans. In the case of the ConversionService types, the
easiest way to do this is to create Default* subtypes. This also
follows convention with the rest of the framework.
Minor updates to util classes
All in service of changes above. See diffs for self-explanatory
details.
* BeanUtils
* ObjectUtils
* ReflectionUtils | org.springframework.web.servlet/src/test/resources/org/springframework/web/servlet/config/mvc-config-message-converters-defaults-off.xml | @@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:mvc="http://www.springframework.org/schema/mvc"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">
+
+ <mvc:annotation-driven>
+ <mvc:message-converters register-defaults="false">
+ <bean class="org.springframework.http.converter.StringHttpMessageConverter"/>
+ <bean class="org.springframework.http.converter.ResourceHttpMessageConverter"/>
+ </mvc:message-converters>
+ </mvc:annotation-driven>
+
+</beans> | true |
Other | spring-projects | spring-framework | b4fea47d5cff9f3c85e62c233c2fe86b1d616592.json | Introduce FeatureSpecification support
Introduce FeatureSpecification interface and implementations
FeatureSpecification objects decouple the configuration of
spring container features from the concern of parsing XML
namespaces, allowing for reuse in code-based configuration
(see @Feature* annotations below).
* ComponentScanSpec
* TxAnnotationDriven
* MvcAnnotationDriven
* MvcDefaultServletHandler
* MvcResources
* MvcViewControllers
Refactor associated BeanDefinitionParsers to delegate to new impls above
The following BeanDefinitionParser implementations now deal only
with the concern of XML parsing. Validation is handled by their
corresponding FeatureSpecification object. Bean definition creation
and registration is handled by their corresponding
FeatureSpecificationExecutor type.
* ComponentScanBeanDefinitionParser
* AnnotationDrivenBeanDefinitionParser (tx)
* AnnotationDrivenBeanDefinitionParser (mvc)
* DefaultServletHandlerBeanDefinitionParser
* ResourcesBeanDefinitionParser
* ViewControllerBeanDefinitionParser
Update AopNamespaceUtils to decouple from XML (DOM API)
Methods necessary for executing TxAnnotationDriven specification
(and eventually, the AspectJAutoProxy specification) have been
added that accept boolean arguments for whether to proxy
target classes and whether to expose the proxy via threadlocal.
Methods that accepted and introspected DOM Element objects still
exist but have been deprecated.
Introduce @FeatureConfiguration classes and @Feature methods
Allow for creation and configuration of FeatureSpecification objects
at the user level. A companion for @Configuration classes allowing
for completely code-driven configuration of the Spring container.
See changes in ConfigurationClassPostProcessor for implementation
details.
See Feature*Tests for usage examples.
FeatureTestSuite in .integration-tests is a JUnit test suite designed
to aggregate all BDP and Feature* related tests for a convenient way
to confirm that Feature-related changes don't break anything.
Uncomment this test and execute from Eclipse / IDEA. Due to classpath
issues, this cannot be compiled by Ant/Ivy at the command line.
Introduce @FeatureAnnotation meta-annotation and @ComponentScan impl
@FeatureAnnotation provides an alternate mechanism for creating
and executing FeatureSpecification objects. See @ComponentScan
and its corresponding ComponentScanAnnotationParser implementation
for details. See ComponentScanAnnotationIntegrationTests for usage
examples
Introduce Default[Formatting]ConversionService implementations
Allows for convenient instantiation of ConversionService objects
containing defaults appropriate for most environments. Replaces
similar support originally in ConversionServiceFactory (which is now
deprecated). This change was justified by the need to avoid use
of FactoryBeans in @Configuration classes (such as
FormattingConversionServiceFactoryBean). It is strongly preferred
that users simply instantiate and configure the objects that underlie
our FactoryBeans. In the case of the ConversionService types, the
easiest way to do this is to create Default* subtypes. This also
follows convention with the rest of the framework.
Minor updates to util classes
All in service of changes above. See diffs for self-explanatory
details.
* BeanUtils
* ObjectUtils
* ReflectionUtils | org.springframework.web/src/test/java/org/springframework/http/MediaTypeTests.java | @@ -1,5 +1,5 @@
/*
- * Copyright 2002-2010 the original author or authors.
+ * Copyright 2002-2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,18 +16,22 @@
package org.springframework.http;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Random;
-import static org.junit.Assert.*;
import org.junit.Test;
-
import org.springframework.core.convert.ConversionService;
-import org.springframework.core.convert.support.ConversionServiceFactory;
+import org.springframework.core.convert.support.DefaultConversionService;
/**
* @author Arjen Poutsma
@@ -490,7 +494,7 @@ public void sortByQualityUnrelated() {
@Test
public void testWithConversionService() {
- ConversionService conversionService = ConversionServiceFactory.createDefaultConversionService();
+ ConversionService conversionService = new DefaultConversionService();
assertTrue(conversionService.canConvert(String.class, MediaType.class));
MediaType mediaType = MediaType.parseMediaType("application/xml");
assertEquals(mediaType, conversionService.convert("application/xml", MediaType.class)); | true |
Other | spring-projects | spring-framework | b4fea47d5cff9f3c85e62c233c2fe86b1d616592.json | Introduce FeatureSpecification support
Introduce FeatureSpecification interface and implementations
FeatureSpecification objects decouple the configuration of
spring container features from the concern of parsing XML
namespaces, allowing for reuse in code-based configuration
(see @Feature* annotations below).
* ComponentScanSpec
* TxAnnotationDriven
* MvcAnnotationDriven
* MvcDefaultServletHandler
* MvcResources
* MvcViewControllers
Refactor associated BeanDefinitionParsers to delegate to new impls above
The following BeanDefinitionParser implementations now deal only
with the concern of XML parsing. Validation is handled by their
corresponding FeatureSpecification object. Bean definition creation
and registration is handled by their corresponding
FeatureSpecificationExecutor type.
* ComponentScanBeanDefinitionParser
* AnnotationDrivenBeanDefinitionParser (tx)
* AnnotationDrivenBeanDefinitionParser (mvc)
* DefaultServletHandlerBeanDefinitionParser
* ResourcesBeanDefinitionParser
* ViewControllerBeanDefinitionParser
Update AopNamespaceUtils to decouple from XML (DOM API)
Methods necessary for executing TxAnnotationDriven specification
(and eventually, the AspectJAutoProxy specification) have been
added that accept boolean arguments for whether to proxy
target classes and whether to expose the proxy via threadlocal.
Methods that accepted and introspected DOM Element objects still
exist but have been deprecated.
Introduce @FeatureConfiguration classes and @Feature methods
Allow for creation and configuration of FeatureSpecification objects
at the user level. A companion for @Configuration classes allowing
for completely code-driven configuration of the Spring container.
See changes in ConfigurationClassPostProcessor for implementation
details.
See Feature*Tests for usage examples.
FeatureTestSuite in .integration-tests is a JUnit test suite designed
to aggregate all BDP and Feature* related tests for a convenient way
to confirm that Feature-related changes don't break anything.
Uncomment this test and execute from Eclipse / IDEA. Due to classpath
issues, this cannot be compiled by Ant/Ivy at the command line.
Introduce @FeatureAnnotation meta-annotation and @ComponentScan impl
@FeatureAnnotation provides an alternate mechanism for creating
and executing FeatureSpecification objects. See @ComponentScan
and its corresponding ComponentScanAnnotationParser implementation
for details. See ComponentScanAnnotationIntegrationTests for usage
examples
Introduce Default[Formatting]ConversionService implementations
Allows for convenient instantiation of ConversionService objects
containing defaults appropriate for most environments. Replaces
similar support originally in ConversionServiceFactory (which is now
deprecated). This change was justified by the need to avoid use
of FactoryBeans in @Configuration classes (such as
FormattingConversionServiceFactoryBean). It is strongly preferred
that users simply instantiate and configure the objects that underlie
our FactoryBeans. In the case of the ConversionService types, the
easiest way to do this is to create Default* subtypes. This also
follows convention with the rest of the framework.
Minor updates to util classes
All in service of changes above. See diffs for self-explanatory
details.
* BeanUtils
* ObjectUtils
* ReflectionUtils | spring-framework-reference/src/mvc.xml | @@ -3368,8 +3368,10 @@ public class SimpleController {
</para>
<note>
<para>
- This list of HttpMessageConverters used can be replaced through
- the mvc:message-converters sub-element of mvc:annotation-driven.
+ You can provide your own HttpMessageConverters through the
+ mvc:message-converters sub-element of mvc:annotation-driven.
+ Message converters you provide will take precedence over the
+ ones registered by default.
</para>
</note>
</listitem> | true |
Other | spring-projects | spring-framework | b04987ccc37985eae59a2b5cc19a1c6ea5d6c844.json | Make ObjectUtils.addObjectToArray() generic | org.springframework.beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionBuilder.java | @@ -305,7 +305,7 @@ public BeanDefinitionBuilder addDependsOn(String beanName) {
this.beanDefinition.setDependsOn(new String[] {beanName});
}
else {
- String[] added = (String[]) ObjectUtils.addObjectToArray(this.beanDefinition.getDependsOn(), beanName);
+ String[] added = ObjectUtils.addObjectToArray(this.beanDefinition.getDependsOn(), beanName);
this.beanDefinition.setDependsOn(added);
}
return this; | true |
Other | spring-projects | spring-framework | b04987ccc37985eae59a2b5cc19a1c6ea5d6c844.json | Make ObjectUtils.addObjectToArray() generic | org.springframework.context/src/main/java/org/springframework/scripting/support/ScriptFactoryPostProcessor.java | @@ -334,12 +334,12 @@ protected void prepareScriptBeans(
ScriptFactory scriptFactory = this.scriptBeanFactory.getBean(scriptFactoryBeanName, ScriptFactory.class);
ScriptSource scriptSource =
getScriptSource(scriptFactoryBeanName, scriptFactory.getScriptSourceLocator());
- Class[] interfaces = scriptFactory.getScriptInterfaces();
+ Class<?>[] interfaces = scriptFactory.getScriptInterfaces();
- Class[] scriptedInterfaces = interfaces;
+ Class<?>[] scriptedInterfaces = interfaces;
if (scriptFactory.requiresConfigInterface() && !bd.getPropertyValues().isEmpty()) {
- Class configInterface = createConfigInterface(bd, interfaces);
- scriptedInterfaces = (Class[]) ObjectUtils.addObjectToArray(interfaces, configInterface);
+ Class<?> configInterface = createConfigInterface(bd, interfaces);
+ scriptedInterfaces = ObjectUtils.addObjectToArray(interfaces, configInterface);
}
BeanDefinition objectBd = createScriptedObjectBeanDefinition( | true |
Other | spring-projects | spring-framework | b04987ccc37985eae59a2b5cc19a1c6ea5d6c844.json | Make ObjectUtils.addObjectToArray() generic | org.springframework.core/src/main/java/org/springframework/util/ObjectUtils.java | @@ -122,22 +122,23 @@ public static boolean containsElement(Object[] array, Object element) {
}
/**
- * Append the given Object to the given array, returning a new array
- * consisting of the input array contents plus the given Object.
+ * Append the given object to the given array, returning a new array
+ * consisting of the input array contents plus the given object.
* @param array the array to append to (can be <code>null</code>)
- * @param obj the Object to append
+ * @param obj the object to append
* @return the new array (of the same component type; never <code>null</code>)
*/
- public static Object[] addObjectToArray(Object[] array, Object obj) {
- Class compType = Object.class;
+ public static <A,O extends A> A[] addObjectToArray(A[] array, O obj) {
+ Class<?> compType = Object.class;
if (array != null) {
compType = array.getClass().getComponentType();
}
else if (obj != null) {
compType = obj.getClass();
}
int newArrLength = (array != null ? array.length + 1 : 1);
- Object[] newArr = (Object[]) Array.newInstance(compType, newArrLength);
+ @SuppressWarnings("unchecked")
+ A[] newArr = (A[]) Array.newInstance(compType, newArrLength);
if (array != null) {
System.arraycopy(array, 0, newArr, 0, array.length);
} | true |
Other | spring-projects | spring-framework | b04987ccc37985eae59a2b5cc19a1c6ea5d6c844.json | Make ObjectUtils.addObjectToArray() generic | org.springframework.core/src/test/java/org/springframework/util/ObjectUtilsTests.java | @@ -119,7 +119,7 @@ public void testAddObjectToArraySunnyDay() {
public void testAddObjectToArrayWhenEmpty() {
String[] array = new String[0];
String newElement = "foo";
- Object[] newArray = ObjectUtils.addObjectToArray(array, newElement);
+ String[] newArray = ObjectUtils.addObjectToArray(array, newElement);
assertEquals(1, newArray.length);
assertEquals(newElement, newArray[0]);
}
@@ -128,7 +128,7 @@ public void testAddObjectToSingleNonNullElementArray() {
String existingElement = "foo";
String[] array = new String[] {existingElement};
String newElement = "bar";
- Object[] newArray = ObjectUtils.addObjectToArray(array, newElement);
+ String[] newArray = ObjectUtils.addObjectToArray(array, newElement);
assertEquals(2, newArray.length);
assertEquals(existingElement, newArray[0]);
assertEquals(newElement, newArray[1]);
@@ -137,15 +137,15 @@ public void testAddObjectToSingleNonNullElementArray() {
public void testAddObjectToSingleNullElementArray() {
String[] array = new String[] {null};
String newElement = "bar";
- Object[] newArray = ObjectUtils.addObjectToArray(array, newElement);
+ String[] newArray = ObjectUtils.addObjectToArray(array, newElement);
assertEquals(2, newArray.length);
assertEquals(null, newArray[0]);
assertEquals(newElement, newArray[1]);
}
public void testAddObjectToNullArray() throws Exception {
String newElement = "foo";
- Object[] newArray = ObjectUtils.addObjectToArray(null, newElement);
+ String[] newArray = ObjectUtils.addObjectToArray(null, newElement);
assertEquals(1, newArray.length);
assertEquals(newElement, newArray[0]);
} | true |
Other | spring-projects | spring-framework | b077d5ba975debea0f75b76441c562b0b54e4294.json | SPR-6678: fix poms for 3.0.1 | build-spring-framework/pom.xml | @@ -14,7 +14,7 @@
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<packaging>pom</packaging>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
<name>Spring Framework</name>
<description>Spring is a layered Java/J2EE application platform, based on code published in Expert
One-on-One J2EE Design and Development by Rod Johnson (Wrox, 2002). </description>
| true |
Other | spring-projects | spring-framework | b077d5ba975debea0f75b76441c562b0b54e4294.json | SPR-6678: fix poms for 3.0.1 | org.springframework.aop/pom.xml | @@ -4,12 +4,12 @@
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<packaging>jar</packaging>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
<parent>
<groupId>org.springframework</groupId>
<artifactId>spring-parent</artifactId>
<relativePath>../org.springframework.spring-parent</relativePath>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
</parent>
<dependencies> | true |
Other | spring-projects | spring-framework | b077d5ba975debea0f75b76441c562b0b54e4294.json | SPR-6678: fix poms for 3.0.1 | org.springframework.asm/pom.xml | @@ -4,12 +4,12 @@
<groupId>org.springframework</groupId>
<artifactId>spring-asm</artifactId>
<packaging>jar</packaging>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
<parent>
<groupId>org.springframework</groupId>
<artifactId>spring-parent</artifactId>
<relativePath>../org.springframework.spring-parent</relativePath>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
</parent>
| true |
Other | spring-projects | spring-framework | b077d5ba975debea0f75b76441c562b0b54e4294.json | SPR-6678: fix poms for 3.0.1 | org.springframework.aspects/pom.xml | @@ -4,12 +4,12 @@
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
<packaging>jar</packaging>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
<parent>
<groupId>org.springframework</groupId>
<artifactId>spring-parent</artifactId>
<relativePath>../org.springframework.spring-parent</relativePath>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
</parent>
<dependencies> | true |
Other | spring-projects | spring-framework | b077d5ba975debea0f75b76441c562b0b54e4294.json | SPR-6678: fix poms for 3.0.1 | org.springframework.beans/pom.xml | @@ -4,12 +4,12 @@
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<packaging>jar</packaging>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
<parent>
<groupId>org.springframework</groupId>
<artifactId>spring-parent</artifactId>
<relativePath>../org.springframework.spring-parent</relativePath>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
</parent>
<dependencies> | true |
Other | spring-projects | spring-framework | b077d5ba975debea0f75b76441c562b0b54e4294.json | SPR-6678: fix poms for 3.0.1 | org.springframework.context.support/pom.xml | @@ -4,12 +4,12 @@
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<packaging>jar</packaging>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
<parent>
<groupId>org.springframework</groupId>
<artifactId>spring-parent</artifactId>
<relativePath>../org.springframework.spring-parent</relativePath>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
</parent>
| true |
Other | spring-projects | spring-framework | b077d5ba975debea0f75b76441c562b0b54e4294.json | SPR-6678: fix poms for 3.0.1 | org.springframework.context/pom.xml | @@ -6,12 +6,12 @@
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<packaging>jar</packaging>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
<parent>
<groupId>org.springframework</groupId>
<artifactId>spring-parent</artifactId>
<relativePath>../org.springframework.spring-parent</relativePath>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
</parent>
<dependencies> | true |
Other | spring-projects | spring-framework | b077d5ba975debea0f75b76441c562b0b54e4294.json | SPR-6678: fix poms for 3.0.1 | org.springframework.core/pom.xml | @@ -6,12 +6,12 @@
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<packaging>jar</packaging>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
<parent>
<groupId>org.springframework</groupId>
<artifactId>spring-parent</artifactId>
<relativePath>../org.springframework.spring-parent</relativePath>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
</parent>
<dependencies> | true |
Other | spring-projects | spring-framework | b077d5ba975debea0f75b76441c562b0b54e4294.json | SPR-6678: fix poms for 3.0.1 | org.springframework.expression/pom.xml | @@ -4,12 +4,12 @@
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<packaging>jar</packaging>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
<parent>
<groupId>org.springframework</groupId>
<artifactId>spring-parent</artifactId>
<relativePath>../org.springframework.spring-parent</relativePath>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
</parent>
<dependencies> | true |
Other | spring-projects | spring-framework | b077d5ba975debea0f75b76441c562b0b54e4294.json | SPR-6678: fix poms for 3.0.1 | org.springframework.instrument.tomcat/pom.xml | @@ -4,12 +4,12 @@
<groupId>org.springframework</groupId>
<artifactId>spring-instrument-tomcat</artifactId>
<packaging>jar</packaging>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
<parent>
<groupId>org.springframework</groupId>
<artifactId>spring-parent</artifactId>
<relativePath>../org.springframework.spring-parent</relativePath>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
</parent>
<dependencies> | true |
Other | spring-projects | spring-framework | b077d5ba975debea0f75b76441c562b0b54e4294.json | SPR-6678: fix poms for 3.0.1 | org.springframework.instrument/pom.xml | @@ -4,12 +4,12 @@
<groupId>org.springframework</groupId>
<artifactId>spring-instrument</artifactId>
<packaging>jar</packaging>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
<parent>
<groupId>org.springframework</groupId>
<artifactId>spring-parent</artifactId>
<relativePath>../org.springframework.spring-parent</relativePath>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
</parent>
</project> | true |
Other | spring-projects | spring-framework | b077d5ba975debea0f75b76441c562b0b54e4294.json | SPR-6678: fix poms for 3.0.1 | org.springframework.integration-tests/pom.xml | @@ -4,7 +4,7 @@
<groupId>org.springframework</groupId>
<artifactId>spring-integration-tests</artifactId>
<packaging>jar</packaging>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.caucho</groupId> | true |
Other | spring-projects | spring-framework | b077d5ba975debea0f75b76441c562b0b54e4294.json | SPR-6678: fix poms for 3.0.1 | org.springframework.jdbc/pom.xml | @@ -4,12 +4,12 @@
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<packaging>jar</packaging>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
<parent>
<groupId>org.springframework</groupId>
<artifactId>spring-parent</artifactId>
<relativePath>../org.springframework.spring-parent</relativePath>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
</parent>
<dependencies>
<dependency> | true |
Other | spring-projects | spring-framework | b077d5ba975debea0f75b76441c562b0b54e4294.json | SPR-6678: fix poms for 3.0.1 | org.springframework.jms/pom.xml | @@ -4,12 +4,12 @@
<groupId>org.springframework</groupId>
<artifactId>spring-jms</artifactId>
<packaging>jar</packaging>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
<parent>
<groupId>org.springframework</groupId>
<artifactId>spring-parent</artifactId>
<relativePath>../org.springframework.spring-parent</relativePath>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
</parent>
<dependencies>
@@ -57,37 +57,37 @@
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
<optional>true</optional>
</dependency>
</dependencies> | true |
Other | spring-projects | spring-framework | b077d5ba975debea0f75b76441c562b0b54e4294.json | SPR-6678: fix poms for 3.0.1 | org.springframework.orm/pom.xml | @@ -6,12 +6,12 @@
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<packaging>jar</packaging>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
<parent>
<groupId>org.springframework</groupId>
<artifactId>spring-parent</artifactId>
<relativePath>../org.springframework.spring-parent</relativePath>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
</parent>
<dependencies>
<dependency> | true |
Other | spring-projects | spring-framework | b077d5ba975debea0f75b76441c562b0b54e4294.json | SPR-6678: fix poms for 3.0.1 | org.springframework.oxm/pom.xml | @@ -6,12 +6,12 @@
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<packaging>jar</packaging>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
<parent>
<groupId>org.springframework</groupId>
<artifactId>spring-parent</artifactId>
<relativePath>../org.springframework.spring-parent</relativePath>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
</parent>
<dependencies> | true |
Other | spring-projects | spring-framework | b077d5ba975debea0f75b76441c562b0b54e4294.json | SPR-6678: fix poms for 3.0.1 | org.springframework.spring-library/pom.xml | @@ -14,7 +14,7 @@
<groupId>org.springframework</groupId>
<artifactId>spring-library</artifactId>
<packaging>libd</packaging>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
<name>Spring Framework</name>
<description>Spring is a layered Java/J2EE application platform, based on code published in Expert
One-on-One J2EE Design and Development by Rod Johnson (Wrox, 2002). </description>
| true |
Other | spring-projects | spring-framework | b077d5ba975debea0f75b76441c562b0b54e4294.json | SPR-6678: fix poms for 3.0.1 | org.springframework.spring-parent/pom.xml | @@ -14,7 +14,7 @@
<artifactId>spring-parent</artifactId>
<packaging>pom</packaging>
<name>Spring Framework - Parent</name>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
<description>Spring Framework Parent</description>
<scm>
<url>https://fisheye.springframework.org/browse/spring-framework</url> | true |
Other | spring-projects | spring-framework | b077d5ba975debea0f75b76441c562b0b54e4294.json | SPR-6678: fix poms for 3.0.1 | org.springframework.test/pom.xml | @@ -4,12 +4,12 @@
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<packaging>jar</packaging>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
<parent>
<groupId>org.springframework</groupId>
<artifactId>spring-parent</artifactId>
<relativePath>../org.springframework.spring-parent</relativePath>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
</parent>
<dependencies> | true |
Other | spring-projects | spring-framework | b077d5ba975debea0f75b76441c562b0b54e4294.json | SPR-6678: fix poms for 3.0.1 | org.springframework.transaction/pom.xml | @@ -4,12 +4,12 @@
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<packaging>jar</packaging>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
<parent>
<groupId>org.springframework</groupId>
<artifactId>spring-parent</artifactId>
<relativePath>../org.springframework.spring-parent</relativePath>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
</parent>
<dependencies> | true |
Other | spring-projects | spring-framework | b077d5ba975debea0f75b76441c562b0b54e4294.json | SPR-6678: fix poms for 3.0.1 | org.springframework.web.portlet/pom.xml | @@ -4,12 +4,12 @@
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc-portlet</artifactId>
<packaging>jar</packaging>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
<parent>
<groupId>org.springframework</groupId>
<artifactId>spring-parent</artifactId>
<relativePath>../org.springframework.spring-parent</relativePath>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
</parent>
<dependencies> | true |
Other | spring-projects | spring-framework | b077d5ba975debea0f75b76441c562b0b54e4294.json | SPR-6678: fix poms for 3.0.1 | org.springframework.web.servlet/pom.xml | @@ -6,12 +6,12 @@
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<packaging>jar</packaging>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
<parent>
<groupId>org.springframework</groupId>
<artifactId>spring-parent</artifactId>
<relativePath>../org.springframework.spring-parent</relativePath>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
</parent>
<profiles> | true |
Other | spring-projects | spring-framework | b077d5ba975debea0f75b76441c562b0b54e4294.json | SPR-6678: fix poms for 3.0.1 | org.springframework.web.struts/pom.xml | @@ -6,12 +6,12 @@
<groupId>org.springframework</groupId>
<artifactId>spring-struts</artifactId>
<packaging>jar</packaging>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
<parent>
<groupId>org.springframework</groupId>
<artifactId>spring-parent</artifactId>
<relativePath>../org.springframework.spring-parent</relativePath>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
</parent>
<dependencies>
<dependency> | true |
Other | spring-projects | spring-framework | b077d5ba975debea0f75b76441c562b0b54e4294.json | SPR-6678: fix poms for 3.0.1 | org.springframework.web/pom.xml | @@ -6,12 +6,12 @@
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<packaging>jar</packaging>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
<parent>
<groupId>org.springframework</groupId>
<artifactId>spring-parent</artifactId>
<relativePath>../org.springframework.spring-parent</relativePath>
- <version>3.0.0.BUILD-SNAPSHOT</version>
+ <version>3.0.1.BUILD-SNAPSHOT</version>
</parent>
<dependencies> | true |
Other | spring-projects | spring-framework | 2fcab44de08bd09159fb7adea2531b16dea3e69b.json | remove addressed TODO | org.springframework.beans/src/main/java/org/springframework/beans/BeanWrapperImpl.java | @@ -1017,7 +1017,6 @@ else if (propValue instanceof Map) {
}
// Pass full property name and old value in here, since we want full
// conversion ability for map values.
- // TODO method parameter nesting level should be token.keys.length + 1
Object convertedMapValue = convertIfNecessary(
propertyName, oldValue, pv.getValue(), mapValueType,
PropertyTypeDescriptor.forNestedType(mapValueType, new MethodParameter(pd.getReadMethod(), -1, tokens.keys.length), pd)); | false |
Other | spring-projects | spring-framework | 8df6b86dd1efbb0a62be789e5b88897df5404148.json | ignore failing test | org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/annotation/Spr7839Tests.java | @@ -101,6 +101,7 @@ public void arrayOfLists() throws Exception {
}
@Test
+ @Ignore
public void map() throws Exception {
request.setRequestURI("/nested/map");
request.addParameter("nested.map['apple'].foo", "bar"); | false |
Other | spring-projects | spring-framework | a7293d2961723d2081c3195b38240b4c22703e22.json | Introduce ApplicationContextInitializer interface
Designed primarily for use in conjunction with web applications
to provide a convenient mechanism for configuring the container
programmatically.
ApplicationContextInitializer implementations are specified through the
new "contextInitializerClasses" servlet context parameter, then detected
and invoked by ContextLoader in its customizeContext() method.
In any case, the semantics of ApplicationContextInitializer's
initialize(ConfigurableApplicationContext) method require that
invocation occur *prior* to refreshing the application context.
ACI implementations may also implement Ordered/PriorityOrdered and
ContextLoader will sort instances appropriately prior to invocation.
Specifically, this new support provides a straightforward way to
programmatically access the container's Environment for the purpose
of adding, removing or otherwise manipulating PropertySource objects.
See Javadoc for further details.
Also note that ApplicationContextInitializer semantics overlap to
some degree with Servlet 3.0's notion of ServletContainerInitializer
classes. As Spring 3.1 development progresses, we'll likely see
these two come together and further influence one another. | org.springframework.context/src/main/java/org/springframework/context/ApplicationContextInitializer.java | @@ -0,0 +1,40 @@
+/*
+ * Copyright 2002-2011 the original author or authors.
+ *
+ * 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.springframework.context;
+
+/**
+ * Callback interface for initializing a Spring {@link ConfigurableApplicationContext}
+ * prior to being {@linkplain ConfigurableApplicationContext#refresh() refreshed}.
+ *
+ * <p>{@code ApplicationContextInitializer} processors are encouraged to detect
+ * whether Spring's {@link org.springframework.core.Ordered Ordered} or
+ * {@link org.springframework.core.PriorityOrdered PriorityOrdered} interfaces are also
+ * implemented and sort instances accordingly if so prior to invocation.
+ *
+ * @author Chris Beams
+ * @since 3.1
+ * @see org.springframework.web.context.ContextLoader#customizeContext
+ */
+public interface ApplicationContextInitializer<C extends ConfigurableApplicationContext> {
+
+ /**
+ * Initialize the given application context.
+ * @param applicationContext the application to configure
+ */
+ void initialize(C applicationContext);
+
+} | true |
Other | spring-projects | spring-framework | a7293d2961723d2081c3195b38240b4c22703e22.json | Introduce ApplicationContextInitializer interface
Designed primarily for use in conjunction with web applications
to provide a convenient mechanism for configuring the container
programmatically.
ApplicationContextInitializer implementations are specified through the
new "contextInitializerClasses" servlet context parameter, then detected
and invoked by ContextLoader in its customizeContext() method.
In any case, the semantics of ApplicationContextInitializer's
initialize(ConfigurableApplicationContext) method require that
invocation occur *prior* to refreshing the application context.
ACI implementations may also implement Ordered/PriorityOrdered and
ContextLoader will sort instances appropriately prior to invocation.
Specifically, this new support provides a straightforward way to
programmatically access the container's Environment for the purpose
of adding, removing or otherwise manipulating PropertySource objects.
See Javadoc for further details.
Also note that ApplicationContextInitializer semantics overlap to
some degree with Servlet 3.0's notion of ServletContainerInitializer
classes. As Spring 3.1 development progresses, we'll likely see
these two come together and further influence one another. | org.springframework.core/src/main/java/org/springframework/core/env/PropertySource.java | @@ -63,6 +63,18 @@ public PropertySource(String name, T source) {
this.source = source;
}
+ /**
+ * Create a new {@code PropertySource} with the given name and with a new {@code Object}
+ * instance as the underlying source.
+ * <p>Often useful in testing scenarios when creating
+ * anonymous implementations that never query an actual source, but rather return
+ * hard-coded values.
+ */
+ @SuppressWarnings("unchecked")
+ public PropertySource(String name) {
+ this(name, (T) new Object());
+ }
+
/**
* Return the name of this {@code PropertySource}
*/ | true |
Other | spring-projects | spring-framework | a7293d2961723d2081c3195b38240b4c22703e22.json | Introduce ApplicationContextInitializer interface
Designed primarily for use in conjunction with web applications
to provide a convenient mechanism for configuring the container
programmatically.
ApplicationContextInitializer implementations are specified through the
new "contextInitializerClasses" servlet context parameter, then detected
and invoked by ContextLoader in its customizeContext() method.
In any case, the semantics of ApplicationContextInitializer's
initialize(ConfigurableApplicationContext) method require that
invocation occur *prior* to refreshing the application context.
ACI implementations may also implement Ordered/PriorityOrdered and
ContextLoader will sort instances appropriately prior to invocation.
Specifically, this new support provides a straightforward way to
programmatically access the container's Environment for the purpose
of adding, removing or otherwise manipulating PropertySource objects.
See Javadoc for further details.
Also note that ApplicationContextInitializer semantics overlap to
some degree with Servlet 3.0's notion of ServletContainerInitializer
classes. As Spring 3.1 development progresses, we'll likely see
these two come together and further influence one another. | org.springframework.web.servlet/src/test/java/org/springframework/web/context/ContextLoaderTests.java | @@ -1,5 +1,5 @@
/*
- * Copyright 2002-2010 the original author or authors.
+ * Copyright 2002-2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,15 +16,24 @@
package org.springframework.web.context;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.io.FileNotFoundException;
import java.io.IOException;
+
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
-import static org.junit.Assert.*;
import org.junit.Test;
-
import org.springframework.beans.BeansException;
import org.springframework.beans.TestBean;
import org.springframework.beans.factory.BeanCreationException;
@@ -33,9 +42,14 @@
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextException;
+import org.springframework.context.ApplicationContextInitializer;
+import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.springframework.core.env.ConfigurableEnvironment;
+import org.springframework.core.env.PropertySource;
import org.springframework.mock.web.MockServletConfig;
import org.springframework.mock.web.MockServletContext;
+import org.springframework.util.StringUtils;
import org.springframework.web.context.support.XmlWebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;
import org.springframework.web.servlet.SimpleWebApplicationContext;
@@ -100,6 +114,39 @@ protected void customizeContext(ServletContext servletContext, ConfigurableWebAp
assertEquals("customizeContext() should have been called.", expectedContents, buffer.toString());
}
+ @Test
+ public void testContextLoaderListenerWithRegisteredContextConfigurer() {
+ MockServletContext sc = new MockServletContext("");
+ sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM,
+ "org/springframework/web/context/WEB-INF/ContextLoaderTests-acc-context.xml");
+ sc.addInitParameter(ContextLoader.CONTEXT_INITIALIZER_CLASSES_PARAM,
+ StringUtils.arrayToCommaDelimitedString(
+ new Object[]{TestContextInitializer.class.getName(), TestWebContextInitializer.class.getName()}));
+ ContextLoaderListener listener = new ContextLoaderListener();
+ listener.contextInitialized(new ServletContextEvent(sc));
+ WebApplicationContext wac = ContextLoaderListener.getCurrentWebApplicationContext();
+ TestBean testBean = wac.getBean(TestBean.class);
+ assertThat(testBean.getName(), equalTo("testName"));
+ assertThat(wac.getServletContext().getAttribute("initialized"), notNullValue());
+ }
+
+ @Test
+ public void testContextLoaderListenerWithUnkownContextConfigurer() {
+ MockServletContext sc = new MockServletContext("");
+ // config file doesn't matter. just a placeholder
+ sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM,
+ "/org/springframework/web/context/WEB-INF/empty-context.xml");
+ sc.addInitParameter(ContextLoader.CONTEXT_INITIALIZER_CLASSES_PARAM,
+ StringUtils.arrayToCommaDelimitedString(new Object[]{UnknownContextInitializer.class.getName()}));
+ ContextLoaderListener listener = new ContextLoaderListener();
+ try {
+ listener.contextInitialized(new ServletContextEvent(sc));
+ fail("expected exception");
+ } catch (IllegalArgumentException ex) {
+ assertTrue(ex.getMessage().contains("not assignable"));
+ }
+ }
+
@Test
public void testContextLoaderWithDefaultContextAndParent() throws Exception {
MockServletContext sc = new MockServletContext("");
@@ -257,4 +304,33 @@ public void refresh() throws BeansException {
}
}
+ private static class TestContextInitializer implements ApplicationContextInitializer<ConfigurableApplicationContext> {
+ public void initialize(ConfigurableApplicationContext applicationContext) {
+ ConfigurableEnvironment environment = applicationContext.getEnvironment();
+ environment.getPropertySources().addFirst(new PropertySource<Object>("testPropertySource") {
+ @Override
+ public Object getProperty(String key) {
+ return "name".equals(key) ? "testName" : null;
+ }
+ });
+ }
+ }
+
+ private static class TestWebContextInitializer implements ApplicationContextInitializer<ConfigurableWebApplicationContext> {
+ public void initialize(ConfigurableWebApplicationContext applicationContext) {
+ ServletContext ctx = applicationContext.getServletContext(); // type-safe access to servlet-specific methods
+ ctx.setAttribute("initialized", true);
+ }
+ }
+
+ private static interface UnknownApplicationContext extends ConfigurableApplicationContext {
+ void unheardOf();
+ }
+
+ private static class UnknownContextInitializer implements ApplicationContextInitializer<UnknownApplicationContext> {
+ public void initialize(UnknownApplicationContext applicationContext) {
+ applicationContext.unheardOf();
+ }
+ }
+
} | true |
Other | spring-projects | spring-framework | a7293d2961723d2081c3195b38240b4c22703e22.json | Introduce ApplicationContextInitializer interface
Designed primarily for use in conjunction with web applications
to provide a convenient mechanism for configuring the container
programmatically.
ApplicationContextInitializer implementations are specified through the
new "contextInitializerClasses" servlet context parameter, then detected
and invoked by ContextLoader in its customizeContext() method.
In any case, the semantics of ApplicationContextInitializer's
initialize(ConfigurableApplicationContext) method require that
invocation occur *prior* to refreshing the application context.
ACI implementations may also implement Ordered/PriorityOrdered and
ContextLoader will sort instances appropriately prior to invocation.
Specifically, this new support provides a straightforward way to
programmatically access the container's Environment for the purpose
of adding, removing or otherwise manipulating PropertySource objects.
See Javadoc for further details.
Also note that ApplicationContextInitializer semantics overlap to
some degree with Servlet 3.0's notion of ServletContainerInitializer
classes. As Spring 3.1 development progresses, we'll likely see
these two come together and further influence one another. | org.springframework.web.servlet/src/test/java/org/springframework/web/context/WEB-INF/ContextLoaderTests-acc-context.xml | @@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+ <bean class="org.springframework.beans.TestBean">
+ <constructor-arg value="${name}"/>
+ </bean>
+
+ <bean class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer"/>
+
+</beans> | true |
Other | spring-projects | spring-framework | a7293d2961723d2081c3195b38240b4c22703e22.json | Introduce ApplicationContextInitializer interface
Designed primarily for use in conjunction with web applications
to provide a convenient mechanism for configuring the container
programmatically.
ApplicationContextInitializer implementations are specified through the
new "contextInitializerClasses" servlet context parameter, then detected
and invoked by ContextLoader in its customizeContext() method.
In any case, the semantics of ApplicationContextInitializer's
initialize(ConfigurableApplicationContext) method require that
invocation occur *prior* to refreshing the application context.
ACI implementations may also implement Ordered/PriorityOrdered and
ContextLoader will sort instances appropriately prior to invocation.
Specifically, this new support provides a straightforward way to
programmatically access the container's Environment for the purpose
of adding, removing or otherwise manipulating PropertySource objects.
See Javadoc for further details.
Also note that ApplicationContextInitializer semantics overlap to
some degree with Servlet 3.0's notion of ServletContainerInitializer
classes. As Spring 3.1 development progresses, we'll likely see
these two come together and further influence one another. | org.springframework.web.servlet/src/test/java/org/springframework/web/context/WEB-INF/empty-context.xml | @@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+</beans> | true |
Other | spring-projects | spring-framework | a7293d2961723d2081c3195b38240b4c22703e22.json | Introduce ApplicationContextInitializer interface
Designed primarily for use in conjunction with web applications
to provide a convenient mechanism for configuring the container
programmatically.
ApplicationContextInitializer implementations are specified through the
new "contextInitializerClasses" servlet context parameter, then detected
and invoked by ContextLoader in its customizeContext() method.
In any case, the semantics of ApplicationContextInitializer's
initialize(ConfigurableApplicationContext) method require that
invocation occur *prior* to refreshing the application context.
ACI implementations may also implement Ordered/PriorityOrdered and
ContextLoader will sort instances appropriately prior to invocation.
Specifically, this new support provides a straightforward way to
programmatically access the container's Environment for the purpose
of adding, removing or otherwise manipulating PropertySource objects.
See Javadoc for further details.
Also note that ApplicationContextInitializer semantics overlap to
some degree with Servlet 3.0's notion of ServletContainerInitializer
classes. As Spring 3.1 development progresses, we'll likely see
these two come together and further influence one another. | org.springframework.web/src/main/java/org/springframework/web/context/ContextLoader.java | @@ -1,5 +1,5 @@
/*
- * Copyright 2002-2010 the original author or authors.
+ * Copyright 2002-2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,24 +17,33 @@
package org.springframework.web.context;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
+
import javax.servlet.ServletContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.access.BeanFactoryLocator;
import org.springframework.beans.factory.access.BeanFactoryReference;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextException;
+import org.springframework.context.ApplicationContextInitializer;
+import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.access.ContextSingletonBeanFactoryLocator;
+import org.springframework.core.GenericTypeResolver;
+import org.springframework.core.OrderComparator;
+import org.springframework.core.Ordered;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.support.PropertiesLoaderUtils;
+import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.ObjectUtils;
+import org.springframework.util.StringUtils;
/**
* Performs the actual initialization work for the root application context.
@@ -78,14 +87,23 @@ public class ContextLoader {
/**
* Config param for the root WebApplicationContext implementation class to
- * use: "<code>contextClass</code>"
+ * use: {@value}
+ * @see #determineContextClass(ServletContext)
+ * @see #createWebApplicationContext(ServletContext, ApplicationContext)
*/
public static final String CONTEXT_CLASS_PARAM = "contextClass";
/**
- * Name of servlet context parameter (i.e., "<code>contextConfigLocation</code>")
- * that can specify the config location for the root context, falling back
- * to the implementation's default otherwise.
+ * Config param for which {@link ApplicationContextInitializer} classes to use
+ * for initializing the web application context: {@value}
+ * @see #customizeContext(ServletContext, ConfigurableWebApplicationContext)
+ */
+ public static final String CONTEXT_INITIALIZER_CLASSES_PARAM = "contextInitializerClasses";
+
+ /**
+ * Name of servlet context parameter (i.e., {@value}) that can specify the
+ * config location for the root context, falling back to the implementation's
+ * default otherwise.
* @see org.springframework.web.context.support.XmlWebApplicationContext#DEFAULT_CONFIG_LOCATION
*/
public static final String CONFIG_LOCATION_PARAM = "contextConfigLocation";
@@ -308,18 +326,73 @@ protected Class<?> determineContextClass(ServletContext servletContext) {
}
}
+ /**
+ * Return the {@link ApplicationContextInitializer} implementation classes to use
+ * if any have been specified by {@link #CONTEXT_INITIALIZER_CLASSES_PARAM}.
+ * @param servletContext current servlet context
+ * @see #CONTEXT_INITIALIZER_CLASSES_PARAM
+ */
+ @SuppressWarnings("unchecked")
+ protected List<Class<ApplicationContextInitializer<ConfigurableApplicationContext>>>
+ determineContextInitializerClasses(ServletContext servletContext) {
+ String classNames = servletContext.getInitParameter(CONTEXT_INITIALIZER_CLASSES_PARAM);
+ List<Class<ApplicationContextInitializer<ConfigurableApplicationContext>>> classes =
+ new ArrayList<Class<ApplicationContextInitializer<ConfigurableApplicationContext>>>();
+ if (classNames != null) {
+ for (String className : StringUtils.tokenizeToStringArray(classNames, ",")) {
+ try {
+ Class<?> clazz = ClassUtils.forName(className, ClassUtils.getDefaultClassLoader());
+ Assert.isAssignable(ApplicationContextInitializer.class, clazz,
+ "class [" + className + "] must implement ApplicationContextInitializer");
+ classes.add((Class<ApplicationContextInitializer<ConfigurableApplicationContext>>)clazz);
+ }
+ catch (ClassNotFoundException ex) {
+ throw new ApplicationContextException(
+ "Failed to load context configurer class [" + className + "]", ex);
+ }
+ }
+ }
+ return classes;
+ }
+
/**
* Customize the {@link ConfigurableWebApplicationContext} created by this
* ContextLoader after config locations have been supplied to the context
* but before the context is <em>refreshed</em>.
- * <p>The default implementation is empty but can be overridden in subclasses
- * to customize the application context.
+ * <p>The default implementation {@linkplain #determineContextInitializerClasses(ServletContext)
+ * determines} what (if any) context initializer classes have been specified through
+ * {@linkplain #CONTEXT_INITIALIZER_CLASSES_PARAM context init parameters} and
+ * {@linkplain ApplicationContextInitializer#initialize invokes each} with the
+ * given web application context.
+ * <p>Any {@link Ordered} {@code ApplicationContextInitializer} will be sorted
+ * appropriately.
* @param servletContext the current servlet context
* @param applicationContext the newly created application context
* @see #createWebApplicationContext(ServletContext, ApplicationContext)
+ * @see #CONTEXT_INITIALIZER_CLASSES_PARAM
+ * @see ApplicationContextInitializer#initialize(ConfigurableApplicationContext)
*/
- protected void customizeContext(
- ServletContext servletContext, ConfigurableWebApplicationContext applicationContext) {
+ protected void customizeContext(ServletContext servletContext, ConfigurableWebApplicationContext applicationContext) {
+ List<ApplicationContextInitializer<ConfigurableApplicationContext>> initializerInstances =
+ new ArrayList<ApplicationContextInitializer<ConfigurableApplicationContext>>();
+
+ for (Class<ApplicationContextInitializer<ConfigurableApplicationContext>> initializerClass :
+ determineContextInitializerClasses(servletContext)) {
+ Class<?> contextClass = applicationContext.getClass();
+ Class<?> initializerContextClass =
+ GenericTypeResolver.resolveTypeArgument(initializerClass, ApplicationContextInitializer.class);
+ Assert.isAssignable(initializerContextClass, contextClass, String.format(
+ "Could not add context initializer [%s] as its generic parameter [%s] " +
+ "is not assignable from the type of application context used by this " +
+ "context loader [%s]", initializerClass.getName(), initializerContextClass, contextClass));
+ initializerInstances.add(BeanUtils.instantiateClass(initializerClass));
+ }
+
+ OrderComparator.sort(initializerInstances);
+
+ for (ApplicationContextInitializer<ConfigurableApplicationContext> initializer : initializerInstances) {
+ initializer.initialize(applicationContext);
+ }
}
/** | true |
Other | spring-projects | spring-framework | 7f8ede14077189114c5040da9192b31ff01475db.json | Remove dead code
* removed registerStandardBeanFactoryPostProcessors() methods
* removed commented-out test from PropertyResourceConfigurerTests | org.springframework.beans/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java | @@ -800,39 +800,6 @@ public void testPreferencesPlaceholderConfigurerWithPathInPlaceholder() {
Preferences.systemRoot().node("mySystemPath/mypath").remove("myName");
}
- /* TODO SPR-7508: uncomment after PropertySourcesPlaceholderConfigurer implementation
- @Test
- public void testPreferencesPlaceholderConfigurerWithCustomPropertiesInEnvironment() {
- factory.registerBeanDefinition("tb",
- genericBeanDefinition(TestBean.class)
- .addPropertyValue("name", "${mypath/myName}")
- .addPropertyValue("age", "${myAge}")
- .addPropertyValue("touchy", "${myotherpath/myTouchy}")
- .getBeanDefinition());
-
- Properties props = new Properties();
- props.put("myAge", "99");
- factory.getEnvironment().getPropertySources().add(new PropertiesPropertySource("localProps", props));
-
- PreferencesPlaceholderConfigurer ppc = new PreferencesPlaceholderConfigurer();
- ppc.setSystemTreePath("mySystemPath");
- ppc.setUserTreePath("myUserPath");
- Preferences.systemRoot().node("mySystemPath").node("mypath").put("myName", "myNameValue");
- Preferences.systemRoot().node("mySystemPath/myotherpath").put("myTouchy", "myTouchyValue");
- Preferences.userRoot().node("myUserPath/myotherpath").put("myTouchy", "myOtherTouchyValue");
- ppc.afterPropertiesSet();
- ppc.postProcessBeanFactory(factory);
-
- TestBean tb = (TestBean) factory.getBean("tb");
- assertEquals("myNameValue", tb.getName());
- assertEquals(99, tb.getAge());
- assertEquals("myOtherTouchyValue", tb.getTouchy());
- Preferences.userRoot().node("myUserPath/myotherpath").remove("myTouchy");
- Preferences.systemRoot().node("mySystemPath/myotherpath").remove("myTouchy");
- Preferences.systemRoot().node("mySystemPath/mypath").remove("myName");
- }
- */
-
private static class ConvertingOverrideConfigurer extends PropertyOverrideConfigurer {
| true |
Other | spring-projects | spring-framework | 7f8ede14077189114c5040da9192b31ff01475db.json | Remove dead code
* removed registerStandardBeanFactoryPostProcessors() methods
* removed commented-out test from PropertyResourceConfigurerTests | org.springframework.context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java | @@ -667,15 +667,6 @@ private void invokeBeanFactoryPostProcessors(
}
}
- /**
- * Common location for subclasses to call and receive registration of standard
- * {@link BeanFactoryPostProcessor} bean definitions.
- *
- * @param registry subclass BeanDefinitionRegistry
- */
- protected void registerStandardBeanFactoryPostProcessors(BeanDefinitionRegistry registry) {
- }
-
/**
* Instantiate and invoke all registered BeanPostProcessor beans,
* respecting explicit order if given. | true |
Other | spring-projects | spring-framework | 7f8ede14077189114c5040da9192b31ff01475db.json | Remove dead code
* removed registerStandardBeanFactoryPostProcessors() methods
* removed commented-out test from PropertyResourceConfigurerTests | org.springframework.context/src/main/java/org/springframework/context/support/AbstractRefreshableApplicationContext.java | @@ -218,7 +218,6 @@ protected void customizeBeanFactory(DefaultListableBeanFactory beanFactory) {
}
beanFactory.setParameterNameDiscoverer(new LocalVariableTableParameterNameDiscoverer());
beanFactory.setAutowireCandidateResolver(new QualifierAnnotationAutowireCandidateResolver());
- registerStandardBeanFactoryPostProcessors(beanFactory);
}
/** | true |
Other | spring-projects | spring-framework | 7f8ede14077189114c5040da9192b31ff01475db.json | Remove dead code
* removed registerStandardBeanFactoryPostProcessors() methods
* removed commented-out test from PropertyResourceConfigurerTests | org.springframework.context/src/main/java/org/springframework/context/support/GenericApplicationContext.java | @@ -103,7 +103,6 @@ public GenericApplicationContext() {
this.beanFactory = new DefaultListableBeanFactory();
this.beanFactory.setParameterNameDiscoverer(new LocalVariableTableParameterNameDiscoverer());
this.beanFactory.setAutowireCandidateResolver(new QualifierAnnotationAutowireCandidateResolver());
- registerStandardBeanFactoryPostProcessors(this.beanFactory);
}
/** | true |
Other | spring-projects | spring-framework | 7c4582b4b320c6233be688833a6dfc8cd7c1a2f6.json | Update build instructions in readme | build-spring-framework/readme.txt | @@ -1,27 +1,42 @@
-This is where the master build that creates releases of Spring Framework resides. The build system is based on spring-build, which is linked in using an SVN external to https://src.springframework.org/svn/spring-build.
+This is where the master build that creates releases of Spring Framework resides.
+The build system is based on spring-build, which is linked in using an SVN
+external to https://src.springframework.org/svn/spring-build.
+
+Build Pre-requisites:
+- javac 1.6 or > must be in your system path
+- ant 1.7 or > must be in your system path
+- set ANT_OPTS as follows (to avoid out of memory errors):
+ ANT_OPTS="-XX:MaxPermSize=1024m -Xmx1024m -Dtest.vm.args='-XX:MaxPermSize=512m -Xmx1024m'"
USERS
- To build all Spring Framework projects, including samples:
1. From this directory, run:
ant
-
-Build Pre-requisites:
-- javac 1.6 or > must be in your system path
-- ant 1.7 or > must be in your system path
+
+- To install the built artifacts into your local Maven cache:
+
+ 1. From this directory, run:
+ ant install-maven
+
+- For a complete tutorial, see:
+
+ http://blog.springsource.com/2009/03/03/building-spring-3
+
DEVELOPERS
- To build a new Spring Framework distribution for release:
- 1. Update the files containing the version number to reflect the new release version, if necessary.
-
+ 1. Update the files containing the version number to reflect the new release
+ version, if necessary.
+
build.properties
build-spring-framework/resources/readme.txt
spring-framework/src/spring-framework-reference.xml
2. From this directory, run:
-
+
ant jar package
-
+
The release archive will be created and placed in:
- target/artifacts
\ No newline at end of file
+ target/artifacts | true |
Other | spring-projects | spring-framework | 7c4582b4b320c6233be688833a6dfc8cd7c1a2f6.json | Update build instructions in readme | build-spring-framework/resources/readme.txt | @@ -1,4 +1,4 @@
-SPRING FRAMEWORK 3.0.5 (October 2010)
+SPRING FRAMEWORK 3.1 M1 (January 2011)
-------------------------------------
http://www.springframework.org
| true |
Other | spring-projects | spring-framework | 6fcca3cd939af78b83bc80cd295996df2d198b81.json | accept Set<?> instead of Set<Object> (SPR-6742) | org.springframework.context/src/main/java/org/springframework/context/support/ConversionServiceFactoryBean.java | @@ -1,5 +1,5 @@
/*
- * Copyright 2002-2009 the original author or authors.
+ * Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,7 +35,7 @@
*/
public class ConversionServiceFactoryBean implements FactoryBean<ConversionService>, InitializingBean {
- private Set<Object> converters;
+ private Set<?> converters;
private GenericConversionService conversionService;
@@ -46,7 +46,7 @@ public class ConversionServiceFactoryBean implements FactoryBean<ConversionServi
* {@link org.springframework.core.convert.converter.ConverterFactory},
* or {@link org.springframework.core.convert.converter.GenericConverter}.
*/
- public void setConverters(Set<Object> converters) {
+ public void setConverters(Set<?> converters) {
this.converters = converters;
}
| true |
Other | spring-projects | spring-framework | 6fcca3cd939af78b83bc80cd295996df2d198b81.json | accept Set<?> instead of Set<Object> (SPR-6742) | org.springframework.context/src/main/java/org/springframework/format/support/FormattingConversionServiceFactoryBean.java | @@ -1,5 +1,5 @@
/*
- * Copyright 2002-2009 the original author or authors.
+ * Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -51,7 +51,7 @@
private static final boolean jodaTimePresent = ClassUtils.isPresent(
"org.joda.time.DateTime", FormattingConversionService.class.getClassLoader());
- private Set<Object> converters;
+ private Set<?> converters;
private FormattingConversionService conversionService;
@@ -62,7 +62,7 @@
* {@link org.springframework.core.convert.converter.ConverterFactory},
* or {@link org.springframework.core.convert.converter.GenericConverter}.
*/
- public void setConverters(Set<Object> converters) {
+ public void setConverters(Set<?> converters) {
this.converters = converters;
}
| true |
Other | spring-projects | spring-framework | 6fcca3cd939af78b83bc80cd295996df2d198b81.json | accept Set<?> instead of Set<Object> (SPR-6742) | org.springframework.core/src/main/java/org/springframework/core/convert/support/ConversionServiceFactory.java | @@ -1,5 +1,5 @@
/*
- * Copyright 2002-2009 the original author or authors.
+ * Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -90,7 +90,7 @@ public static void addDefaultConverters(GenericConversionService conversionServi
* {@link ConverterFactory}, or {@link GenericConverter}
* @param registry the target registry to register with
*/
- public static void registerConverters(Set<Object> converters, ConverterRegistry registry) {
+ public static void registerConverters(Set<?> converters, ConverterRegistry registry) {
if (converters != null) {
for (Object converter : converters) {
if (converter instanceof GenericConverter) { | true |
Other | spring-projects | spring-framework | 35517b62a0139855e70c926739039ea7265f4b16.json | Change groovy dependency to 1.6.3 to match ANT/ivy | org.springframework.context/pom.xml | @@ -101,8 +101,8 @@
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
- <artifactId>groovy</artifactId>
- <version>1.7-beta-1</version>
+ <artifactId>groovy-all</artifactId>
+ <version>1.6.3</version>
<optional>true</optional>
</dependency>
<dependency> | false |
Other | spring-projects | spring-framework | 613b4d182b23b474db4e43257cf75ef8454e6bdf.json | avoid potential NPE (SPR-6300) | org.springframework.test/src/main/java/org/springframework/test/web/ModelAndViewAssert.java | @@ -1,5 +1,5 @@
/*
- * Copyright 2002-2008 the original author or authors.
+ * Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@
import java.util.Map;
import java.util.Set;
+import org.springframework.util.ObjectUtils;
import org.springframework.web.servlet.ModelAndView;
/**
@@ -180,8 +181,8 @@ public static void assertSortAndCompareListModelAttribute(
*/
public static void assertViewName(ModelAndView mav, String expectedName) {
assertCondition(mav != null, "ModelAndView is null");
- assertCondition(expectedName.equals(mav.getViewName()), "View name is not equal to '" + expectedName +
- "' but was '" + mav.getViewName() + "'");
+ assertCondition(ObjectUtils.nullSafeEquals(expectedName, mav.getViewName()),
+ "View name is not equal to '" + expectedName + "' but was '" + mav.getViewName() + "'");
}
| false |
Other | spring-projects | spring-framework | d8245c800bd8be235cbe9b363d4f6fe7dc4a5e77.json | Add minimal doc for JSR 330 support. | spring-framework-reference/src/beans.xml | @@ -1077,11 +1077,11 @@ public class ExampleBean {
properties themselves are not set until the bean <emphasis>is actually
created</emphasis>. Beans that are singleton-scoped and set to be
pre-instantiated (the default) are created when the container is
- created. Scopes are defined in <xref
- linkend="beans-factory-scopes" /> Otherwise, the bean is created only
- when it is requested. Creation of a bean potentially causes a graph of
- beans to be created, as the bean's dependencies and its dependencies'
- dependencies (and so on) are created and assigned.</para>
+ created. Scopes are defined in <xref linkend="beans-factory-scopes" />
+ Otherwise, the bean is created only when it is requested. Creation of
+ a bean potentially causes a graph of beans to be created, as the
+ bean's dependencies and its dependencies' dependencies (and so on) are
+ created and assigned.</para>
<sidebar>
<title>Circular dependencies</title>
@@ -2232,7 +2232,8 @@ support=support@example.co.uk</programlisting>
<para>If you use Java 5 and thus have access to source-level
annotations, you may find <literal><xref
- linkend="metadata-annotations-required" /></literal> to be of interest.</para>
+ linkend="metadata-annotations-required" /></literal> to be of
+ interest.</para>
</section>
<section id="beans-factory-method-injection">
@@ -2566,13 +2567,16 @@ public class ReplacementComputeValue implements MethodReplacer {
</tbody>
</tgroup>
</table>
+
<note>
<title>Thread-scoped beans</title>
- <para>As of Spring 3.0, a <emphasis>thread scope</emphasis> is available, but is
- not registered by default. For more information, see the documentation for
- <ulink url="http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/context/support/SimpleThreadScope.html">SimpleThreadScope</ulink>.
+
+ <para>As of Spring 3.0, a <emphasis>thread scope</emphasis> is
+ available, but is not registered by default. For more information, see
+ the documentation for <ulink
+ url="http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/context/support/SimpleThreadScope.html">SimpleThreadScope</ulink>.
For instructions on how to register this or any other custom scope, see
- <xref linkend="beans-factory-scopes-custom-using"/>.</para>
+ <xref linkend="beans-factory-scopes-custom-using" />.</para>
</note>
<section id="beans-factory-scopes-singleton">
@@ -3111,10 +3115,12 @@ public class ReplacementComputeValue implements MethodReplacer {
<para>Suppose that you write your custom
<interfacename>Scope</interfacename> implementation, and then register
it as below.</para>
+
<note>
- <para>The example below uses <literal>SimpleThreadScope</literal>
- which is included with Spring, but not registered by default. The instructions
- would be the same for your own custom <literal>Scope</literal> implementations.</para>
+ <para>The example below uses <literal>SimpleThreadScope</literal>
+ which is included with Spring, but not registered by default. The
+ instructions would be the same for your own custom
+ <literal>Scope</literal> implementations.</para>
</note>
<programlisting language="java">
@@ -3528,8 +3534,7 @@ public final class Boot {
<interfacename>BeanFactory</interfacename> type if the field,
constructor, or method in question carries the
<interfacename>@Autowired</interfacename> annotation. For more
- information, see <xref
- linkend="beans-autowired-annotation" />.</para>
+ information, see <xref linkend="beans-autowired-annotation" />.</para>
<para>When an ApplicationContext creates a class that implements the
<interfacename>org.springframework.beans.factory.BeanNameAware</interfacename>
@@ -3846,12 +3851,12 @@ org.springframework.scripting.groovy.GroovyMessenger@272961</programlisting>
<para>Using callback interfaces or annotations in conjunction with a
custom <interfacename>BeanPostProcessor</interfacename> implementation
is a common means of extending the Spring IoC container. An example is
- shown in <xref linkend="metadata-annotations-required" /> which demonstrates the
- usage of a custom <interfacename>BeanPostProcessor</interfacename>
- implementation that ships with the Spring distribution which ensures
- that JavaBean properties on beans that are marked with an (arbitrary)
- annotation are actually (configured to be) dependency-injected with a
- value.</para>
+ shown in <xref linkend="metadata-annotations-required" /> which
+ demonstrates the usage of a custom
+ <interfacename>BeanPostProcessor</interfacename> implementation that
+ ships with the Spring distribution which ensures that JavaBean
+ properties on beans that are marked with an (arbitrary) annotation are
+ actually (configured to be) dependency-injected with a value.</para>
</section>
</section>
@@ -4178,12 +4183,16 @@ dataSource.url=jdbc:mysql:mydb</programlisting>
adds support for JSR-250 annotations such as
<interfacename>@Resource</interfacename>,
<interfacename>@PostConstruct</interfacename>, and
- <interfacename>@PreDestroy</interfacename>. Use of these annotations also
- requires that certain <interfacename>BeanPostProcessors</interfacename> be
- registered within the Spring container. As always, you can register them
- as individual bean definitions, but they can also be implicitly registered
- by including the following tag in an XML-based Spring configuration
- (notice the inclusion of the <literal>context</literal> namespace):</para>
+ <interfacename>@PreDestroy</interfacename>. Spring 3.0 adds support for
+ JSR-330 (Dependency Injection for Java) annotations contained in the
+ javax.inject package such as <classname>@Inject</classname>,
+ <literal>@Qualifier, @Named, and @Provider</literal> if the JSR330 jar is
+ present on the classpath. Use of these annotations also requires that
+ certain <interfacename>BeanPostProcessors</interfacename> be registered
+ within the Spring container. As always, you can register them as
+ individual bean definitions, but they can also be implicitly registered by
+ including the following tag in an XML-based Spring configuration (notice
+ the inclusion of the <literal>context</literal> namespace):</para>
<programlisting language="xml"><?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
@@ -4250,12 +4259,22 @@ dataSource.url=jdbc:mysql:mydb</programlisting>
</section>
<section id="beans-autowired-annotation">
- <title><interfacename>@Autowired</interfacename></title>
+ <title><interfacename>@Autowired and @Inject</interfacename></title>
<para>As expected, you can apply the
<interfacename>@Autowired</interfacename> annotation to "traditional"
setter methods:</para>
+ <note>
+ <para>JSR 330's @Inject annotation can be used in place of Spring's
+ <interfacename>@Autowired</interfacename> in the examples below.
+ <interfacename>@Inject</interfacename> does not have a required
+ property unlike Spring's <interfacename>@Autowire</interfacename>
+ annotation which as a required property to indicate if the value being
+ injected is optional. This behavior is enabled automatically if you
+ have the JSR 330 jar on the classpath.</para>
+ </note>
+
<programlisting language="java">public class SimpleMovieLister {
private MovieFinder movieFinder;
@@ -4423,6 +4442,14 @@ dataSource.url=jdbc:mysql:mydb</programlisting>
matches so that a specific bean is chosen for each argument. In the
simplest case, this can be a plain descriptive value:</para>
+ <note>
+ <para>Note that the JSR 330 <interfacename>@Qualifier</interfacename>
+ annotation can only be applied as a meta-annotation unlike Spring's
+ @Qualifier which takes a string property to discriminate among
+ multiple injection candidates and can be placed on annotation as well
+ as types, fields, methods, contstructors and parameters.</para>
+ </note>
+
<programlisting language="java">public class MovieRecommender {
@Autowired
@@ -4537,6 +4564,14 @@ dataSource.url=jdbc:mysql:mydb</programlisting>
<interfacename>@Qualifier</interfacename> annotation within your
definition:</para>
+ <note>
+ <para>You can use JSR 330's <interfacename>@Qualifier
+ </interfacename>annotation in the manner described below in place of
+ Spring's <interfacename>@Qualifier</interfacename> annotation. This
+ behavior is enabled automatically if you have the JSR 330 jar on the
+ classpath.</para>
+ </note>
+
<programlisting language="java">@Target({ElementType.FIELD, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
<emphasis role="bold">@Qualifier</emphasis>
@@ -5046,6 +5081,18 @@ public class JpaMovieFinder implements MovieFinder {
by including the <emphasis>annotation-config</emphasis> attribute with
a value of false.</para>
</note>
+
+ <note>
+ <para>In Spring 3.0 RC1 you can use JSR 330's
+ <interfacename>@Named</interfacename> annotation in place of
+ stereotpye annotations and they will be automatically detected during
+ component-scanning. The value of the
+ <interfacename>@Named</interfacename> property will be used as the
+ Bean Name. At this time Spring default for bean scope will be applied
+ when using @Named. This behavior as well as mapping of JSR 330 and
+ JSR299 scopes is planned for Spring 3.0 GA assuming the JSRs are
+ stable at that time.</para>
+ </note>
</section>
<section id="beans-scanning-filters">
@@ -5129,8 +5176,7 @@ public class JpaMovieFinder implements MovieFinder {
<entry>A custom implementation of the
<interfacename>org.springframework.core.type
- .TypeFilter</interfacename>
- interface.</entry>
+ .TypeFilter</interfacename> interface.</entry>
</row>
</tbody>
</tgroup>
@@ -5194,7 +5240,8 @@ public class FactoryMethodComponent {
annotations that can be specified are <literal>@Scope</literal>,
<literal>@Lazy</literal>, and custom qualifier annotations. Autowired
fields and methods are supported as previously discussed, with
- additional support for autowiring of <literal>@Bean</literal> methods:</para>
+ additional support for autowiring of <literal>@Bean</literal>
+ methods:</para>
<programlisting language="java">@Component
public class FactoryMethodComponent {
@@ -5265,12 +5312,20 @@ public class FactoryMethodComponent {
<interfacename>@Service</interfacename>, and
<interfacename>@Controller</interfacename>) that contains a
<literal>name</literal> value will thereby provide that name to the
- corresponding bean definition. If such an annotation contains no
- <literal>name</literal> value or for any other detected component (such
- as those discovered by custom filters), the default bean name generator
- returns the uncapitalized non-qualified class name. For example, if the
- following two components were detected, the names would be myMovieLister
- and movieFinderImpl:</para>
+ corresponding bean definition.</para>
+
+ <note>
+ <para>JSR 330's @Named annotation can be used as a mean to both detect
+ components and to provide them with a name. This behavior is enabled
+ automatically if you have the JSR 330 jar on the classpath.</para>
+ </note>
+
+ <para>If such an annotation contains no <literal>name</literal> value or
+ for any other detected component (such as those discovered by custom
+ filters), the default bean name generator returns the uncapitalized
+ non-qualified class name. For example, if the following two components
+ were detected, the names would be myMovieLister and
+ movieFinderImpl:</para>
<programlisting language="java">@Service("myMovieLister")
public class SimpleMovieLister {
@@ -5516,7 +5571,8 @@ public class AppConfig {
<interfacename>@Configuration</interfacename>-annotated class supports
the regular lifecycle callbacks. Any classes defined with the @Bean
annotation can use the @PostConstruct and @PreDestroy annotations from
- JSR-250, see <link linkend="beans-factory-lifecycle-combined-effects">JSR-250
+ JSR-250, see <link
+ linkend="beans-factory-lifecycle-combined-effects">JSR-250
annotations</link> for further details.</para>
<para>The regular Spring <link
@@ -5528,8 +5584,7 @@ public class AppConfig {
<para>The standard set of <code>*Aware</code> interfaces such as
<code><link
linkend="beans-beanfactory">BeanFactoryAware</link></code>,
- <code><link
- linkend="beans-factory-aware">BeanNameAware</link></code>,
+ <code><link linkend="beans-factory-aware">BeanNameAware</link></code>,
<code><link
linkend="context-functionality-messagesource">MessageSourceAware</link></code>,
<code><link | true |
Other | spring-projects | spring-framework | d8245c800bd8be235cbe9b363d4f6fe7dc4a5e77.json | Add minimal doc for JSR 330 support. | spring-framework-reference/src/new-in-3.xml | @@ -68,8 +68,8 @@
<sidebar id="new-in-3-intro-work-in-progress">
<title>Note:</title>
- <para>This document is not yet available. It will
- be available for the Spring 3.0 final release.</para>
+ <para>This document is not yet available. It will be available for the
+ Spring 3.0 final release.</para>
</sidebar>
</section>
@@ -186,7 +186,8 @@
</listitem>
<listitem>
- <para>General-purpose type conversion system and UI field formatting system</para>
+ <para>General-purpose type conversion system and UI field formatting
+ system</para>
</listitem>
<listitem>
@@ -384,15 +385,18 @@ public class AppConfig {
</section>
<section id="new-feature-convert-and-format">
- <title>General purpose type conversion system and UI field formatting system</title>
- <para>
- A general purpose <link linkend="core.convert">type conversion system</link> has been introduced.
- The system is currently used by SpEL for type coersion, and may also be used by a Spring Container when binding bean property values.
- </para>
- <para>
- In addition, a <link linkend="ui.format">ui.format</link> system has been introduced for formatting UI field values.
- This system provides a simpler and more robust alternative to JavaBean PropertyEditors in UI environments such as Spring MVC.
- </para>
+ <title>General purpose type conversion system and UI field formatting
+ system</title>
+
+ <para>A general purpose <link linkend="core.convert">type conversion
+ system</link> has been introduced. The system is currently used by SpEL
+ for type coersion, and may also be used by a Spring Container when
+ binding bean property values.</para>
+
+ <para>In addition, a <link linkend="ui.format">ui.format</link> system
+ has been introduced for formatting UI field values. This system provides
+ a simpler and more robust alternative to JavaBean PropertyEditors in UI
+ environments such as Spring MVC.</para>
</section>
<section id="new-feature-oxm">
@@ -431,9 +435,9 @@ public class AppConfig {
the <emphasis>Object to XML mapping</emphasis> functionality mentioned
earlier.</para>
- <para>Refer to the section on <link linkend="mvc">MVC</link> and
- <link linkend="rest-resttemplate">the RestTemplate</link>
- for more information.</para>
+ <para>Refer to the section on <link linkend="mvc">MVC</link> and <link
+ linkend="rest-resttemplate">the RestTemplate</link> for more
+ information.</para>
</section>
<section>
@@ -452,9 +456,8 @@ public class AppConfig {
<section id="new-feature-validation">
<title>Declarative model validation</title>
- <para>Hibernate Validator, JSR 303</para>
-
- <para>Work in progress... not part of the Spring 3.0 M3 release.</para>
+ <para>JSR 303 support using Hibernate Validator as the
+ implementation.</para>
</section>
<section id="new-feature-jee-6">
@@ -464,7 +467,7 @@ public class AppConfig {
use of the new @Async annotation (or EJB 3.1's @Asynchronous
annotation).</para>
- <para>JSF 2.0, JPA 2.0, etc</para>
+ <para>JSR 303, JSF 2.0, JPA 2.0, etc</para>
<para>Work in progress... not part of the Spring 3.0 M3 release.</para>
</section> | true |
Other | spring-projects | spring-framework | 59d9f73f46c147856479f17faef65317ce6eacea.json | ignore client proxies for export | org.springframework.web/src/main/java/org/springframework/remoting/jaxws/AbstractJaxWsServiceExporter.java | @@ -110,23 +110,25 @@ public void publishEndpoints() {
for (String beanName : beanNames) {
try {
Class<?> type = this.beanFactory.getType(beanName);
- WebService wsAnnotation = type.getAnnotation(WebService.class);
- WebServiceProvider wsProviderAnnotation = type.getAnnotation(WebServiceProvider.class);
- if (wsAnnotation != null || wsProviderAnnotation != null) {
- Endpoint endpoint = Endpoint.create(this.beanFactory.getBean(beanName));
- if (this.endpointProperties != null) {
- endpoint.setProperties(this.endpointProperties);
+ if (type != null && !type.isInterface()) {
+ WebService wsAnnotation = type.getAnnotation(WebService.class);
+ WebServiceProvider wsProviderAnnotation = type.getAnnotation(WebServiceProvider.class);
+ if (wsAnnotation != null || wsProviderAnnotation != null) {
+ Endpoint endpoint = Endpoint.create(this.beanFactory.getBean(beanName));
+ if (this.endpointProperties != null) {
+ endpoint.setProperties(this.endpointProperties);
+ }
+ if (this.executor != null) {
+ endpoint.setExecutor(this.executor);
+ }
+ if (wsAnnotation != null) {
+ publishEndpoint(endpoint, wsAnnotation);
+ }
+ else {
+ publishEndpoint(endpoint, wsProviderAnnotation);
+ }
+ this.publishedEndpoints.add(endpoint);
}
- if (this.executor != null) {
- endpoint.setExecutor(this.executor);
- }
- if (wsAnnotation != null) {
- publishEndpoint(endpoint, wsAnnotation);
- }
- else {
- publishEndpoint(endpoint, wsProviderAnnotation);
- }
- this.publishedEndpoints.add(endpoint);
}
}
catch (CannotLoadBeanClassException ex) { | false |
Other | spring-projects | spring-framework | 143ce57e7683287237a358558dd7cd28f8534ff2.json | SPR-6541: consolidate repositories into a profile (-P build) | org.springframework.spring-parent/pom.xml | @@ -24,41 +24,9 @@
<repositories>
<repository>
- <id>java.net</id>
- <name>Java.net Repository for Maven</name>
- <url>http://download.java.net/maven/1/</url>
- <layout>legacy</layout>
- <snapshots><enabled>false</enabled></snapshots>
- </repository>
- <!-- for use with jexcelapi 2.6.8, portlet 2.0, javax.el/el-api 2.1 -->
- <repository>
- <id>jboss</id>
- <name>JBoss Repository</name>
- <url>http://repository.jboss.org/maven2</url>
- <snapshots><enabled>false</enabled></snapshots>
- </repository>
- <repository>
- <id>EclipseLink Repo</id>
- <url>http://mirror.cc.vt.edu/pub/eclipse/rt/eclipselink/maven.repo/</url>
- <snapshots><enabled>false</enabled></snapshots>
- </repository>
- <!-- for rome 1.0 -->
- <repository>
- <id>sun-repo-2</id>
- <url>http://download.java.net/maven/2/</url>
- <snapshots><enabled>false</enabled></snapshots>
- </repository>
- <!-- fallback to S2 bundle repo for com.ibm.websphere.uow, oracle.classloader, com.sun.enterprise.loader -->
- <repository>
- <id>com.springsource.repository.bundles.release</id>
- <name>SpringSource Enterprise Bundle Repository - SpringSource Bundle Releases</name>
- <url>http://repository.springsource.com/maven/bundles/release/</url>
- <snapshots><enabled>false</enabled></snapshots>
- </repository>
- <repository>
- <id>com.springsource.repository.bundles.external</id>
- <name>SpringSource Enterprise Bundle Repository - External Bundle Releases</name>
- <url>http://repository.springsource.com/maven/bundles/external/</url>
+ <id>org.springframework.repository.maven</id>
+ <name>SpringSource Maven Repository</name>
+ <url>http://repository.springframework.org/maven/</url>
<snapshots><enabled>false</enabled></snapshots>
</repository>
</repositories>
@@ -205,6 +173,49 @@
</plugins>
</build>
</profile>
+ <profile>
+ <id>build</id>
+ <repositories>
+ <repository>
+ <id>java.net</id>
+ <name>Java.net Repository for Maven</name>
+ <url>http://download.java.net/maven/1/</url>
+ <layout>legacy</layout>
+ <snapshots><enabled>false</enabled></snapshots>
+ </repository>
+ <!-- for use with jexcelapi 2.6.8, portlet 2.0, javax.el/el-api 2.1 -->
+ <repository>
+ <id>jboss</id>
+ <name>JBoss Repository</name>
+ <url>http://repository.jboss.org/maven2</url>
+ <snapshots><enabled>false</enabled></snapshots>
+ </repository>
+ <repository>
+ <id>EclipseLink Repo</id>
+ <url>http://mirror.cc.vt.edu/pub/eclipse/rt/eclipselink/maven.repo/</url>
+ <snapshots><enabled>false</enabled></snapshots>
+ </repository>
+ <!-- for rome 1.0 -->
+ <repository>
+ <id>sun-repo-2</id>
+ <url>http://download.java.net/maven/2/</url>
+ <snapshots><enabled>false</enabled></snapshots>
+ </repository>
+ <!-- fallback to S2 bundle repo for com.ibm.websphere.uow, oracle.classloader, com.sun.enterprise.loader, caucho -->
+ <repository>
+ <id>com.springsource.repository.bundles.release</id>
+ <name>SpringSource Enterprise Bundle Repository - SpringSource Bundle Releases</name>
+ <url>http://repository.springsource.com/maven/bundles/release/</url>
+ <snapshots><enabled>false</enabled></snapshots>
+ </repository>
+ <repository>
+ <id>com.springsource.repository.bundles.external</id>
+ <name>SpringSource Enterprise Bundle Repository - External Bundle Releases</name>
+ <url>http://repository.springsource.com/maven/bundles/external/</url>
+ <snapshots><enabled>false</enabled></snapshots>
+ </repository>
+ </repositories>
+ </profile>
</profiles>
<build> | true |
Other | spring-projects | spring-framework | 143ce57e7683287237a358558dd7cd28f8534ff2.json | SPR-6541: consolidate repositories into a profile (-P build) | org.springframework.web/pom.xml | @@ -178,15 +178,4 @@
</dependency>
</dependencies>
- <!-- for caucho v 3.2.1 -->
- <repositories>
- <repository>
- <id>com.springsource.repository.bundles.external</id>
- <name>SpringSource Enterprise Bundle Repository - External Bundle Releases</name>
- <url>http://repository.springsource.com/maven/bundles/external</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
- </repositories>
</project> | true |
Other | spring-projects | spring-framework | e65ba99e237a10db8ffd066b3f9f0d9682f11b02.json | use varargs for scan method as well | org.springframework.context/src/main/java/org/springframework/context/annotation/AnnotationConfigApplicationContext.java | @@ -114,7 +114,7 @@ public void register(Class<?>... annotatedClasses) {
* Perform a scan within the specified base packages.
* @param basePackages the packages to check for annotated classes
*/
- public void scan(String[] basePackages) {
+ public void scan(String... basePackages) {
this.scanner.scan(basePackages);
}
| false |
Other | spring-projects | spring-framework | fae06dc156250ebea80594f4ca15ffd32e8f3c4b.json | SPR-6092: clarify jar name in test docs | spring-framework-reference/src/testing.xml | @@ -155,16 +155,22 @@
</listitem>
</itemizedlist>
- <para>The Spring Framework provides first class support for integration
- testing in the <filename
- class="libraryfile">spring-test.jar</filename>
- library (where <literal>VERSION</literal> is the release version). This
- library includes the <literal>org.springframework.test</literal>
- package, which contains valuable classes for integration testing with a
- Spring container. This testing does not rely on an application server or
- other deployment environment. Such tests are slower to run than unit
- tests but much faster to than the equivalent Cactus tests or remote
- tests that rely on deployment to an application server.</para>
+ <para>The Spring Framework provides first class support for
+ integration testing in
+ the <filename class="libraryfile">spring-test</filename> module.
+ The name of the actual jar file might include the the release
+ version and might also be in the
+ long <filename>org.springframework.test</filename> form,
+ depending on where you got it from (see
+ the <link linkend="dependency-management">section on Dependency
+ Management</link> for an explanation). This library includes
+ the <literal>org.springframework.test</literal> package, which
+ contains valuable classes for integration testing with a Spring
+ container. This testing does not rely on an application server
+ or other deployment environment. Such tests are slower to run
+ than unit tests but much faster to than the equivalent Cactus
+ tests or remote tests that rely on deployment to an application
+ server.</para>
<para>In Spring 2.5 and later, unit and integration testing support is
provided in the form of the annotation-driven <link | false |
Other | spring-projects | spring-framework | ebd15e32876e0266c57faaf77ff66987e9bf813a.json | SPR-6092: add section on Ivy | spring-framework-reference/src/overview.xml | @@ -415,7 +415,9 @@ TR: OK. Added to diagram.--></para>
(<code>org.springframework.*-<version>.jar</code>), and the
dependencies are also in this "long" form, with external libraries
(not from SpringSource) having the prefix
- <code>com.springsource</code>.</para>
+ <code>com.springsource</code>. See the <ulink security=""
+ url="http://www.springsource.com/repository/app/faq">FAQ</ulink>
+ for more information.</para>
</listitem>
<listitem>
@@ -576,10 +578,23 @@ TR: OK. Added to diagram.--></para>
libraries in order to use Spring for simple use cases. For basic
dependency injection there is only one mandatory external dependency,
and that is for logging (see below for a more detailed description of
- logging options). If you are using Maven for dependency management you
- don't even need to supply the logging dependency explicitly. For
- example, to create an application context and use dependency injection
- to configure an application, your Maven dependencies will look like
+ logging options).</para>
+
+ <para>Next we outline the basic steps needed to configure an
+ application that depends on Spring, first with Maven and then with
+ Ivy. In all cases, if anything is unclear, refer to the documentation
+ of your dependency management system, or look at some sample code -
+ Spring itself uses Ivy to manage dependencies when it is building, and
+ our samples mostly use Maven.</para>
+ </section>
+
+ <section>
+ <title>Maven Dependency Management</title>
+
+ <para>If you are using Maven for dependency management you don't even
+ need to supply the logging dependency explicitly. For example, to
+ create an application context and use dependency injection to
+ configure an application, your Maven dependencies will look like
this:</para>
<para><programlisting><dependencies>
@@ -659,14 +674,53 @@ TR: OK. Added to diagram.--></para>
that can be used to search for and download dependencies. It also has
handy snippets of Maven and Ivy configuration that you can copy and
paste if you are using those tools.</para>
+ </section>
+
+ <section>
+ <title>Ivy Dependency Management</title>
+
+ <para>If you prefer to use <ulink
+ url="http://ant.apache.org/ivy">Ivy</ulink> to manage dependencies
+ then there are similar names and configuration options. </para>
+
+ <para>To configure Ivy to point to the SpringSource EBR add the
+ following resolvers to your
+ <filename>ivysettings.xml</filename>:</para>
- <para>If you prefer to use <ulink url="http://ant.apache.org/ivy">
- Ivy</ulink> to manage dependencies then there are
- similar names and configuration options there (refer to the
- documentation of your dependency management system, or look at some
- sample code - Spring itself uses Ivy to manage dependencies when it is
- building).</para>
+ <programlisting><resolvers>
+
+ <url name="com.springsource.repository.bundles.release">
+ <ivy pattern="http://repository.springsource.com/ivy/bundles/release/
+ [organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
+ <artifact pattern="http://repository.springsource.com/ivy/bundles/release/
+ [organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
+
+ </url>
+
+ <url name="com.springsource.repository.bundles.external">
+
+ <ivy pattern="http://repository.springsource.com/ivy/bundles/external/
+ [organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
+ <artifact pattern="http://repository.springsource.com/ivy/bundles/external/
+ [organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
+
+ </url>
+
+</resolvers></programlisting>
+
+ <para>The XML above is not valid because the lines are too long - if
+ you copy-paste then remove the extra line endings in the middle of the
+ url patterns.</para>
+
+ <para>Once Ivy is configured to look in the EBR adding a dependency is
+ easy. Simply pull up the details page for the bundle in question in
+ the repository browser and you'll find an Ivy snippet ready for you to
+ include in your dependencies section. For example (in
+ <filename>ivy.xml</filename>): </para>
+
+ <programlisting><dependency org="org.springframework"
+ name="org.springframework.core" rev="3.0.0.RELEASE" conf="compile->runtime"/></programlisting>
</section>
</section>
@@ -697,32 +751,33 @@ TR: OK. Added to diagram.--></para>
Spring and specifically from the central module called
<code>spring-core</code>.</para>
- <para>The nice thing about <code>commons-logging</code> is that you don't need
- anything else to make your application work. It has a runtime discovery
- algorithm that looks for other logging frameworks in well known places
- on the classpath and uses one that it thinks is appropriate (or you can
- tell it which one if you need to). If nothing else is available you get
- pretty nice looking logs just from the JDK (java.util.logging or JUL for
- short). You should find that your Spring application works and logs
- happily to the console out of the box in most situations, and that's
- important.</para>
+ <para>The nice thing about <code>commons-logging</code> is that you
+ don't need anything else to make your application work. It has a runtime
+ discovery algorithm that looks for other logging frameworks in well
+ known places on the classpath and uses one that it thinks is appropriate
+ (or you can tell it which one if you need to). If nothing else is
+ available you get pretty nice looking logs just from the JDK
+ (java.util.logging or JUL for short). You should find that your Spring
+ application works and logs happily to the console out of the box in most
+ situations, and that's important.</para>
<section>
<title>Not Using Commons Logging</title>
- <para>Unfortunately, the worst thing about <code>commons-logging</code>, and what
- has made it unpopular with new tools, is also the runtime discovery
- algorithm. If we could turn back the clock and start Spring now as a
- new project it would use a different logging dependency. Probably the
- first choice would be the Simple Logging Framework for Java (<ulink
- url="http://www.slf4j.org">SLF4J</ulink>),
- which is also used by a lot of other tools
- that people use with Spring inside their applications.</para>
-
- <para>To switch off <code>commons-logging</code> is easy: just make sure it isn't
- on the classpath at runtime. In Maven terms you exclude the
- dependency, and because of the way that the Spring dependencies are
- declared, you only have to do that once.</para>
+ <para>Unfortunately, the worst thing about
+ <code>commons-logging</code>, and what has made it unpopular with new
+ tools, is also the runtime discovery algorithm. If we could turn back
+ the clock and start Spring now as a new project it would use a
+ different logging dependency. Probably the first choice would be the
+ Simple Logging Framework for Java (<ulink
+ url="http://www.slf4j.org">SLF4J</ulink>), which is also used by a lot
+ of other tools that people use with Spring inside their
+ applications.</para>
+
+ <para>To switch off <code>commons-logging</code> is easy: just make
+ sure it isn't on the classpath at runtime. In Maven terms you exclude
+ the dependency, and because of the way that the Spring dependencies
+ are declared, you only have to do that once.</para>
<programlisting><dependencies>
<dependency>
@@ -750,28 +805,28 @@ TR: OK. Added to diagram.--></para>
</section>
<para>SLF4J is a cleaner dependency and more efficient at runtime than
- <code>commons-logging</code> because it uses compile-time bindings instead of runtime
- discovery of the other logging frameworks it integrates. This also means
- that you have to be more explicit about what you want to happen at
- runtime, and declare it or configure it accordingly. SLF4J provides
- bindings to many common logging frameworks, so you can usually choose
- one that you already use, and bind to that for configuration and
- management.</para>
+ <code>commons-logging</code> because it uses compile-time bindings
+ instead of runtime discovery of the other logging frameworks it
+ integrates. This also means that you have to be more explicit about what
+ you want to happen at runtime, and declare it or configure it
+ accordingly. SLF4J provides bindings to many common logging frameworks,
+ so you can usually choose one that you already use, and bind to that for
+ configuration and management.</para>
<para>SLF4J provides bindings to many common logging frameworks,
including JCL, and it also does the reverse: bridges between other
logging frameworks and itself. So to use SLF4J with Spring you need to
- replace the <code>commons-logging</code> dependency with the SLF4J-JCL bridge. Once
- you have done that then logging calls from within Spring will be
- translated into logging calls to the SLF4J API, so if other libraries in
- your application use that API, then you have a single place to configure
- and manage logging.</para>
+ replace the <code>commons-logging</code> dependency with the SLF4J-JCL
+ bridge. Once you have done that then logging calls from within Spring
+ will be translated into logging calls to the SLF4J API, so if other
+ libraries in your application use that API, then you have a single place
+ to configure and manage logging.</para>
<para>A common choice might be to bridge Spring to SLF4J, and then
provide explicit binding from SLF4J to Log4J. You need to supply 4
- dependencies (and exclude the existing <code>commons-logging</code>): the bridge, the
- SLF4J API, the binding to Log4J, and the Log4J implementation itself. In
- Maven you would do that like this</para>
+ dependencies (and exclude the existing <code>commons-logging</code>):
+ the bridge, the SLF4J API, the binding to Log4J, and the Log4J
+ implementation itself. In Maven you would do that like this</para>
<programlisting><dependencies>
<dependency>
@@ -821,13 +876,12 @@ TR: OK. Added to diagram.--></para>
<para>A more common choice amongst SLF4J users, which uses fewer steps
and generates fewer dependencies, is to bind directly to <ulink type=""
- url="http://logback.qos.ch">Logback</ulink>.
- This removes the extra binding step because
- Logback implements SLF4J directly, so you only need to depend on two
- libaries not four (<code>jcl-slf4j</code> and <code>logback</code>). If
- you do that you might also need to exlude the slf4j-api dependency from
- other external dependencies (not Spring), because you only want one
- version of that API on the classpath.</para>
+ url="http://logback.qos.ch">Logback</ulink>. This removes the extra
+ binding step because Logback implements SLF4J directly, so you only need
+ to depend on two libaries not four (<code>jcl-slf4j</code> and
+ <code>logback</code>). If you do that you might also need to exlude the
+ slf4j-api dependency from other external dependencies (not Spring),
+ because you only want one version of that API on the classpath.</para>
<section>
<title>Using Log4J</title> | false |
Other | spring-projects | spring-framework | b42cf25599fe9a497ce8da47e1cd06475f2a80e5.json | SPR-6236: Reintroduce Struts support | build-spring-framework/generate-pom.xml | @@ -25,6 +25,7 @@
<pathelement location="../org.springframework.web.servlet"/>
<pathelement location="../org.springframework.web.portlet"/>
<pathelement location="../org.springframework.test"/>
+ <pathelement location="../org.springframework.web.struts"/>
</path>
<condition property="maven.extension" value=".bat" else="">
| true |
Other | spring-projects | spring-framework | b42cf25599fe9a497ce8da47e1cd06475f2a80e5.json | SPR-6236: Reintroduce Struts support | build-spring-framework/pom.xml | @@ -74,6 +74,7 @@
<module>../org.springframework.web.servlet</module>
<module>../org.springframework.web.portlet</module>
<module>../org.springframework.test</module>
+ <module>../org.springframework.web.struts</module>
</modules>
<profiles>
| true |
Other | spring-projects | spring-framework | b42cf25599fe9a497ce8da47e1cd06475f2a80e5.json | SPR-6236: Reintroduce Struts support | org.springframework.web.struts/pom.xml | @@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-struts</artifactId>
+ <packaging>jar</packaging>
+ <version>3.0.0.BUILD-SNAPSHOT</version>
+ <parent>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-parent</artifactId>
+ <relativePath>../org.springframework.spring-parent</relativePath>
+ <version>3.0.0.BUILD-SNAPSHOT</version>
+ </parent>
+ <dependencies>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet.jsp</groupId>
+ <artifactId>jsp-api</artifactId>
+ <version>2.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jstl</artifactId>
+ <version>1.1.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>struts</groupId>
+ <artifactId>struts</artifactId>
+ <version>1.2.9</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-beanutils</groupId>
+ <artifactId>commons-beanutils</artifactId>
+ <version>1.7.0</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-core</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-web</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-webmvc</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project> | true |
Other | spring-projects | spring-framework | 7461d7058298c7e707c670b6e43f716a3bfb8f84.json | SPR-6236: Reintroduce Struts support | build-spring-framework/build.xml | @@ -21,6 +21,7 @@
<pathelement location="../org.springframework.web.servlet"/>
<pathelement location="../org.springframework.web.portlet"/>
<pathelement location="../org.springframework.test"/>
+ <pathelement location="../org.springframework.web.struts"/>
<pathelement location="../org.springframework.spring-library"/>
<pathelement location="../org.springframework.integration-tests"/>
</path>
| true |
Other | spring-projects | spring-framework | 7461d7058298c7e707c670b6e43f716a3bfb8f84.json | SPR-6236: Reintroduce Struts support | build-spring-framework/publish.xml | @@ -24,6 +24,7 @@
<pathelement location="../org.springframework.web.servlet"/>
<pathelement location="../org.springframework.web.portlet"/>
<pathelement location="../org.springframework.test"/>
+ <pathelement location="../org.springframework.web.struts"/>
</path>
<path id="modules-with-only-pom-artifacts">
| true |
Other | spring-projects | spring-framework | 7fa910509672270f952a250c4ed64b7db69ccdac.json | SPR-6236: Reintroduce Struts support | org.springframework.web.struts/build.xml | @@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="org.springframework.web.struts">
+ <property file="${basedir}/../build.properties"/>
+ <import file="${basedir}/../build-spring-framework/package-bundle.xml"/>
+ <import file="${basedir}/../spring-build/standard/default.xml"/>
+</project> | true |
Other | spring-projects | spring-framework | 7fa910509672270f952a250c4ed64b7db69ccdac.json | SPR-6236: Reintroduce Struts support | org.springframework.web.struts/ivy.xml | @@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?xml-stylesheet type="text/xsl" href="http://ivyrep.jayasoft.org/ivy-doc.xsl"?>
+<ivy-module
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="http://incubator.apache.org/ivy/schemas/ivy.xsd"
+ version="1.3">
+
+ <info organisation="org.springframework" module="${ant.project.name}">
+ <license name="Apache 2.0" url="http://www.apache.org/licenses/LICENSE-2.0"/>
+ </info>
+
+ <configurations>
+ <include file="${spring.build.dir}/common/default-ivy-configurations.xml"/>
+ <conf name="tiles" extends="runtime" description="JARs neeeded to create beans for Tiles"/>
+ </configurations>
+
+ <publications>
+ <artifact name="${ant.project.name}"/>
+ <artifact name="${ant.project.name}-sources" type="src" ext="jar"/>
+ </publications>
+
+ <dependencies>
+ <dependency org="javax.servlet" name="com.springsource.javax.servlet" rev="2.5.0" conf="provided->compile"/>
+ <dependency org="org.apache.commons" name="com.springsource.org.apache.commons.logging" rev="1.1.1"
+ conf="compile->compile"/>
+ <dependency org="org.apache.commons" name="com.springsource.org.apache.commons.beanutils" rev="1.7.0"
+ conf="compile->compile"/>
+ <dependency org="org.apache.struts" name="com.springsource.org.apache.struts" rev="1.2.9" />
+ <dependency org="org.springframework" name="org.springframework.beans" rev="latest.integration"
+ conf="compile->compile"/>
+ <dependency org="org.springframework" name="org.springframework.context" rev="latest.integration"
+ conf="compile->compile"/>
+ <dependency org="org.springframework" name="org.springframework.core" rev="latest.integration"
+ conf="compile->compile"/>
+ <dependency org="org.springframework" name="org.springframework.web" rev="latest.integration"
+ conf="compile->compile"/>
+ <dependency org="org.springframework" name="org.springframework.web.servlet" rev="latest.integration"
+ conf="optional, tiles->compile"/>
+ <!--
+ <dependency org="com.sun.syndication" name="com.springsource.com.sun.syndication" rev="1.0.0"
+ conf="optional, feed->compile"/>
+ <dependency org="com.lowagie.text" name="com.springsource.com.lowagie.text" rev="2.0.8"
+ conf="optional, itext->compile"/>
+ <dependency org="org.freemarker" name="com.springsource.freemarker" rev="2.3.15"
+ conf="optional, freemarker->compile"/>
+ <dependency org="javax.el" name="com.springsource.javax.el" rev="1.0.0" conf="provided->compile"/>
+ <dependency org="javax.servlet" name="com.springsource.javax.servlet.jsp" rev="2.1.0" conf="provided->compile"/>
+ <dependency org="javax.servlet" name="com.springsource.javax.servlet.jsp.jstl" rev="1.1.2"
+ conf="provided->compile"/>
+ <dependency org="net.sourceforge.jexcelapi" name="com.springsource.jxl" rev="2.6.6"
+ conf="optional, jexcelapi->compile"/>
+ <dependency org="net.sourceforge.jasperreports" name="com.springsource.net.sf.jasperreports" rev="2.0.5"
+ conf="optional, jasper-reports->compile"/>
+ <dependency org="org.apache.commons" name="com.springsource.org.apache.commons.logging" rev="1.1.1"
+ conf="compile->compile"/>
+ <dependency org="org.apache.poi" name="com.springsource.org.apache.poi" rev="3.0.2.FINAL"
+ conf="optional, poi->compile"/>
+ <dependency org="org.apache.tiles" name="com.springsource.org.apache.tiles" rev="2.1.2.osgi"
+ conf="optional, tiles->compile"/>
+ <dependency org="org.apache.tiles" name="com.springsource.org.apache.tiles.core" rev="2.1.2.osgi"
+ conf="optional, tiles->compile"/>
+ <dependency org="org.apache.tiles" name="com.springsource.org.apache.tiles.jsp" rev="2.1.2"
+ conf="optional, tiles->compile"/>
+ <dependency org="org.apache.tiles" name="com.springsource.org.apache.tiles.servlet" rev="2.1.2"
+ conf="optional, tiles->compile"/>
+ <dependency org="org.apache.velocity" name="com.springsource.org.apache.velocity" rev="1.5.0"
+ conf="optional, velocity->compile"/>
+ <dependency org="org.apache.velocity" name="com.springsource.org.apache.velocity.tools.view" rev="1.4.0"
+ conf="optional, velocity->compile"/>
+ <dependency org="org.codehaus.jackson" name="com.springsource.org.codehaus.jackson.mapper" rev="1.0.0"
+ conf="optional, jackson->compile"/>
+ <dependency org="org.springframework" name="org.springframework.beans" rev="latest.integration"
+ conf="compile->compile"/>
+ <dependency org="org.springframework" name="org.springframework.context" rev="latest.integration"
+ conf="compile->compile"/>
+ <dependency org="org.springframework" name="org.springframework.context.support" rev="latest.integration"
+ conf="optional, velocity, freemarker, jasper-reports->compile"/>
+ <dependency org="org.springframework" name="org.springframework.core" rev="latest.integration"
+ conf="compile->compile"/>
+ <dependency org="org.springframework" name="org.springframework.oxm" rev="latest.integration"
+ conf="optional, oxm->compile"/>
+-->
+ <!-- test dependencies -->
+ <dependency org="org.junit" name="com.springsource.org.junit" rev="4.7.0" conf="test->runtime"/>
+ <dependency org="org.easymock" name="com.springsource.org.easymock" rev="2.5.1" conf="test->compile"/>
+ <dependency org="org.springframework" name="org.springframework.test" rev="latest.integration"
+ conf="test->compile"/>
+ <dependency org="javax.servlet" name="com.springsource.javax.servlet.jsp.jstl" rev="1.1.2"
+ conf="test->compile"/>
+ </dependencies>
+
+</ivy-module> | true |
Other | spring-projects | spring-framework | 7fa910509672270f952a250c4ed64b7db69ccdac.json | SPR-6236: Reintroduce Struts support | org.springframework.web.struts/src/main/java/org/springframework/web/servlet/view/tiles/ComponentControllerSupport.java | @@ -0,0 +1,180 @@
+/*
+ * Copyright 2002-2008 the original author or authors.
+ *
+ * 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.springframework.web.servlet.view.tiles;
+
+import java.io.File;
+import java.io.IOException;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.struts.tiles.ComponentContext;
+import org.apache.struts.tiles.ControllerSupport;
+
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.MessageSourceAccessor;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.servlet.support.RequestContextUtils;
+import org.springframework.web.util.NestedServletException;
+import org.springframework.web.util.WebUtils;
+
+/**
+ * Convenience class for Spring-aware Tiles component controllers.
+ * Provides a reference to the current Spring application context,
+ * e.g. for bean lookup or resource loading.
+ *
+ * <p>Derives from the Tiles {@link ControllerSupport} class rather than
+ * implementing the Tiles {@link org.apache.struts.tiles.Controller} interface
+ * in order to be compatible with Struts 1.1 and 1.2. Implements both Struts 1.1's
+ * <code>perform</code> and Struts 1.2's <code>execute</code> method accordingly.
+ *
+ * @author Juergen Hoeller
+ * @author Alef Arendsen
+ * @since 22.08.2003
+ * @see org.springframework.web.context.support.WebApplicationObjectSupport
+ * @deprecated as of Spring 3.0
+ */
+@Deprecated
+public abstract class ComponentControllerSupport extends ControllerSupport {
+
+ private WebApplicationContext webApplicationContext;
+
+ private MessageSourceAccessor messageSourceAccessor;
+
+
+ /**
+ * This implementation delegates to <code>execute</code>,
+ * converting non-Servlet/IO Exceptions to ServletException.
+ * <p>This is the only execution method available in Struts 1.1.
+ * @see #execute
+ */
+ @Override
+ public final void perform(
+ ComponentContext componentContext, HttpServletRequest request,
+ HttpServletResponse response, ServletContext servletContext)
+ throws ServletException, IOException {
+
+ try {
+ execute(componentContext, request, response, servletContext);
+ }
+ catch (ServletException ex) {
+ throw ex;
+ }
+ catch (IOException ex) {
+ throw ex;
+ }
+ catch (Throwable ex) {
+ throw new NestedServletException("Execution of component controller failed", ex);
+ }
+ }
+
+ /**
+ * This implementation delegates to <code>doPerform</code>,
+ * lazy-initializing the application context reference if necessary.
+ * <p>This is the preferred execution method in Struts 1.2.
+ * When running with Struts 1.1, it will be called by <code>perform</code>.
+ * @see #perform
+ * @see #doPerform
+ */
+ @Override
+ public final void execute(
+ ComponentContext componentContext, HttpServletRequest request,
+ HttpServletResponse response, ServletContext servletContext)
+ throws Exception {
+
+ synchronized (this) {
+ if (this.webApplicationContext == null) {
+ this.webApplicationContext = RequestContextUtils.getWebApplicationContext(request, servletContext);
+ this.messageSourceAccessor = new MessageSourceAccessor(this.webApplicationContext);
+ }
+ }
+ doPerform(componentContext, request, response);
+ }
+
+
+ /**
+ * Subclasses can override this for custom initialization behavior.
+ * Gets called on initialization of the context for this controller.
+ * @throws org.springframework.context.ApplicationContextException in case of initialization errors
+ * @throws org.springframework.beans.BeansException if thrown by application context methods
+ */
+ protected void initApplicationContext() throws BeansException {
+ }
+
+ /**
+ * Return the current Spring ApplicationContext.
+ */
+ protected final ApplicationContext getApplicationContext() {
+ return this.webApplicationContext;
+ }
+
+ /**
+ * Return the current Spring WebApplicationContext.
+ */
+ protected final WebApplicationContext getWebApplicationContext() {
+ return this.webApplicationContext;
+ }
+
+ /**
+ * Return a MessageSourceAccessor for the application context
+ * used by this object, for easy message access.
+ */
+ protected final MessageSourceAccessor getMessageSourceAccessor() {
+ return this.messageSourceAccessor;
+ }
+
+ /**
+ * Return the current ServletContext.
+ */
+ protected final ServletContext getServletContext() {
+ return this.webApplicationContext.getServletContext();
+ }
+
+ /**
+ * Return the temporary directory for the current web application,
+ * as provided by the servlet container.
+ * @return the File representing the temporary directory
+ */
+ protected final File getTempDir() {
+ return WebUtils.getTempDir(getServletContext());
+ }
+
+
+ /**
+ * Perform the preparation for the component, allowing for any Exception to be thrown.
+ * The ServletContext can be retrieved via getServletContext, if necessary.
+ * The Spring WebApplicationContext can be accessed via getWebApplicationContext.
+ * <p>This method will be called both in the Struts 1.1 and Struts 1.2 case,
+ * by <code>perform</code> or <code>execute</code>, respectively.
+ * @param componentContext current Tiles component context
+ * @param request current HTTP request
+ * @param response current HTTP response
+ * @throws Exception in case of errors
+ * @see org.apache.struts.tiles.Controller#perform
+ * @see #getServletContext
+ * @see #getWebApplicationContext
+ * @see #perform
+ * @see #execute
+ */
+ protected abstract void doPerform(
+ ComponentContext componentContext, HttpServletRequest request, HttpServletResponse response)
+ throws Exception;
+
+} | true |
Other | spring-projects | spring-framework | 7fa910509672270f952a250c4ed64b7db69ccdac.json | SPR-6236: Reintroduce Struts support | org.springframework.web.struts/src/main/java/org/springframework/web/servlet/view/tiles/TilesConfigurer.java | @@ -0,0 +1,149 @@
+/*
+ * Copyright 2002-2007 the original author or authors.
+ *
+ * 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.springframework.web.servlet.view.tiles;
+
+import org.apache.struts.tiles.DefinitionsFactory;
+import org.apache.struts.tiles.DefinitionsFactoryConfig;
+import org.apache.struts.tiles.DefinitionsFactoryException;
+import org.apache.struts.tiles.TilesUtil;
+import org.apache.struts.tiles.xmlDefinition.I18nFactorySet;
+
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.util.StringUtils;
+import org.springframework.web.context.support.WebApplicationObjectSupport;
+
+/**
+ * Helper class to configure Tiles 1.x for the Spring Framework. See
+ * <a href="http://struts.apache.org">http://struts.apache.org</a>
+ * for more information about Struts Tiles, which basically is a templating
+ * mechanism for JSP-based web applications.
+ *
+ * <p><b>NOTE:</b> This TilesConfigurer class supports Tiles 1.x,
+ * a.k.a. "Struts Tiles", which comes as part of Struts 1.x.
+ * For Tiles 2.x support, check out
+ * {@link org.springframework.web.servlet.view.tiles2.TilesConfigurer}.
+ *
+ * <p>The TilesConfigurer simply configures a Tiles DefinitionsFactory using
+ * a set of files containing definitions, to be accessed by {@link TilesView}
+ * instances.
+ *
+ * <p>TilesViews can be managed by any {@link org.springframework.web.servlet.ViewResolver}.
+ * For simple convention-based view resolution, consider using
+ * {@link org.springframework.web.servlet.view.UrlBasedViewResolver} with the
+ * "viewClass" property set to "org.springframework.web.servlet.view.tiles.TilesView".
+ *
+ * <p>A typical TilesConfigurer bean definition looks as follows:
+ *
+ * <pre>
+ * <bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles.TilesConfigurer">
+ * <property name="definitions">
+ * <list>
+ * <value>/WEB-INF/defs/general.xml</value>
+ * <value>/WEB-INF/defs/widgets.xml</value>
+ * <value>/WEB-INF/defs/administrator.xml</value>
+ * <value>/WEB-INF/defs/customer.xml</value>
+ * <value>/WEB-INF/defs/templates.xml</value>
+ * </list>
+ * </property>
+ * </bean></pre>
+ *
+ * The values in the list are the actual files containing the definitions.
+ *
+ * @author Alef Arendsen
+ * @author Juergen Hoeller
+ * @see TilesView
+ * @see org.springframework.web.servlet.view.UrlBasedViewResolver
+ * @deprecated as of Spring 3.0
+ */
+@Deprecated
+public class TilesConfigurer extends WebApplicationObjectSupport implements InitializingBean {
+
+ /** Definition URLs mapped to descriptions */
+ private String[] definitions;
+
+ /** Validate the Tiles definitions? */
+ private boolean validateDefinitions = true;
+
+ /** Factory class for Tiles */
+ private Class factoryClass = I18nFactorySet.class;
+
+
+ /**
+ * Set the Tiles definitions, i.e. the list of files containing the definitions.
+ */
+ public void setDefinitions(String[] definitions) {
+ this.definitions = definitions;
+ }
+
+ /**
+ * Set whether to validate the Tiles XML definitions. Default is "true".
+ */
+ public void setValidateDefinitions(boolean validateDefinitions) {
+ this.validateDefinitions = validateDefinitions;
+ }
+
+ /**
+ * Set the factory class for Tiles. Default is I18nFactorySet.
+ * @see org.apache.struts.tiles.xmlDefinition.I18nFactorySet
+ */
+ public void setFactoryClass(Class factoryClass) {
+ this.factoryClass = factoryClass;
+ }
+
+
+ /**
+ * Initialize the Tiles definition factory.
+ * Delegates to createDefinitionsFactory for the actual creation.
+ * @throws DefinitionsFactoryException if an error occurs
+ * @see #createDefinitionsFactory
+ */
+ public void afterPropertiesSet() throws DefinitionsFactoryException {
+ logger.debug("TilesConfigurer: initializion started");
+
+ // initialize the configuration for the definitions factory
+ DefinitionsFactoryConfig factoryConfig = new DefinitionsFactoryConfig();
+ factoryConfig.setFactoryName("");
+ factoryConfig.setFactoryClassname(this.factoryClass.getName());
+ factoryConfig.setParserValidate(this.validateDefinitions);
+
+ if (this.definitions != null) {
+ String defs = StringUtils.arrayToCommaDelimitedString(this.definitions);
+ if (logger.isInfoEnabled()) {
+ logger.info("TilesConfigurer: adding definitions [" + defs + "]");
+ }
+ factoryConfig.setDefinitionConfigFiles(defs);
+ }
+
+ // initialize the definitions factory
+ createDefinitionsFactory(factoryConfig);
+
+ logger.debug("TilesConfigurer: initialization completed");
+ }
+
+ /**
+ * Create the Tiles DefinitionsFactory and expose it to the ServletContext.
+ * @param factoryConfig the configuration for the DefinitionsFactory
+ * @return the DefinitionsFactory
+ * @throws DefinitionsFactoryException if an error occurs
+ */
+ protected DefinitionsFactory createDefinitionsFactory(DefinitionsFactoryConfig factoryConfig)
+ throws DefinitionsFactoryException {
+
+ return TilesUtil.createDefinitionsFactory(getServletContext(), factoryConfig);
+ }
+
+} | true |
Other | spring-projects | spring-framework | 7fa910509672270f952a250c4ed64b7db69ccdac.json | SPR-6236: Reintroduce Struts support | org.springframework.web.struts/src/main/java/org/springframework/web/servlet/view/tiles/TilesJstlView.java | @@ -0,0 +1,53 @@
+/*
+ * Copyright 2002-2008 the original author or authors.
+ *
+ * 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.springframework.web.servlet.view.tiles;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.springframework.web.servlet.support.JstlUtils;
+import org.springframework.web.servlet.support.RequestContext;
+
+/**
+ * Specialization of {@link TilesView} for JSTL pages,
+ * i.e. Tiles pages that use the JSP Standard Tag Library.
+ *
+ * <p><b>NOTE:</b> This TilesJstlView class supports Tiles 1.x,
+ * a.k.a. "Struts Tiles", which comes as part of Struts 1.x.
+ * For Tiles 2.x support, check out
+ * {@link org.springframework.web.servlet.view.tiles2.TilesView}.
+ *
+ * <p>Exposes JSTL-specific request attributes specifying locale
+ * and resource bundle for JSTL's formatting and message tags,
+ * using Spring's locale and message source.
+ *
+ * <p>This is a separate class mainly to avoid JSTL dependencies
+ * in TilesView itself.
+ *
+ * @author Juergen Hoeller
+ * @since 20.08.2003
+ * @see org.springframework.web.servlet.support.JstlUtils#exposeLocalizationContext
+ * @deprecated as of Spring 3.0
+ */
+@Deprecated
+public class TilesJstlView extends TilesView {
+
+ @Override
+ protected void exposeHelpers(HttpServletRequest request) throws Exception {
+ JstlUtils.exposeLocalizationContext(new RequestContext(request, getServletContext()));
+ }
+
+} | true |
Other | spring-projects | spring-framework | 7fa910509672270f952a250c4ed64b7db69ccdac.json | SPR-6236: Reintroduce Struts support | org.springframework.web.struts/src/main/java/org/springframework/web/servlet/view/tiles/TilesView.java | @@ -0,0 +1,209 @@
+/*
+ * Copyright 2002-2007 the original author or authors.
+ *
+ * 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.springframework.web.servlet.view.tiles;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.struts.tiles.ComponentContext;
+import org.apache.struts.tiles.ComponentDefinition;
+import org.apache.struts.tiles.Controller;
+import org.apache.struts.tiles.DefinitionsFactory;
+import org.apache.struts.tiles.TilesUtilImpl;
+
+import org.springframework.context.ApplicationContextException;
+import org.springframework.web.servlet.view.InternalResourceView;
+
+/**
+ * View implementation that retrieves a Tiles definition.
+ * The "url" property is interpreted as name of a Tiles definition.
+ *
+ * <p>{@link TilesJstlView} with JSTL support is a separate class,
+ * mainly to avoid JSTL dependencies in this class.
+ *
+ * <p><b>NOTE:</b> This TilesView class supports Tiles 1.x,
+ * a.k.a. "Struts Tiles", which comes as part of Struts 1.x.
+ * For Tiles 2.x support, check out
+ * {@link org.springframework.web.servlet.view.tiles2.TilesView}.
+ *
+ * <p>Depends on a Tiles DefinitionsFactory which must be available
+ * in the ServletContext. This factory is typically set up via a
+ * {@link TilesConfigurer} bean definition in the application context.
+ *
+ * <p>Check out {@link ComponentControllerSupport} which provides
+ * a convenient base class for Spring-aware component controllers,
+ * allowing convenient access to the Spring ApplicationContext.
+ *
+ * @author Alef Arendsen
+ * @author Juergen Hoeller
+ * @see #setUrl
+ * @see TilesJstlView
+ * @see TilesConfigurer
+ * @see ComponentControllerSupport
+ * @deprecated as of Spring 3.0
+ */
+@Deprecated
+public class TilesView extends InternalResourceView {
+
+ /**
+ * Name of the attribute that will override the path of the layout page
+ * to render. A Tiles component controller can set such an attribute
+ * to dynamically switch the look and feel of a Tiles page.
+ * @see #setPath
+ */
+ public static final String PATH_ATTRIBUTE = TilesView.class.getName() + ".PATH";
+
+ /**
+ * Set the path of the layout page to render.
+ * @param request current HTTP request
+ * @param path the path of the layout page
+ * @see #PATH_ATTRIBUTE
+ */
+ public static void setPath(HttpServletRequest request, String path) {
+ request.setAttribute(PATH_ATTRIBUTE, path);
+ }
+
+
+ private DefinitionsFactory definitionsFactory;
+
+
+ @Override
+ protected void initApplicationContext() throws ApplicationContextException {
+ super.initApplicationContext();
+
+ // get definitions factory
+ this.definitionsFactory =
+ (DefinitionsFactory) getServletContext().getAttribute(TilesUtilImpl.DEFINITIONS_FACTORY);
+ if (this.definitionsFactory == null) {
+ throw new ApplicationContextException("Tiles definitions factory not found: TilesConfigurer not defined?");
+ }
+ }
+
+ /**
+ * Prepare for rendering the Tiles definition: Execute the associated
+ * component controller if any, and determine the request dispatcher path.
+ */
+ @Override
+ protected String prepareForRendering(HttpServletRequest request, HttpServletResponse response)
+ throws Exception {
+
+ // get component definition
+ ComponentDefinition definition = getComponentDefinition(this.definitionsFactory, request);
+ if (definition == null) {
+ throw new ServletException("No Tiles definition found for name '" + getUrl() + "'");
+ }
+
+ // get current component context
+ ComponentContext context = getComponentContext(definition, request);
+
+ // execute component controller associated with definition, if any
+ Controller controller = getController(definition, request);
+ if (controller != null) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Executing Tiles controller [" + controller + "]");
+ }
+ executeController(controller, context, request, response);
+ }
+
+ // determine the path of the definition
+ String path = getDispatcherPath(definition, request);
+ if (path == null) {
+ throw new ServletException(
+ "Could not determine a path for Tiles definition '" + definition.getName() + "'");
+ }
+
+ return path;
+ }
+
+ /**
+ * Determine the Tiles component definition for the given Tiles
+ * definitions factory.
+ * @param factory the Tiles definitions factory
+ * @param request current HTTP request
+ * @return the component definition
+ */
+ protected ComponentDefinition getComponentDefinition(DefinitionsFactory factory, HttpServletRequest request)
+ throws Exception {
+ return factory.getDefinition(getUrl(), request, getServletContext());
+ }
+
+ /**
+ * Determine the Tiles component context for the given Tiles definition.
+ * @param definition the Tiles definition to render
+ * @param request current HTTP request
+ * @return the component context
+ * @throws Exception if preparations failed
+ */
+ protected ComponentContext getComponentContext(ComponentDefinition definition, HttpServletRequest request)
+ throws Exception {
+ ComponentContext context = ComponentContext.getContext(request);
+ if (context == null) {
+ context = new ComponentContext(definition.getAttributes());
+ ComponentContext.setContext(context, request);
+ }
+ else {
+ context.addMissing(definition.getAttributes());
+ }
+ return context;
+ }
+
+ /**
+ * Determine and initialize the Tiles component controller for the
+ * given Tiles definition, if any.
+ * @param definition the Tiles definition to render
+ * @param request current HTTP request
+ * @return the component controller to execute, or <code>null</code> if none
+ * @throws Exception if preparations failed
+ */
+ protected Controller getController(ComponentDefinition definition, HttpServletRequest request)
+ throws Exception {
+
+ return definition.getOrCreateController();
+ }
+
+ /**
+ * Execute the given Tiles controller.
+ * @param controller the component controller to execute
+ * @param context the component context
+ * @param request current HTTP request
+ * @param response current HTTP response
+ * @throws Exception if controller execution failed
+ */
+ protected void executeController(
+ Controller controller, ComponentContext context, HttpServletRequest request, HttpServletResponse response)
+ throws Exception {
+
+ controller.perform(context, request, response, getServletContext());
+ }
+
+ /**
+ * Determine the dispatcher path for the given Tiles definition,
+ * i.e. the request dispatcher path of the layout page.
+ * @param definition the Tiles definition to render
+ * @param request current HTTP request
+ * @return the path of the layout page to render
+ * @throws Exception if preparations failed
+ */
+ protected String getDispatcherPath(ComponentDefinition definition, HttpServletRequest request)
+ throws Exception {
+
+ Object pathAttr = request.getAttribute(PATH_ATTRIBUTE);
+ return (pathAttr != null ? pathAttr.toString() : definition.getPath());
+ }
+
+} | true |
Other | spring-projects | spring-framework | 7fa910509672270f952a250c4ed64b7db69ccdac.json | SPR-6236: Reintroduce Struts support | org.springframework.web.struts/src/main/java/org/springframework/web/servlet/view/tiles/package.html | @@ -0,0 +1,10 @@
+<html>
+<body>
+
+Support classes for the integration of
+<a href="http://www.lifl.fr/~dumoulin/tiles">Tiles</a>
+(included in Struts) as Spring web view technology.
+Contains a View implementation for Tiles definitions.
+
+</body>
+</html> | true |
Other | spring-projects | spring-framework | 7fa910509672270f952a250c4ed64b7db69ccdac.json | SPR-6236: Reintroduce Struts support | org.springframework.web.struts/src/main/java/org/springframework/web/struts/ActionServletAwareProcessor.java | @@ -0,0 +1,72 @@
+/*
+ * Copyright 2002-2007 the original author or authors.
+ *
+ * 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.springframework.web.struts;
+
+import org.apache.struts.action.Action;
+import org.apache.struts.action.ActionServlet;
+
+import org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor;
+
+/**
+ * {@link org.springframework.beans.factory.config.BeanPostProcessor}
+ * implementation that passes the ActionServlet to beans that extend
+ * the Struts {@link org.apache.struts.action.Action} class.
+ * Invokes <code>Action.setServlet</code> with <code>null</dode> on
+ * bean destruction, providing the same lifecycle handling as the
+ * native Struts ActionServlet.
+ *
+ * <p>ContextLoaderPlugIn automatically registers this processor
+ * with the underlying bean factory of its WebApplicationContext.
+ *
+ * @author Juergen Hoeller
+ * @since 1.0.1
+ * @see ContextLoaderPlugIn
+ * @see org.apache.struts.action.Action#setServlet
+ * @deprecated as of Spring 3.0
+ */
+@Deprecated
+class ActionServletAwareProcessor implements DestructionAwareBeanPostProcessor {
+
+ private final ActionServlet actionServlet;
+
+
+ /**
+ * Create a new ActionServletAwareProcessor for the given servlet.
+ */
+ public ActionServletAwareProcessor(ActionServlet actionServlet) {
+ this.actionServlet = actionServlet;
+ }
+
+
+ public Object postProcessBeforeInitialization(Object bean, String beanName) {
+ if (bean instanceof Action) {
+ ((Action) bean).setServlet(this.actionServlet);
+ }
+ return bean;
+ }
+
+ public Object postProcessAfterInitialization(Object bean, String beanName) {
+ return bean;
+ }
+
+ public void postProcessBeforeDestruction(Object bean, String beanName) {
+ if (bean instanceof Action) {
+ ((Action) bean).setServlet(null);
+ }
+ }
+
+} | true |
Other | spring-projects | spring-framework | 7fa910509672270f952a250c4ed64b7db69ccdac.json | SPR-6236: Reintroduce Struts support | org.springframework.web.struts/src/main/java/org/springframework/web/struts/ActionSupport.java | @@ -0,0 +1,151 @@
+/*
+ * Copyright 2002-2005 the original author or authors.
+ *
+ * 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.springframework.web.struts;
+
+import java.io.File;
+
+import javax.servlet.ServletContext;
+
+import org.apache.struts.action.Action;
+import org.apache.struts.action.ActionServlet;
+
+import org.springframework.context.support.MessageSourceAccessor;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.util.WebUtils;
+
+/**
+ * Convenience class for Spring-aware Struts 1.1+ Actions.
+ *
+ * <p>Provides a reference to the current Spring application context, e.g.
+ * for bean lookup or resource loading. Auto-detects a ContextLoaderPlugIn
+ * context, falling back to the root WebApplicationContext. For typical
+ * usage, i.e. accessing middle tier beans, use a root WebApplicationContext.
+ *
+ * <p>For Struts DispatchActions or Lookup/MappingDispatchActions, use the
+ * analogous {@link DispatchActionSupport DispatchActionSupport} or
+ * {@link LookupDispatchActionSupport LookupDispatchActionSupport} /
+ * {@link MappingDispatchActionSupport MappingDispatchActionSupport} class,
+ * respectively.
+ *
+ * <p>As an alternative approach, you can wire your Struts Actions themselves
+ * as Spring beans, passing references to them via IoC rather than looking
+ * up references in a programmatic fashion. Check out
+ * {@link DelegatingActionProxy DelegatingActionProxy} and
+ * {@link DelegatingRequestProcessor DelegatingRequestProcessor}.
+ *
+ * @author Juergen Hoeller
+ * @since 1.0.1
+ * @see ContextLoaderPlugIn#SERVLET_CONTEXT_PREFIX
+ * @see org.springframework.web.context.WebApplicationContext#ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE
+ * @see org.springframework.web.context.ContextLoaderListener
+ * @see org.springframework.web.context.ContextLoaderServlet
+ * @see DispatchActionSupport
+ * @see LookupDispatchActionSupport
+ * @see MappingDispatchActionSupport
+ * @see DelegatingActionProxy
+ * @see DelegatingRequestProcessor
+ * @deprecated as of Spring 3.0
+ */
+@Deprecated
+public abstract class ActionSupport extends Action {
+
+ private WebApplicationContext webApplicationContext;
+
+ private MessageSourceAccessor messageSourceAccessor;
+
+
+ /**
+ * Initialize the WebApplicationContext for this Action.
+ * Invokes onInit after successful initialization of the context.
+ * @see #initWebApplicationContext
+ * @see #onInit
+ */
+ @Override
+ public void setServlet(ActionServlet actionServlet) {
+ super.setServlet(actionServlet);
+ if (actionServlet != null) {
+ this.webApplicationContext = initWebApplicationContext(actionServlet);
+ this.messageSourceAccessor = new MessageSourceAccessor(this.webApplicationContext);
+ onInit();
+ }
+ else {
+ onDestroy();
+ }
+ }
+
+ /**
+ * Fetch ContextLoaderPlugIn's WebApplicationContext from the ServletContext,
+ * falling back to the root WebApplicationContext (the usual case).
+ * @param actionServlet the associated ActionServlet
+ * @return the WebApplicationContext
+ * @throws IllegalStateException if no WebApplicationContext could be found
+ * @see DelegatingActionUtils#findRequiredWebApplicationContext
+ */
+ protected WebApplicationContext initWebApplicationContext(ActionServlet actionServlet)
+ throws IllegalStateException {
+
+ return DelegatingActionUtils.findRequiredWebApplicationContext(actionServlet, null);
+ }
+
+
+ /**
+ * Return the current Spring WebApplicationContext.
+ */
+ protected final WebApplicationContext getWebApplicationContext() {
+ return this.webApplicationContext;
+ }
+
+ /**
+ * Return a MessageSourceAccessor for the application context
+ * used by this object, for easy message access.
+ */
+ protected final MessageSourceAccessor getMessageSourceAccessor() {
+ return this.messageSourceAccessor;
+ }
+
+ /**
+ * Return the current ServletContext.
+ */
+ protected final ServletContext getServletContext() {
+ return this.webApplicationContext.getServletContext();
+ }
+
+ /**
+ * Return the temporary directory for the current web application,
+ * as provided by the servlet container.
+ * @return the File representing the temporary directory
+ */
+ protected final File getTempDir() {
+ return WebUtils.getTempDir(getServletContext());
+ }
+
+
+ /**
+ * Callback for custom initialization after the context has been set up.
+ * @see #setServlet
+ */
+ protected void onInit() {
+ }
+
+ /**
+ * Callback for custom destruction when the ActionServlet shuts down.
+ * @see #setServlet
+ */
+ protected void onDestroy() {
+ }
+
+} | true |
Other | spring-projects | spring-framework | 7fa910509672270f952a250c4ed64b7db69ccdac.json | SPR-6236: Reintroduce Struts support | org.springframework.web.struts/src/main/java/org/springframework/web/struts/AutowiringRequestProcessor.java | @@ -0,0 +1,187 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * 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.springframework.web.struts;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.struts.action.Action;
+import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.ActionServlet;
+import org.apache.struts.action.RequestProcessor;
+import org.apache.struts.config.ModuleConfig;
+
+import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.web.context.WebApplicationContext;
+
+/**
+ * Subclass of Struts's default RequestProcessor that autowires Struts Actions
+ * with Spring beans defined in ContextLoaderPlugIn's WebApplicationContext
+ * or - in case of general service layer beans - in the root WebApplicationContext.
+ *
+ * <p>In the Struts config file, you simply continue to specify the original
+ * Action class. The instance created for that class will automatically get
+ * wired with matching service layer beans, that is, bean property setters
+ * will automatically be called if a service layer bean matches the property.
+ *
+ * <pre>
+ * <action path="/login" type="myapp.MyAction"/></pre>
+ *
+ * There are two autowire modes available: "byType" and "byName". The default
+ * is "byType", matching service layer beans with the Action's bean property
+ * argument types. This behavior can be changed through specifying an "autowire"
+ * init-param for the Struts ActionServlet with the value "byName", which will
+ * match service layer bean names with the Action's bean property <i>names</i>.
+ *
+ * <p>Dependency checking is turned off by default: If no matching service
+ * layer bean can be found, the setter in question will simply not get invoked.
+ * To enforce matching service layer beans, consider specify the "dependencyCheck"
+ * init-param for the Struts ActionServlet with the value "true".
+ *
+ * <p>If you also need the Tiles setup functionality of the original
+ * TilesRequestProcessor, use AutowiringTilesRequestProcessor. As there's just
+ * a single central class to customize in Struts, we have to provide another
+ * subclass here, covering both the Tiles and the Spring delegation aspect.
+ *
+ * <p>The default implementation delegates to the DelegatingActionUtils
+ * class as fas as possible, to reuse as much code as possible despite
+ * the need to provide two RequestProcessor subclasses. If you need to
+ * subclass yet another RequestProcessor, take this class as a template,
+ * delegating to DelegatingActionUtils just like it.
+ *
+ * @author Juergen Hoeller
+ * @since 2.0
+ * @see AutowiringTilesRequestProcessor
+ * @see ContextLoaderPlugIn
+ * @see DelegatingActionUtils
+ * @deprecated as of Spring 3.0
+ */
+@Deprecated
+public class AutowiringRequestProcessor extends RequestProcessor {
+
+ private WebApplicationContext webApplicationContext;
+
+ private int autowireMode = AutowireCapableBeanFactory.AUTOWIRE_NO;
+
+ private boolean dependencyCheck = false;
+
+
+ @Override
+ public void init(ActionServlet actionServlet, ModuleConfig moduleConfig) throws ServletException {
+ super.init(actionServlet, moduleConfig);
+ if (actionServlet != null) {
+ this.webApplicationContext = initWebApplicationContext(actionServlet, moduleConfig);
+ this.autowireMode = initAutowireMode(actionServlet, moduleConfig);
+ this.dependencyCheck = initDependencyCheck(actionServlet, moduleConfig);
+ }
+ }
+
+ /**
+ * Fetch ContextLoaderPlugIn's WebApplicationContext from the ServletContext,
+ * falling back to the root WebApplicationContext. This context is supposed
+ * to contain the service layer beans to wire the Struts Actions with.
+ * @param actionServlet the associated ActionServlet
+ * @param moduleConfig the associated ModuleConfig
+ * @return the WebApplicationContext
+ * @throws IllegalStateException if no WebApplicationContext could be found
+ * @see DelegatingActionUtils#findRequiredWebApplicationContext
+ * @see ContextLoaderPlugIn#SERVLET_CONTEXT_PREFIX
+ */
+ protected WebApplicationContext initWebApplicationContext(
+ ActionServlet actionServlet, ModuleConfig moduleConfig) throws IllegalStateException {
+
+ WebApplicationContext wac =
+ DelegatingActionUtils.findRequiredWebApplicationContext(actionServlet, moduleConfig);
+ if (wac instanceof ConfigurableApplicationContext) {
+ ((ConfigurableApplicationContext) wac).getBeanFactory().ignoreDependencyType(ActionServlet.class);
+ }
+ return wac;
+ }
+
+ /**
+ * Determine the autowire mode to use for wiring Struts Actions.
+ * <p>The default implementation checks the "autowire" init-param of the
+ * Struts ActionServlet, falling back to "AUTOWIRE_BY_TYPE" as default.
+ * @param actionServlet the associated ActionServlet
+ * @param moduleConfig the associated ModuleConfig
+ * @return the autowire mode to use
+ * @see DelegatingActionUtils#getAutowireMode
+ * @see org.springframework.beans.factory.config.AutowireCapableBeanFactory#autowireBeanProperties
+ * @see org.springframework.beans.factory.config.AutowireCapableBeanFactory#AUTOWIRE_BY_TYPE
+ * @see org.springframework.beans.factory.config.AutowireCapableBeanFactory#AUTOWIRE_BY_NAME
+ */
+ protected int initAutowireMode(ActionServlet actionServlet, ModuleConfig moduleConfig) {
+ return DelegatingActionUtils.getAutowireMode(actionServlet);
+ }
+
+ /**
+ * Determine whether to apply a dependency check after wiring Struts Actions.
+ * <p>The default implementation checks the "dependencyCheck" init-param of the
+ * Struts ActionServlet, falling back to no dependency check as default.
+ * @param actionServlet the associated ActionServlet
+ * @param moduleConfig the associated ModuleConfig
+ * @return whether to enforce a dependency check or not
+ * @see DelegatingActionUtils#getDependencyCheck
+ * @see org.springframework.beans.factory.config.AutowireCapableBeanFactory#autowireBeanProperties
+ */
+ protected boolean initDependencyCheck(ActionServlet actionServlet, ModuleConfig moduleConfig) {
+ return DelegatingActionUtils.getDependencyCheck(actionServlet);
+ }
+
+
+ /**
+ * Return the current Spring WebApplicationContext.
+ */
+ protected final WebApplicationContext getWebApplicationContext() {
+ return this.webApplicationContext;
+ }
+
+ /**
+ * Return the autowire mode to use for wiring Struts Actions.
+ */
+ protected final int getAutowireMode() {
+ return autowireMode;
+ }
+
+ /**
+ * Return whether to apply a dependency check after wiring Struts Actions.
+ */
+ protected final boolean getDependencyCheck() {
+ return dependencyCheck;
+ }
+
+
+ /**
+ * Extend the base class method to autowire each created Action instance.
+ * @see org.springframework.beans.factory.config.AutowireCapableBeanFactory#autowireBeanProperties
+ */
+ @Override
+ protected Action processActionCreate(
+ HttpServletRequest request, HttpServletResponse response, ActionMapping mapping)
+ throws IOException {
+
+ Action action = super.processActionCreate(request, response, mapping);
+ getWebApplicationContext().getAutowireCapableBeanFactory().autowireBeanProperties(
+ action, getAutowireMode(), getDependencyCheck());
+ return action;
+ }
+
+} | true |
Other | spring-projects | spring-framework | 7fa910509672270f952a250c4ed64b7db69ccdac.json | SPR-6236: Reintroduce Struts support | org.springframework.web.struts/src/main/java/org/springframework/web/struts/AutowiringTilesRequestProcessor.java | @@ -0,0 +1,169 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * 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.springframework.web.struts;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.struts.action.Action;
+import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.ActionServlet;
+import org.apache.struts.config.ModuleConfig;
+import org.apache.struts.tiles.TilesRequestProcessor;
+
+import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.web.context.WebApplicationContext;
+
+/**
+ * Subclass of Struts's TilesRequestProcessor that autowires Struts Actions
+ * with Spring beans defined in ContextLoaderPlugIn's WebApplicationContext
+ * or - in case of general service layer beans - in the root WebApplicationContext.
+ *
+ * <p>Behaves like
+ * {@link AutowiringRequestProcessor AutowiringRequestProcessor},
+ * but also provides the Tiles functionality of the original TilesRequestProcessor.
+ * As there's just a single central class to customize in Struts, we have to provide
+ * another subclass here, covering both the Tiles and the Spring delegation aspect.
+ *
+ * <p>The default implementation delegates to the DelegatingActionUtils
+ * class as fas as possible, to reuse as much code as possible despite
+ * the need to provide two RequestProcessor subclasses. If you need to
+ * subclass yet another RequestProcessor, take this class as a template,
+ * delegating to DelegatingActionUtils just like it.
+ *
+ * @author Juergen Hoeller
+ * @since 2.0
+ * @see AutowiringRequestProcessor
+ * @see ContextLoaderPlugIn
+ * @see DelegatingActionUtils
+ * @deprecated as of Spring 3.0
+ */
+@Deprecated
+public class AutowiringTilesRequestProcessor extends TilesRequestProcessor {
+
+ private WebApplicationContext webApplicationContext;
+
+ private int autowireMode = AutowireCapableBeanFactory.AUTOWIRE_NO;
+
+ private boolean dependencyCheck = false;
+
+
+ @Override
+ public void init(ActionServlet actionServlet, ModuleConfig moduleConfig) throws ServletException {
+ super.init(actionServlet, moduleConfig);
+ if (actionServlet != null) {
+ this.webApplicationContext = initWebApplicationContext(actionServlet, moduleConfig);
+ this.autowireMode = initAutowireMode(actionServlet, moduleConfig);
+ this.dependencyCheck = initDependencyCheck(actionServlet, moduleConfig);
+ }
+ }
+
+ /**
+ * Fetch ContextLoaderPlugIn's WebApplicationContext from the ServletContext,
+ * falling back to the root WebApplicationContext. This context is supposed
+ * to contain the service layer beans to wire the Struts Actions with.
+ * @param actionServlet the associated ActionServlet
+ * @param moduleConfig the associated ModuleConfig
+ * @return the WebApplicationContext
+ * @throws IllegalStateException if no WebApplicationContext could be found
+ * @see DelegatingActionUtils#findRequiredWebApplicationContext
+ * @see ContextLoaderPlugIn#SERVLET_CONTEXT_PREFIX
+ */
+ protected WebApplicationContext initWebApplicationContext(
+ ActionServlet actionServlet, ModuleConfig moduleConfig) throws IllegalStateException {
+
+ WebApplicationContext wac =
+ DelegatingActionUtils.findRequiredWebApplicationContext(actionServlet, moduleConfig);
+ if (wac instanceof ConfigurableApplicationContext) {
+ ((ConfigurableApplicationContext) wac).getBeanFactory().ignoreDependencyType(ActionServlet.class);
+ }
+ return wac;
+ }
+
+ /**
+ * Determine the autowire mode to use for wiring Struts Actions.
+ * <p>The default implementation checks the "autowire" init-param of the
+ * Struts ActionServlet, falling back to "AUTOWIRE_BY_TYPE" as default.
+ * @param actionServlet the associated ActionServlet
+ * @param moduleConfig the associated ModuleConfig
+ * @return the autowire mode to use
+ * @see DelegatingActionUtils#getAutowireMode
+ * @see org.springframework.beans.factory.config.AutowireCapableBeanFactory#autowireBeanProperties
+ * @see org.springframework.beans.factory.config.AutowireCapableBeanFactory#AUTOWIRE_BY_TYPE
+ * @see org.springframework.beans.factory.config.AutowireCapableBeanFactory#AUTOWIRE_BY_NAME
+ */
+ protected int initAutowireMode(ActionServlet actionServlet, ModuleConfig moduleConfig) {
+ return DelegatingActionUtils.getAutowireMode(actionServlet);
+ }
+
+ /**
+ * Determine whether to apply a dependency check after wiring Struts Actions.
+ * <p>The default implementation checks the "dependencyCheck" init-param of the
+ * Struts ActionServlet, falling back to no dependency check as default.
+ * @param actionServlet the associated ActionServlet
+ * @param moduleConfig the associated ModuleConfig
+ * @return whether to enforce a dependency check or not
+ * @see DelegatingActionUtils#getDependencyCheck
+ * @see org.springframework.beans.factory.config.AutowireCapableBeanFactory#autowireBeanProperties
+ */
+ protected boolean initDependencyCheck(ActionServlet actionServlet, ModuleConfig moduleConfig) {
+ return DelegatingActionUtils.getDependencyCheck(actionServlet);
+ }
+
+
+ /**
+ * Return the current Spring WebApplicationContext.
+ */
+ protected final WebApplicationContext getWebApplicationContext() {
+ return this.webApplicationContext;
+ }
+
+ /**
+ * Return the autowire mode to use for wiring Struts Actions.
+ */
+ protected final int getAutowireMode() {
+ return autowireMode;
+ }
+
+ /**
+ * Return whether to apply a dependency check after wiring Struts Actions.
+ */
+ protected final boolean getDependencyCheck() {
+ return dependencyCheck;
+ }
+
+
+ /**
+ * Extend the base class method to autowire each created Action instance.
+ * @see org.springframework.beans.factory.config.AutowireCapableBeanFactory#autowireBeanProperties
+ */
+ @Override
+ protected Action processActionCreate(
+ HttpServletRequest request, HttpServletResponse response, ActionMapping mapping)
+ throws IOException {
+
+ Action action = super.processActionCreate(request, response, mapping);
+ getWebApplicationContext().getAutowireCapableBeanFactory().autowireBeanProperties(
+ action, getAutowireMode(), getDependencyCheck());
+ return action;
+ }
+
+} | true |
Other | spring-projects | spring-framework | 7fa910509672270f952a250c4ed64b7db69ccdac.json | SPR-6236: Reintroduce Struts support | org.springframework.web.struts/src/main/java/org/springframework/web/struts/ContextLoaderPlugIn.java | @@ -0,0 +1,397 @@
+/*
+ * Copyright 2002-2007 the original author or authors.
+ *
+ * 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.springframework.web.struts;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.struts.action.ActionServlet;
+import org.apache.struts.action.PlugIn;
+import org.apache.struts.config.ModuleConfig;
+
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.context.ApplicationContextException;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.util.ClassUtils;
+import org.springframework.util.StringUtils;
+import org.springframework.web.context.ConfigurableWebApplicationContext;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.context.support.WebApplicationContextUtils;
+import org.springframework.web.context.support.XmlWebApplicationContext;
+
+/**
+ * Struts 1.1+ PlugIn that loads a Spring application context for the Struts
+ * ActionServlet. This context will automatically refer to the root
+ * WebApplicationContext (loaded by ContextLoaderListener/Servlet) as parent.
+ *
+ * <p>The default namespace of the WebApplicationContext is the name of the
+ * Struts ActionServlet, suffixed with "-servlet" (e.g. "action-servlet").
+ * The default location of the XmlWebApplicationContext configuration file
+ * is therefore "/WEB-INF/action-servlet.xml".
+ *
+ * <pre>
+ * <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn"/></pre>
+ *
+ * The location of the context configuration files can be customized
+ * through the "contextConfigLocation" setting, analogous to the root
+ * WebApplicationContext and FrameworkServlet contexts.
+ *
+ * <pre>
+ * <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
+ * <set-property property="contextConfigLocation" value="/WEB-INF/action-servlet.xml /WEB-INF/myContext.xml"/>
+ * </plug-in></pre>
+ *
+ * Beans defined in the ContextLoaderPlugIn context can be accessed
+ * from conventional Struts Actions, via fetching the WebApplicationContext
+ * reference from the ServletContext. ActionSupport and DispatchActionSupport
+ * are pre-built convenience classes that provide easy access to the context.
+ *
+ * <p>It is normally preferable to access Spring's root WebApplicationContext
+ * in such scenarios, though: A shared middle tier should be defined there
+ * rather than in a ContextLoaderPlugin context, for access by any web component.
+ * ActionSupport and DispatchActionSupport autodetect the root context too.
+ *
+ * <p>A special usage of this PlugIn is to define Struts Actions themselves
+ * as beans, typically wiring them with middle tier components defined in the
+ * root context. Such Actions will then be delegated to by proxy definitions
+ * in the Struts configuration, using the DelegatingActionProxy class or
+ * the DelegatingRequestProcessor.
+ *
+ * <p>Note that you can use a single ContextLoaderPlugIn for all Struts modules.
+ * That context can in turn be loaded from multiple XML files, for example split
+ * according to Struts modules. Alternatively, define one ContextLoaderPlugIn per
+ * Struts module, specifying appropriate "contextConfigLocation" parameters.
+ *
+ * <p>Note: The idea of delegating to Spring-managed Struts Actions originated in
+ * Don Brown's <a href="http://struts.sourceforge.net/struts-spring">Spring Struts Plugin</a>.
+ * ContextLoaderPlugIn and DelegatingActionProxy constitute a clean-room
+ * implementation of the same idea, essentially superseding the original plugin.
+ * Many thanks to Don Brown and Matt Raible for the original work and for the
+ * agreement to reimplement the idea in Spring proper!
+ *
+ * @author Juergen Hoeller
+ * @since 1.0.1
+ * @see #SERVLET_CONTEXT_PREFIX
+ * @see ActionSupport
+ * @see DispatchActionSupport
+ * @see DelegatingActionProxy
+ * @see DelegatingRequestProcessor
+ * @see DelegatingTilesRequestProcessor
+ * @see org.springframework.web.context.ContextLoaderListener
+ * @see org.springframework.web.context.ContextLoaderServlet
+ * @see org.springframework.web.servlet.FrameworkServlet
+ * @deprecated as of Spring 3.0
+ */
+@Deprecated
+public class ContextLoaderPlugIn implements PlugIn {
+
+ /**
+ * Suffix for WebApplicationContext namespaces. If a Struts ActionServlet is
+ * given the name "action" in a context, the namespace used by this PlugIn will
+ * resolve to "action-servlet".
+ */
+ public static final String DEFAULT_NAMESPACE_SUFFIX = "-servlet";
+
+ /**
+ * Default context class for ContextLoaderPlugIn.
+ * @see org.springframework.web.context.support.XmlWebApplicationContext
+ */
+ public static final Class DEFAULT_CONTEXT_CLASS = XmlWebApplicationContext.class;
+
+ /**
+ * Prefix for the ServletContext attribute for the WebApplicationContext.
+ * The completion is the Struts module name.
+ */
+ public static final String SERVLET_CONTEXT_PREFIX = ContextLoaderPlugIn.class.getName() + ".CONTEXT.";
+
+
+ protected final Log logger = LogFactory.getLog(getClass());
+
+ /** Custom WebApplicationContext class */
+ private Class contextClass = DEFAULT_CONTEXT_CLASS;
+
+ /** Namespace for this servlet */
+ private String namespace;
+
+ /** Explicit context config location */
+ private String contextConfigLocation;
+
+ /** The Struts ActionServlet that this PlugIn is registered with */
+ private ActionServlet actionServlet;
+
+ /** The Struts ModuleConfig that this PlugIn is registered with */
+ private ModuleConfig moduleConfig;
+
+ /** WebApplicationContext for the ActionServlet */
+ private WebApplicationContext webApplicationContext;
+
+
+ /**
+ * Set a custom context class by name. This class must be of type WebApplicationContext,
+ * when using the default ContextLoaderPlugIn implementation, the context class
+ * must also implement ConfigurableWebApplicationContext.
+ * @see #createWebApplicationContext
+ */
+ public void setContextClassName(String contextClassName) throws ClassNotFoundException {
+ this.contextClass = ClassUtils.forName(contextClassName);
+ }
+
+ /**
+ * Set a custom context class. This class must be of type WebApplicationContext,
+ * when using the default ContextLoaderPlugIn implementation, the context class
+ * must also implement ConfigurableWebApplicationContext.
+ * @see #createWebApplicationContext
+ */
+ public void setContextClass(Class contextClass) {
+ this.contextClass = contextClass;
+ }
+
+ /**
+ * Return the custom context class.
+ */
+ public Class getContextClass() {
+ return this.contextClass;
+ }
+
+ /**
+ * Set a custom namespace for the ActionServlet,
+ * to be used for building a default context config location.
+ */
+ public void setNamespace(String namespace) {
+ this.namespace = namespace;
+ }
+
+ /**
+ * Return the namespace for the ActionServlet, falling back to default scheme if
+ * no custom namespace was set: e.g. "test-servlet" for a servlet named "test".
+ */
+ public String getNamespace() {
+ if (this.namespace != null) {
+ return this.namespace;
+ }
+ if (this.actionServlet != null) {
+ return this.actionServlet.getServletName() + DEFAULT_NAMESPACE_SUFFIX;
+ }
+ return null;
+ }
+
+ /**
+ * Set the context config location explicitly, instead of relying on the default
+ * location built from the namespace. This location string can consist of
+ * multiple locations separated by any number of commas and spaces.
+ */
+ public void setContextConfigLocation(String contextConfigLocation) {
+ this.contextConfigLocation = contextConfigLocation;
+ }
+
+ /**
+ * Return the explicit context config location, if any.
+ */
+ public String getContextConfigLocation() {
+ return this.contextConfigLocation;
+ }
+
+
+ /**
+ * Create the ActionServlet's WebApplicationContext.
+ */
+ public final void init(ActionServlet actionServlet, ModuleConfig moduleConfig) throws ServletException {
+ long startTime = System.currentTimeMillis();
+ if (logger.isInfoEnabled()) {
+ logger.info("ContextLoaderPlugIn for Struts ActionServlet '" + actionServlet.getServletName() +
+ ", module '" + moduleConfig.getPrefix() + "': initialization started");
+ }
+
+ this.actionServlet = actionServlet;
+ this.moduleConfig = moduleConfig;
+ try {
+ this.webApplicationContext = initWebApplicationContext();
+ onInit();
+ }
+ catch (RuntimeException ex) {
+ logger.error("Context initialization failed", ex);
+ throw ex;
+ }
+
+ if (logger.isInfoEnabled()) {
+ long elapsedTime = System.currentTimeMillis() - startTime;
+ logger.info("ContextLoaderPlugIn for Struts ActionServlet '" + actionServlet.getServletName() +
+ "', module '" + moduleConfig.getPrefix() + "': initialization completed in " + elapsedTime + " ms");
+ }
+ }
+
+ /**
+ * Return the Struts ActionServlet that this PlugIn is associated with.
+ */
+ public final ActionServlet getActionServlet() {
+ return actionServlet;
+ }
+
+ /**
+ * Return the name of the ActionServlet that this PlugIn is associated with.
+ */
+ public final String getServletName() {
+ return this.actionServlet.getServletName();
+ }
+
+ /**
+ * Return the ServletContext that this PlugIn is associated with.
+ */
+ public final ServletContext getServletContext() {
+ return this.actionServlet.getServletContext();
+ }
+
+ /**
+ * Return the Struts ModuleConfig that this PlugIn is associated with.
+ */
+ public final ModuleConfig getModuleConfig() {
+ return this.moduleConfig;
+ }
+
+ /**
+ * Return the prefix of the ModuleConfig that this PlugIn is associated with.
+ * @see org.apache.struts.config.ModuleConfig#getPrefix
+ */
+ public final String getModulePrefix() {
+ return this.moduleConfig.getPrefix();
+ }
+
+ /**
+ * Initialize and publish the WebApplicationContext for the ActionServlet.
+ * <p>Delegates to {@link #createWebApplicationContext} for actual creation.
+ * <p>Can be overridden in subclasses. Call <code>getActionServlet()</code>
+ * and/or <code>getModuleConfig()</code> to access the Struts configuration
+ * that this PlugIn is associated with.
+ * @throws org.springframework.beans.BeansException if the context couldn't be initialized
+ * @throws IllegalStateException if there is already a context for the Struts ActionServlet
+ * @see #getActionServlet()
+ * @see #getServletName()
+ * @see #getServletContext()
+ * @see #getModuleConfig()
+ * @see #getModulePrefix()
+ */
+ protected WebApplicationContext initWebApplicationContext() throws BeansException, IllegalStateException {
+ getServletContext().log("Initializing WebApplicationContext for Struts ActionServlet '" +
+ getServletName() + "', module '" + getModulePrefix() + "'");
+ WebApplicationContext parent = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
+
+ WebApplicationContext wac = createWebApplicationContext(parent);
+ if (logger.isInfoEnabled()) {
+ logger.info("Using context class '" + wac.getClass().getName() + "' for servlet '" + getServletName() + "'");
+ }
+
+ // Publish the context as a servlet context attribute.
+ String attrName = getServletContextAttributeName();
+ getServletContext().setAttribute(attrName, wac);
+ if (logger.isDebugEnabled()) {
+ logger.debug("Published WebApplicationContext of Struts ActionServlet '" + getServletName() +
+ "', module '" + getModulePrefix() + "' as ServletContext attribute with name [" + attrName + "]");
+ }
+
+ return wac;
+ }
+
+ /**
+ * Instantiate the WebApplicationContext for the ActionServlet, either a default
+ * XmlWebApplicationContext or a custom context class if set.
+ * <p>This implementation expects custom contexts to implement ConfigurableWebApplicationContext.
+ * Can be overridden in subclasses.
+ * @throws org.springframework.beans.BeansException if the context couldn't be initialized
+ * @see #setContextClass
+ * @see org.springframework.web.context.support.XmlWebApplicationContext
+ */
+ protected WebApplicationContext createWebApplicationContext(WebApplicationContext parent)
+ throws BeansException {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("ContextLoaderPlugIn for Struts ActionServlet '" + getServletName() +
+ "', module '" + getModulePrefix() + "' will try to create custom WebApplicationContext " +
+ "context of class '" + getContextClass().getName() + "', using parent context [" + parent + "]");
+ }
+ if (!ConfigurableWebApplicationContext.class.isAssignableFrom(getContextClass())) {
+ throw new ApplicationContextException(
+ "Fatal initialization error in ContextLoaderPlugIn for Struts ActionServlet '" + getServletName() +
+ "', module '" + getModulePrefix() + "': custom WebApplicationContext class [" +
+ getContextClass().getName() + "] is not of type ConfigurableWebApplicationContext");
+ }
+
+ ConfigurableWebApplicationContext wac =
+ (ConfigurableWebApplicationContext) BeanUtils.instantiateClass(getContextClass());
+ wac.setParent(parent);
+ wac.setServletContext(getServletContext());
+ wac.setNamespace(getNamespace());
+ if (getContextConfigLocation() != null) {
+ wac.setConfigLocations(
+ StringUtils.tokenizeToStringArray(
+ getContextConfigLocation(), ConfigurableWebApplicationContext.CONFIG_LOCATION_DELIMITERS));
+ }
+ wac.addBeanFactoryPostProcessor(
+ new BeanFactoryPostProcessor() {
+ public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
+ beanFactory.addBeanPostProcessor(new ActionServletAwareProcessor(getActionServlet()));
+ beanFactory.ignoreDependencyType(ActionServlet.class);
+ }
+ }
+ );
+
+ wac.refresh();
+ return wac;
+ }
+
+ /**
+ * Return the ServletContext attribute name for this PlugIn's WebApplicationContext.
+ * <p>The default implementation returns SERVLET_CONTEXT_PREFIX + module prefix.
+ * @see #SERVLET_CONTEXT_PREFIX
+ * @see #getModulePrefix()
+ */
+ public String getServletContextAttributeName() {
+ return SERVLET_CONTEXT_PREFIX + getModulePrefix();
+ }
+
+ /**
+ * Return this PlugIn's WebApplicationContext.
+ */
+ public final WebApplicationContext getWebApplicationContext() {
+ return webApplicationContext;
+ }
+
+ /**
+ * Callback for custom initialization after the context has been set up.
+ * @throws ServletException if initialization failed
+ */
+ protected void onInit() throws ServletException {
+ }
+
+
+ /**
+ * Close the WebApplicationContext of the ActionServlet.
+ * @see org.springframework.context.ConfigurableApplicationContext#close()
+ */
+ public void destroy() {
+ getServletContext().log("Closing WebApplicationContext of Struts ActionServlet '" +
+ getServletName() + "', module '" + getModulePrefix() + "'");
+ if (getWebApplicationContext() instanceof ConfigurableApplicationContext) {
+ ((ConfigurableApplicationContext) getWebApplicationContext()).close();
+ }
+ }
+
+} | true |
Other | spring-projects | spring-framework | 7fa910509672270f952a250c4ed64b7db69ccdac.json | SPR-6236: Reintroduce Struts support | org.springframework.web.struts/src/main/java/org/springframework/web/struts/DelegatingActionProxy.java | @@ -0,0 +1,170 @@
+/*
+ * Copyright 2002-2007 the original author or authors.
+ *
+ * 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.springframework.web.struts;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.struts.action.Action;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.ActionServlet;
+import org.apache.struts.config.ModuleConfig;
+
+import org.springframework.beans.BeansException;
+import org.springframework.web.context.WebApplicationContext;
+
+/**
+ * Proxy for a Spring-managed Struts <code>Action</code> that is defined in
+ * {@link ContextLoaderPlugIn ContextLoaderPlugIn's}
+ * {@link WebApplicationContext}.
+ *
+ * <p>The proxy is defined in the Struts config file, specifying this
+ * class as the action class. This class will delegate to a Struts
+ * <code>Action</code> bean in the <code>ContextLoaderPlugIn</code> context.
+ *
+ * <pre class="code"><action path="/login" type="org.springframework.web.struts.DelegatingActionProxy"/></pre>
+ *
+ * The name of the <code>Action</code> bean in the
+ * <code>WebApplicationContext</code> will be determined from the mapping
+ * path and module prefix. This can be customized by overriding the
+ * <code>determineActionBeanName</code> method.
+ *
+ * <p>Example:
+ * <ul>
+ * <li>mapping path "/login" -> bean name "/login"<br>
+ * <li>mapping path "/login", module prefix "/mymodule" ->
+ * bean name "/mymodule/login"
+ * </ul>
+ *
+ * <p>A corresponding bean definition in the <code>ContextLoaderPlugin</code>
+ * context would look as follows; notice that the <code>Action</code> is now
+ * able to leverage fully Spring's configuration facilities:
+ *
+ * <pre class="code">
+ * <bean name="/login" class="myapp.MyAction">
+ * <property name="...">...</property>
+ * </bean></pre>
+ *
+ * Note that you can use a single <code>ContextLoaderPlugIn</code> for all
+ * Struts modules. That context can in turn be loaded from multiple XML files,
+ * for example split according to Struts modules. Alternatively, define one
+ * <code>ContextLoaderPlugIn</code> per Struts module, specifying appropriate
+ * "contextConfigLocation" parameters. In both cases, the Spring bean name
+ * has to include the module prefix.
+ *
+ * <p>If you want to avoid having to specify <code>DelegatingActionProxy</code>
+ * as the <code>Action</code> type in your struts-config file (for example to
+ * be able to generate your Struts config file with XDoclet) consider using the
+ * {@link DelegatingRequestProcessor DelegatingRequestProcessor}.
+ * The latter's disadvantage is that it might conflict with the need
+ * for a different <code>RequestProcessor</code> subclass.
+ *
+ * <p>The default implementation delegates to the {@link DelegatingActionUtils}
+ * class as much as possible, to reuse as much code as possible with
+ * <code>DelegatingRequestProcessor</code> and
+ * {@link DelegatingTilesRequestProcessor}.
+ *
+ * <p>Note: The idea of delegating to Spring-managed Struts Actions originated in
+ * Don Brown's <a href="http://struts.sourceforge.net/struts-spring">Spring Struts Plugin</a>.
+ * <code>ContextLoaderPlugIn</code> and <code>DelegatingActionProxy</code>
+ * constitute a clean-room implementation of the same idea, essentially
+ * superseding the original plugin. Many thanks to Don Brown and Matt Raible
+ * for the original work and for the agreement to reimplement the idea in
+ * Spring proper!
+ *
+ * @author Juergen Hoeller
+ * @since 1.0.1
+ * @see #determineActionBeanName
+ * @see DelegatingRequestProcessor
+ * @see DelegatingTilesRequestProcessor
+ * @see DelegatingActionUtils
+ * @see ContextLoaderPlugIn
+ * @deprecated as of Spring 3.0
+ */
+@Deprecated
+public class DelegatingActionProxy extends Action {
+
+ /**
+ * Pass the execute call on to the Spring-managed delegate <code>Action</code>.
+ * @see #getDelegateAction
+ */
+ @Override
+ public ActionForward execute(
+ ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
+ throws Exception {
+
+ Action delegateAction = getDelegateAction(mapping);
+ return delegateAction.execute(mapping, form, request, response);
+ }
+
+
+ /**
+ * Return the delegate <code>Action</code> for the given <code>mapping</code>.
+ * <p>The default implementation determines a bean name from the
+ * given <code>ActionMapping</code> and looks up the corresponding bean in
+ * the {@link WebApplicationContext}.
+ * @param mapping the Struts <code>ActionMapping</code>
+ * @return the delegate <code>Action</code>
+ * @throws BeansException if thrown by <code>WebApplicationContext</code> methods
+ * @see #determineActionBeanName
+ */
+ protected Action getDelegateAction(ActionMapping mapping) throws BeansException {
+ WebApplicationContext wac = getWebApplicationContext(getServlet(), mapping.getModuleConfig());
+ String beanName = determineActionBeanName(mapping);
+ return (Action) wac.getBean(beanName, Action.class);
+ }
+
+ /**
+ * Fetch ContextLoaderPlugIn's {@link WebApplicationContext} from the
+ * <code>ServletContext</code>, falling back to the root
+ * <code>WebApplicationContext</code>.
+ * <p>This context is supposed to contain the Struts <code>Action</code>
+ * beans to delegate to.
+ * @param actionServlet the associated <code>ActionServlet</code>
+ * @param moduleConfig the associated <code>ModuleConfig</code>
+ * @return the <code>WebApplicationContext</code>
+ * @throws IllegalStateException if no <code>WebApplicationContext</code> could be found
+ * @see DelegatingActionUtils#findRequiredWebApplicationContext
+ * @see ContextLoaderPlugIn#SERVLET_CONTEXT_PREFIX
+ */
+ protected WebApplicationContext getWebApplicationContext(
+ ActionServlet actionServlet, ModuleConfig moduleConfig) throws IllegalStateException {
+
+ return DelegatingActionUtils.findRequiredWebApplicationContext(actionServlet, moduleConfig);
+ }
+
+ /**
+ * Determine the name of the <code>Action</code> bean, to be looked up in
+ * the <code>WebApplicationContext</code>.
+ * <p>The default implementation takes the
+ * {@link org.apache.struts.action.ActionMapping#getPath mapping path} and
+ * prepends the
+ * {@link org.apache.struts.config.ModuleConfig#getPrefix module prefix},
+ * if any.
+ * @param mapping the Struts <code>ActionMapping</code>
+ * @return the name of the Action bean
+ * @see DelegatingActionUtils#determineActionBeanName
+ * @see org.apache.struts.action.ActionMapping#getPath
+ * @see org.apache.struts.config.ModuleConfig#getPrefix
+ */
+ protected String determineActionBeanName(ActionMapping mapping) {
+ return DelegatingActionUtils.determineActionBeanName(mapping);
+ }
+
+} | true |
Other | spring-projects | spring-framework | 7fa910509672270f952a250c4ed64b7db69ccdac.json | SPR-6236: Reintroduce Struts support | org.springframework.web.struts/src/main/java/org/springframework/web/struts/DelegatingActionUtils.java | @@ -0,0 +1,212 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * 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.springframework.web.struts;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.ActionServlet;
+import org.apache.struts.config.ModuleConfig;
+
+import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.context.support.WebApplicationContextUtils;
+
+/**
+ * Common methods for letting Struts Actions work with a
+ * Spring WebApplicationContext.
+ *
+ * <p>As everything in Struts is based on concrete inheritance,
+ * we have to provide an Action subclass (DelegatingActionProxy) and
+ * two RequestProcessor subclasses (DelegatingRequestProcessor and
+ * DelegatingTilesRequestProcessor). The only way to share common
+ * functionality is a utility class like this one.
+ *
+ * @author Juergen Hoeller
+ * @since 1.0.2
+ * @see DelegatingActionProxy
+ * @see DelegatingRequestProcessor
+ * @see DelegatingTilesRequestProcessor
+ * @deprecated as of Spring 3.0
+ */
+@Deprecated
+public abstract class DelegatingActionUtils {
+
+ /**
+ * The name of the autowire init-param specified on the Struts ActionServlet:
+ * "spring.autowire"
+ */
+ public static final String PARAM_AUTOWIRE = "spring.autowire";
+
+ /**
+ * The name of the dependency check init-param specified on the Struts ActionServlet:
+ * "spring.dependencyCheck"
+ */
+ public static final String PARAM_DEPENDENCY_CHECK = "spring.dependencyCheck";
+
+ /**
+ * Value of the autowire init-param that indicates autowiring by name:
+ * "byName"
+ */
+ public static final String AUTOWIRE_BY_NAME = "byName";
+
+ /**
+ * Value of the autowire init-param that indicates autowiring by type:
+ * "byType"
+ */
+ public static final String AUTOWIRE_BY_TYPE = "byType";
+
+
+ private static final Log logger = LogFactory.getLog(DelegatingActionUtils.class);
+
+
+ /**
+ * Fetch ContextLoaderPlugIn's WebApplicationContext from the ServletContext.
+ * <p>Checks for a module-specific context first, falling back to the
+ * context for the default module else.
+ * @param actionServlet the associated ActionServlet
+ * @param moduleConfig the associated ModuleConfig (can be <code>null</code>)
+ * @return the WebApplicationContext, or <code>null</code> if none
+ * @see ContextLoaderPlugIn#SERVLET_CONTEXT_PREFIX
+ */
+ public static WebApplicationContext getWebApplicationContext(
+ ActionServlet actionServlet, ModuleConfig moduleConfig) {
+
+ WebApplicationContext wac = null;
+ String modulePrefix = null;
+
+ // Try module-specific attribute.
+ if (moduleConfig != null) {
+ modulePrefix = moduleConfig.getPrefix();
+ wac = (WebApplicationContext) actionServlet.getServletContext().getAttribute(
+ ContextLoaderPlugIn.SERVLET_CONTEXT_PREFIX + modulePrefix);
+ }
+
+ // If not found, try attribute for default module.
+ if (wac == null && !"".equals(modulePrefix)) {
+ wac = (WebApplicationContext) actionServlet.getServletContext().getAttribute(
+ ContextLoaderPlugIn.SERVLET_CONTEXT_PREFIX);
+ }
+
+ return wac;
+ }
+
+ /**
+ * Fetch ContextLoaderPlugIn's WebApplicationContext from the ServletContext.
+ * <p>Checks for a module-specific context first, falling back to the
+ * context for the default module else.
+ * @param actionServlet the associated ActionServlet
+ * @param moduleConfig the associated ModuleConfig (can be <code>null</code>)
+ * @return the WebApplicationContext
+ * @throws IllegalStateException if no WebApplicationContext could be found
+ * @see ContextLoaderPlugIn#SERVLET_CONTEXT_PREFIX
+ */
+ public static WebApplicationContext getRequiredWebApplicationContext(
+ ActionServlet actionServlet, ModuleConfig moduleConfig) throws IllegalStateException {
+
+ WebApplicationContext wac = getWebApplicationContext(actionServlet, moduleConfig);
+ // If no Struts-specific context found, throw an exception.
+ if (wac == null) {
+ throw new IllegalStateException(
+ "Could not find ContextLoaderPlugIn's WebApplicationContext as ServletContext attribute [" +
+ ContextLoaderPlugIn.SERVLET_CONTEXT_PREFIX + "]: Did you register [" +
+ ContextLoaderPlugIn.class.getName() + "]?");
+ }
+ return wac;
+ }
+
+ /**
+ * Find most specific context available: check ContextLoaderPlugIn's
+ * WebApplicationContext first, fall back to root WebApplicationContext else.
+ * <p>When checking the ContextLoaderPlugIn context: checks for a module-specific
+ * context first, falling back to the context for the default module else.
+ * @param actionServlet the associated ActionServlet
+ * @param moduleConfig the associated ModuleConfig (can be <code>null</code>)
+ * @return the WebApplicationContext
+ * @throws IllegalStateException if no WebApplicationContext could be found
+ * @see #getWebApplicationContext
+ * @see org.springframework.web.context.support.WebApplicationContextUtils#getRequiredWebApplicationContext
+ */
+ public static WebApplicationContext findRequiredWebApplicationContext(
+ ActionServlet actionServlet, ModuleConfig moduleConfig) throws IllegalStateException {
+
+ WebApplicationContext wac = getWebApplicationContext(actionServlet, moduleConfig);
+ // If no Struts-specific context found, fall back to root context.
+ if (wac == null) {
+ wac = WebApplicationContextUtils.getRequiredWebApplicationContext(actionServlet.getServletContext());
+ }
+ return wac;
+ }
+
+ /**
+ * Default implementation of Action bean determination, taking
+ * the mapping path and prepending the module prefix, if any.
+ * @param mapping the Struts ActionMapping
+ * @return the name of the Action bean
+ * @see org.apache.struts.action.ActionMapping#getPath
+ * @see org.apache.struts.config.ModuleConfig#getPrefix
+ */
+ public static String determineActionBeanName(ActionMapping mapping) {
+ String prefix = mapping.getModuleConfig().getPrefix();
+ String path = mapping.getPath();
+ String beanName = prefix + path;
+ if (logger.isDebugEnabled()) {
+ logger.debug("DelegatingActionProxy with mapping path '" + path + "' and module prefix '" +
+ prefix + "' delegating to Spring bean with name [" + beanName + "]");
+ }
+ return beanName;
+ }
+
+ /**
+ * Determine the autowire mode from the "autowire" init-param of the
+ * Struts ActionServlet, falling back to "AUTOWIRE_BY_TYPE" as default.
+ * @param actionServlet the Struts ActionServlet
+ * @return the autowire mode to use
+ * @see #PARAM_AUTOWIRE
+ * @see #AUTOWIRE_BY_NAME
+ * @see #AUTOWIRE_BY_TYPE
+ * @see org.springframework.beans.factory.config.AutowireCapableBeanFactory#autowireBeanProperties
+ * @see org.springframework.beans.factory.config.AutowireCapableBeanFactory#AUTOWIRE_BY_TYPE
+ * @see org.springframework.beans.factory.config.AutowireCapableBeanFactory#AUTOWIRE_BY_NAME
+ */
+ public static int getAutowireMode(ActionServlet actionServlet) {
+ String autowire = actionServlet.getInitParameter(PARAM_AUTOWIRE);
+ if (autowire != null) {
+ if (AUTOWIRE_BY_NAME.equals(autowire)) {
+ return AutowireCapableBeanFactory.AUTOWIRE_BY_NAME;
+ }
+ else if (!AUTOWIRE_BY_TYPE.equals(autowire)) {
+ throw new IllegalArgumentException("ActionServlet 'autowire' parameter must be 'byName' or 'byType'");
+ }
+ }
+ return AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE;
+ }
+
+ /**
+ * Determine the dependency check to use from the "dependencyCheck" init-param
+ * of the Struts ActionServlet, falling back to no dependency check as default.
+ * @param actionServlet the Struts ActionServlet
+ * @return whether to enforce a dependency check or not
+ * @see #PARAM_DEPENDENCY_CHECK
+ * @see org.springframework.beans.factory.config.AutowireCapableBeanFactory#autowireBeanProperties
+ */
+ public static boolean getDependencyCheck(ActionServlet actionServlet) {
+ String dependencyCheck = actionServlet.getInitParameter(PARAM_DEPENDENCY_CHECK);
+ return Boolean.valueOf(dependencyCheck).booleanValue();
+ }
+
+} | true |
Other | spring-projects | spring-framework | 7fa910509672270f952a250c4ed64b7db69ccdac.json | SPR-6236: Reintroduce Struts support | org.springframework.web.struts/src/main/java/org/springframework/web/struts/DelegatingRequestProcessor.java | @@ -0,0 +1,201 @@
+/*
+ * Copyright 2002-2007 the original author or authors.
+ *
+ * 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.springframework.web.struts;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.struts.action.Action;
+import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.ActionServlet;
+import org.apache.struts.action.RequestProcessor;
+import org.apache.struts.config.ModuleConfig;
+
+import org.springframework.beans.BeansException;
+import org.springframework.web.context.WebApplicationContext;
+
+/**
+ * Subclass of Struts's default {@link RequestProcessor} that looks up
+ * Spring-managed Struts {@link Action Actions} defined in
+ * {@link ContextLoaderPlugIn ContextLoaderPlugIn's} {@link WebApplicationContext}
+ * (or, as a fallback, in the root <code>WebApplicationContext</code>).
+ *
+ * <p>In the Struts config file, you can either specify the original
+ * <code>Action</code> class (as when generated by XDoclet), or no
+ * <code>Action</code> class at all. In any case, Struts will delegate to an
+ * <code>Action</code> bean in the <code>ContextLoaderPlugIn</code> context.
+ *
+ * <pre class="code"><action path="/login" type="myapp.MyAction"/></pre>
+ *
+ * or
+ *
+ * <pre class="code"><action path="/login"/></pre>
+ *
+ * The name of the <code>Action</code> bean in the
+ * <code>WebApplicationContext</code> will be determined from the mapping path
+ * and module prefix. This can be customized by overriding the
+ * {@link #determineActionBeanName} method.
+ *
+ * <p>Example:
+ * <ul>
+ * <li>mapping path "/login" -> bean name "/login"<br>
+ * <li>mapping path "/login", module prefix "/mymodule" ->
+ * bean name "/mymodule/login"
+ * </ul>
+ *
+ * <p>A corresponding bean definition in the <code>ContextLoaderPlugin</code>
+ * context would look as follows; notice that the <code>Action</code> is now
+ * able to leverage fully Spring's configuration facilities:
+ *
+ * <pre class="code">
+ * <bean name="/login" class="myapp.MyAction">
+ * <property name="...">...</property>
+ * </bean></pre>
+ *
+ * Note that you can use a single <code>ContextLoaderPlugIn</code> for all
+ * Struts modules. That context can in turn be loaded from multiple XML files,
+ * for example split according to Struts modules. Alternatively, define one
+ * <code>ContextLoaderPlugIn</code> per Struts module, specifying appropriate
+ * "contextConfigLocation" parameters. In both cases, the Spring bean name has
+ * to include the module prefix.
+ *
+ * <p>If you also need the Tiles setup functionality of the original
+ * <code>TilesRequestProcessor</code>, use
+ * <code>DelegatingTilesRequestProcessor</code>. As there is just a
+ * single central class to customize in Struts, we have to provide another
+ * subclass here, covering both the Tiles and the Spring delegation aspect.
+ *
+ * <p>If this <code>RequestProcessor</code> conflicts with the need for a
+ * different <code>RequestProcessor</code> subclass (other than
+ * <code>TilesRequestProcessor</code>), consider using
+ * {@link DelegatingActionProxy} as the Struts <code>Action</code> type in
+ * your struts-config file.
+ *
+ * <p>The default implementation delegates to the
+ * <code>DelegatingActionUtils</code> class as much as possible, to reuse as
+ * much code as possible despite the need to provide two
+ * <code>RequestProcessor</code> subclasses. If you need to subclass yet
+ * another <code>RequestProcessor</code>, take this class as a template,
+ * delegating to <code>DelegatingActionUtils</code> just like it.
+ *
+ * @author Juergen Hoeller
+ * @since 1.0.2
+ * @see #determineActionBeanName
+ * @see DelegatingTilesRequestProcessor
+ * @see DelegatingActionProxy
+ * @see DelegatingActionUtils
+ * @see ContextLoaderPlugIn
+ * @deprecated as of Spring 3.0
+ */
+@Deprecated
+public class DelegatingRequestProcessor extends RequestProcessor {
+
+ private WebApplicationContext webApplicationContext;
+
+
+ @Override
+ public void init(ActionServlet actionServlet, ModuleConfig moduleConfig) throws ServletException {
+ super.init(actionServlet, moduleConfig);
+ if (actionServlet != null) {
+ this.webApplicationContext = initWebApplicationContext(actionServlet, moduleConfig);
+ }
+ }
+
+ /**
+ * Fetch ContextLoaderPlugIn's {@link WebApplicationContext} from the
+ * <code>ServletContext</code>, falling back to the root
+ * <code>WebApplicationContext</code>.
+ * <p>This context is supposed to contain the Struts <code>Action</code>
+ * beans to delegate to.
+ * @param actionServlet the associated <code>ActionServlet</code>
+ * @param moduleConfig the associated <code>ModuleConfig</code>
+ * @return the <code>WebApplicationContext</code>
+ * @throws IllegalStateException if no <code>WebApplicationContext</code> could be found
+ * @see DelegatingActionUtils#findRequiredWebApplicationContext
+ * @see ContextLoaderPlugIn#SERVLET_CONTEXT_PREFIX
+ */
+ protected WebApplicationContext initWebApplicationContext(
+ ActionServlet actionServlet, ModuleConfig moduleConfig) throws IllegalStateException {
+
+ return DelegatingActionUtils.findRequiredWebApplicationContext(actionServlet, moduleConfig);
+ }
+
+ /**
+ * Return the <code>WebApplicationContext</code> that this processor
+ * delegates to.
+ */
+ protected final WebApplicationContext getWebApplicationContext() {
+ return this.webApplicationContext;
+ }
+
+
+ /**
+ * Override the base class method to return the delegate action.
+ * @see #getDelegateAction
+ */
+ @Override
+ protected Action processActionCreate(
+ HttpServletRequest request, HttpServletResponse response, ActionMapping mapping)
+ throws IOException {
+
+ Action action = getDelegateAction(mapping);
+ if (action != null) {
+ return action;
+ }
+ return super.processActionCreate(request, response, mapping);
+ }
+
+ /**
+ * Return the delegate <code>Action</code> for the given mapping.
+ * <p>The default implementation determines a bean name from the
+ * given <code>ActionMapping</code> and looks up the corresponding
+ * bean in the <code>WebApplicationContext</code>.
+ * @param mapping the Struts <code>ActionMapping</code>
+ * @return the delegate <code>Action</code>, or <code>null</code> if none found
+ * @throws BeansException if thrown by <code>WebApplicationContext</code> methods
+ * @see #determineActionBeanName
+ */
+ protected Action getDelegateAction(ActionMapping mapping) throws BeansException {
+ String beanName = determineActionBeanName(mapping);
+ if (!getWebApplicationContext().containsBean(beanName)) {
+ return null;
+ }
+ return (Action) getWebApplicationContext().getBean(beanName, Action.class);
+ }
+
+ /**
+ * Determine the name of the <code>Action</code> bean, to be looked up in
+ * the <code>WebApplicationContext</code>.
+ * <p>The default implementation takes the
+ * {@link org.apache.struts.action.ActionMapping#getPath mapping path} and
+ * prepends the
+ * {@link org.apache.struts.config.ModuleConfig#getPrefix module prefix},
+ * if any.
+ * @param mapping the Struts <code>ActionMapping</code>
+ * @return the name of the Action bean
+ * @see DelegatingActionUtils#determineActionBeanName
+ * @see org.apache.struts.action.ActionMapping#getPath
+ * @see org.apache.struts.config.ModuleConfig#getPrefix
+ */
+ protected String determineActionBeanName(ActionMapping mapping) {
+ return DelegatingActionUtils.determineActionBeanName(mapping);
+ }
+
+} | true |
Other | spring-projects | spring-framework | 7fa910509672270f952a250c4ed64b7db69ccdac.json | SPR-6236: Reintroduce Struts support | org.springframework.web.struts/src/main/java/org/springframework/web/struts/DelegatingTilesRequestProcessor.java | @@ -0,0 +1,147 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * 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.springframework.web.struts;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.struts.action.Action;
+import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.ActionServlet;
+import org.apache.struts.config.ModuleConfig;
+import org.apache.struts.tiles.TilesRequestProcessor;
+
+import org.springframework.beans.BeansException;
+import org.springframework.web.context.WebApplicationContext;
+
+/**
+ * Subclass of Struts's TilesRequestProcessor that autowires
+ * Struts Actions defined in ContextLoaderPlugIn's WebApplicationContext
+ * (or, as a fallback, in the root WebApplicationContext).
+ *
+ * <p>Behaves like
+ * {@link DelegatingRequestProcessor DelegatingRequestProcessor},
+ * but also provides the Tiles functionality of the original TilesRequestProcessor.
+ * As there's just a single central class to customize in Struts, we have to provide
+ * another subclass here, covering both the Tiles and the Spring delegation aspect.
+ *
+ * <p>The default implementation delegates to the DelegatingActionUtils
+ * class as fas as possible, to reuse as much code as possible despite
+ * the need to provide two RequestProcessor subclasses. If you need to
+ * subclass yet another RequestProcessor, take this class as a template,
+ * delegating to DelegatingActionUtils just like it.
+ *
+ * @author Juergen Hoeller
+ * @since 1.0.2
+ * @see DelegatingRequestProcessor
+ * @see DelegatingActionProxy
+ * @see DelegatingActionUtils
+ * @see ContextLoaderPlugIn
+ * @deprecated as of Spring 3.0
+ */
+@Deprecated
+public class DelegatingTilesRequestProcessor extends TilesRequestProcessor {
+
+ private WebApplicationContext webApplicationContext;
+
+
+ @Override
+ public void init(ActionServlet actionServlet, ModuleConfig moduleConfig) throws ServletException {
+ super.init(actionServlet, moduleConfig);
+ if (actionServlet != null) {
+ this.webApplicationContext = initWebApplicationContext(actionServlet, moduleConfig);
+ }
+ }
+
+ /**
+ * Fetch ContextLoaderPlugIn's WebApplicationContext from the ServletContext,
+ * falling back to the root WebApplicationContext. This context is supposed
+ * to contain the Struts Action beans to delegate to.
+ * @param actionServlet the associated ActionServlet
+ * @param moduleConfig the associated ModuleConfig
+ * @return the WebApplicationContext
+ * @throws IllegalStateException if no WebApplicationContext could be found
+ * @see DelegatingActionUtils#findRequiredWebApplicationContext
+ * @see ContextLoaderPlugIn#SERVLET_CONTEXT_PREFIX
+ */
+ protected WebApplicationContext initWebApplicationContext(
+ ActionServlet actionServlet, ModuleConfig moduleConfig) throws IllegalStateException {
+
+ return DelegatingActionUtils.findRequiredWebApplicationContext(actionServlet, moduleConfig);
+ }
+
+ /**
+ * Return the WebApplicationContext that this processor delegates to.
+ */
+ protected final WebApplicationContext getWebApplicationContext() {
+ return webApplicationContext;
+ }
+
+
+ /**
+ * Override the base class method to return the delegate action.
+ * @see #getDelegateAction
+ */
+ @Override
+ protected Action processActionCreate(
+ HttpServletRequest request, HttpServletResponse response, ActionMapping mapping)
+ throws IOException {
+
+ Action action = getDelegateAction(mapping);
+ if (action != null) {
+ return action;
+ }
+ return super.processActionCreate(request, response, mapping);
+ }
+
+ /**
+ * Return the delegate Action for the given mapping.
+ * <p>The default implementation determines a bean name from the
+ * given ActionMapping and looks up the corresponding bean in the
+ * WebApplicationContext.
+ * @param mapping the Struts ActionMapping
+ * @return the delegate Action, or <code>null</code> if none found
+ * @throws BeansException if thrown by WebApplicationContext methods
+ * @see #determineActionBeanName
+ */
+ protected Action getDelegateAction(ActionMapping mapping) throws BeansException {
+ String beanName = determineActionBeanName(mapping);
+ if (!getWebApplicationContext().containsBean(beanName)) {
+ return null;
+ }
+ return (Action) getWebApplicationContext().getBean(beanName, Action.class);
+ }
+
+ /**
+ * Determine the name of the Action bean, to be looked up in
+ * the WebApplicationContext.
+ * <p>The default implementation takes the mapping path and
+ * prepends the module prefix, if any.
+ * @param mapping the Struts ActionMapping
+ * @return the name of the Action bean
+ * @see DelegatingActionUtils#determineActionBeanName
+ * @see ActionMapping#getPath
+ * @see ModuleConfig#getPrefix
+ */
+ protected String determineActionBeanName(ActionMapping mapping) {
+ return DelegatingActionUtils.determineActionBeanName(mapping);
+ }
+
+} | true |
Other | spring-projects | spring-framework | 7fa910509672270f952a250c4ed64b7db69ccdac.json | SPR-6236: Reintroduce Struts support | org.springframework.web.struts/src/main/java/org/springframework/web/struts/DispatchActionSupport.java | @@ -0,0 +1,151 @@
+/*
+ * Copyright 2002-2005 the original author or authors.
+ *
+ * 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.springframework.web.struts;
+
+import java.io.File;
+
+import javax.servlet.ServletContext;
+
+import org.apache.struts.action.ActionServlet;
+import org.apache.struts.actions.DispatchAction;
+
+import org.springframework.context.support.MessageSourceAccessor;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.util.WebUtils;
+
+/**
+ * Convenience class for Spring-aware Struts 1.1+ DispatchActions.
+ *
+ * <p>Provides a reference to the current Spring application context, e.g.
+ * for bean lookup or resource loading. Auto-detects a ContextLoaderPlugIn
+ * context, falling back to the root WebApplicationContext. For typical
+ * usage, i.e. accessing middle tier beans, use a root WebApplicationContext.
+ *
+ * <p>For classic Struts Actions or Lookup/MappingDispatchActions, use the
+ * analogous {@link ActionSupport ActionSupport} or
+ * {@link LookupDispatchActionSupport LookupDispatchActionSupport} /
+ * {@link MappingDispatchActionSupport MappingDispatchActionSupport} class,
+ * respectively.
+ *
+ * <p>As an alternative approach, you can wire your Struts Actions themselves
+ * as Spring beans, passing references to them via IoC rather than looking
+ * up references in a programmatic fashion. Check out
+ * {@link DelegatingActionProxy DelegatingActionProxy} and
+ * {@link DelegatingRequestProcessor DelegatingRequestProcessor}.
+ *
+ * @author Juergen Hoeller
+ * @since 1.0.1
+ * @see ContextLoaderPlugIn#SERVLET_CONTEXT_PREFIX
+ * @see org.springframework.web.context.WebApplicationContext#ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE
+ * @see org.springframework.web.context.ContextLoaderListener
+ * @see org.springframework.web.context.ContextLoaderServlet
+ * @see ActionSupport
+ * @see LookupDispatchActionSupport
+ * @see MappingDispatchActionSupport
+ * @see DelegatingActionProxy
+ * @see DelegatingRequestProcessor
+ * @deprecated as of Spring 3.0
+ */
+@Deprecated
+public abstract class DispatchActionSupport extends DispatchAction {
+
+ private WebApplicationContext webApplicationContext;
+
+ private MessageSourceAccessor messageSourceAccessor;
+
+
+ /**
+ * Initialize the WebApplicationContext for this Action.
+ * Invokes onInit after successful initialization of the context.
+ * @see #initWebApplicationContext
+ * @see #onInit
+ */
+ @Override
+ public void setServlet(ActionServlet actionServlet) {
+ super.setServlet(actionServlet);
+ if (actionServlet != null) {
+ this.webApplicationContext = initWebApplicationContext(actionServlet);
+ this.messageSourceAccessor = new MessageSourceAccessor(this.webApplicationContext);
+ onInit();
+ }
+ else {
+ onDestroy();
+ }
+ }
+
+ /**
+ * Fetch ContextLoaderPlugIn's WebApplicationContext from the ServletContext,
+ * falling back to the root WebApplicationContext (the usual case).
+ * @param actionServlet the associated ActionServlet
+ * @return the WebApplicationContext
+ * @throws IllegalStateException if no WebApplicationContext could be found
+ * @see DelegatingActionUtils#findRequiredWebApplicationContext
+ */
+ protected WebApplicationContext initWebApplicationContext(ActionServlet actionServlet)
+ throws IllegalStateException {
+
+ return DelegatingActionUtils.findRequiredWebApplicationContext(actionServlet, null);
+ }
+
+
+ /**
+ * Return the current Spring WebApplicationContext.
+ */
+ protected final WebApplicationContext getWebApplicationContext() {
+ return this.webApplicationContext;
+ }
+
+ /**
+ * Return a MessageSourceAccessor for the application context
+ * used by this object, for easy message access.
+ */
+ protected final MessageSourceAccessor getMessageSourceAccessor() {
+ return this.messageSourceAccessor;
+ }
+
+ /**
+ * Return the current ServletContext.
+ */
+ protected final ServletContext getServletContext() {
+ return this.webApplicationContext.getServletContext();
+ }
+
+ /**
+ * Return the temporary directory for the current web application,
+ * as provided by the servlet container.
+ * @return the File representing the temporary directory
+ */
+ protected final File getTempDir() {
+ return WebUtils.getTempDir(getServletContext());
+ }
+
+
+ /**
+ * Callback for custom initialization after the context has been set up.
+ * @see #setServlet
+ */
+ protected void onInit() {
+ }
+
+ /**
+ * Callback for custom destruction when the ActionServlet shuts down.
+ * @see #setServlet
+ */
+ protected void onDestroy() {
+ }
+
+} | true |
Other | spring-projects | spring-framework | 7fa910509672270f952a250c4ed64b7db69ccdac.json | SPR-6236: Reintroduce Struts support | org.springframework.web.struts/src/main/java/org/springframework/web/struts/LookupDispatchActionSupport.java | @@ -0,0 +1,150 @@
+/*
+ * Copyright 2002-2005 the original author or authors.
+ *
+ * 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.springframework.web.struts;
+
+import java.io.File;
+
+import javax.servlet.ServletContext;
+
+import org.apache.struts.action.ActionServlet;
+import org.apache.struts.actions.LookupDispatchAction;
+
+import org.springframework.context.support.MessageSourceAccessor;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.util.WebUtils;
+
+/**
+ * Convenience class for Spring-aware Struts 1.1+ LookupDispatchActions.
+ *
+ * <p>Provides a reference to the current Spring application context, e.g.
+ * for bean lookup or resource loading. Auto-detects a ContextLoaderPlugIn
+ * context, falling back to the root WebApplicationContext. For typical
+ * usage, i.e. accessing middle tier beans, use a root WebApplicationContext.
+ *
+ * <p>For classic Struts Actions, DispatchActions or MappingDispatchActions,
+ * use the analogous {@link ActionSupport ActionSupport} or
+ * {@link DispatchActionSupport DispatchActionSupport} /
+ * {@link MappingDispatchActionSupport MappingDispatchActionSupport} class.
+ *
+ * <p>As an alternative approach, you can wire your Struts Actions themselves
+ * as Spring beans, passing references to them via IoC rather than looking
+ * up references in a programmatic fashion. Check out
+ * {@link DelegatingActionProxy DelegatingActionProxy} and
+ * {@link DelegatingRequestProcessor DelegatingRequestProcessor}.
+ *
+ * @author Juergen Hoeller
+ * @since 1.1
+ * @see ContextLoaderPlugIn#SERVLET_CONTEXT_PREFIX
+ * @see WebApplicationContext#ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE
+ * @see org.springframework.web.context.ContextLoaderListener
+ * @see org.springframework.web.context.ContextLoaderServlet
+ * @see ActionSupport
+ * @see DispatchActionSupport
+ * @see MappingDispatchActionSupport
+ * @see DelegatingActionProxy
+ * @see DelegatingRequestProcessor
+ * @deprecated as of Spring 3.0
+ */
+@Deprecated
+public abstract class LookupDispatchActionSupport extends LookupDispatchAction {
+
+ private WebApplicationContext webApplicationContext;
+
+ private MessageSourceAccessor messageSourceAccessor;
+
+
+ /**
+ * Initialize the WebApplicationContext for this Action.
+ * Invokes onInit after successful initialization of the context.
+ * @see #initWebApplicationContext
+ * @see #onInit
+ */
+ @Override
+ public void setServlet(ActionServlet actionServlet) {
+ super.setServlet(actionServlet);
+ if (actionServlet != null) {
+ this.webApplicationContext = initWebApplicationContext(actionServlet);
+ this.messageSourceAccessor = new MessageSourceAccessor(this.webApplicationContext);
+ onInit();
+ }
+ else {
+ onDestroy();
+ }
+ }
+
+ /**
+ * Fetch ContextLoaderPlugIn's WebApplicationContext from the ServletContext,
+ * falling back to the root WebApplicationContext (the usual case).
+ * @param actionServlet the associated ActionServlet
+ * @return the WebApplicationContext
+ * @throws IllegalStateException if no WebApplicationContext could be found
+ * @see DelegatingActionUtils#findRequiredWebApplicationContext
+ */
+ protected WebApplicationContext initWebApplicationContext(ActionServlet actionServlet)
+ throws IllegalStateException {
+
+ return DelegatingActionUtils.findRequiredWebApplicationContext(actionServlet, null);
+ }
+
+
+ /**
+ * Return the current Spring WebApplicationContext.
+ */
+ protected final WebApplicationContext getWebApplicationContext() {
+ return this.webApplicationContext;
+ }
+
+ /**
+ * Return a MessageSourceAccessor for the application context
+ * used by this object, for easy message access.
+ */
+ protected final MessageSourceAccessor getMessageSourceAccessor() {
+ return this.messageSourceAccessor;
+ }
+
+ /**
+ * Return the current ServletContext.
+ */
+ protected final ServletContext getServletContext() {
+ return this.webApplicationContext.getServletContext();
+ }
+
+ /**
+ * Return the temporary directory for the current web application,
+ * as provided by the servlet container.
+ * @return the File representing the temporary directory
+ */
+ protected final File getTempDir() {
+ return WebUtils.getTempDir(getServletContext());
+ }
+
+
+ /**
+ * Callback for custom initialization after the context has been set up.
+ * @see #setServlet
+ */
+ protected void onInit() {
+ }
+
+ /**
+ * Callback for custom destruction when the ActionServlet shuts down.
+ * @see #setServlet
+ */
+ protected void onDestroy() {
+ }
+
+} | true |
Other | spring-projects | spring-framework | 7fa910509672270f952a250c4ed64b7db69ccdac.json | SPR-6236: Reintroduce Struts support | org.springframework.web.struts/src/main/java/org/springframework/web/struts/MappingDispatchActionSupport.java | @@ -0,0 +1,150 @@
+/*
+ * Copyright 2002-2005 the original author or authors.
+ *
+ * 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.springframework.web.struts;
+
+import java.io.File;
+
+import javax.servlet.ServletContext;
+
+import org.apache.struts.action.ActionServlet;
+import org.apache.struts.actions.MappingDispatchAction;
+
+import org.springframework.context.support.MessageSourceAccessor;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.util.WebUtils;
+
+/**
+ * Convenience class for Spring-aware Struts 1.2 MappingDispatchActions.
+ *
+ * <p>Provides a reference to the current Spring application context, e.g.
+ * for bean lookup or resource loading. Auto-detects a ContextLoaderPlugIn
+ * context, falling back to the root WebApplicationContext. For typical
+ * usage, i.e. accessing middle tier beans, use a root WebApplicationContext.
+ *
+ * <p>For classic Struts Actions, DispatchActions or LookupDispatchActions,
+ * use the analogous {@link ActionSupport ActionSupport} or
+ * {@link DispatchActionSupport DispatchActionSupport} /
+ * {@link LookupDispatchActionSupport LookupDispatchActionSupport} class.
+ *
+ * <p>As an alternative approach, you can wire your Struts Actions themselves
+ * as Spring beans, passing references to them via IoC rather than looking
+ * up references in a programmatic fashion. Check out
+ * {@link DelegatingActionProxy DelegatingActionProxy} and
+ * {@link DelegatingRequestProcessor DelegatingRequestProcessor}.
+ *
+ * @author Juergen Hoeller
+ * @since 1.1.3
+ * @see ContextLoaderPlugIn#SERVLET_CONTEXT_PREFIX
+ * @see WebApplicationContext#ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE
+ * @see org.springframework.web.context.ContextLoaderListener
+ * @see org.springframework.web.context.ContextLoaderServlet
+ * @see ActionSupport
+ * @see DispatchActionSupport
+ * @see LookupDispatchActionSupport
+ * @see DelegatingActionProxy
+ * @see DelegatingRequestProcessor
+ * @deprecated as of Spring 3.0
+ */
+@Deprecated
+public abstract class MappingDispatchActionSupport extends MappingDispatchAction {
+
+ private WebApplicationContext webApplicationContext;
+
+ private MessageSourceAccessor messageSourceAccessor;
+
+
+ /**
+ * Initialize the WebApplicationContext for this Action.
+ * Invokes onInit after successful initialization of the context.
+ * @see #initWebApplicationContext
+ * @see #onInit
+ */
+ @Override
+ public void setServlet(ActionServlet actionServlet) {
+ super.setServlet(actionServlet);
+ if (actionServlet != null) {
+ this.webApplicationContext = initWebApplicationContext(actionServlet);
+ this.messageSourceAccessor = new MessageSourceAccessor(this.webApplicationContext);
+ onInit();
+ }
+ else {
+ onDestroy();
+ }
+ }
+
+ /**
+ * Fetch ContextLoaderPlugIn's WebApplicationContext from the ServletContext,
+ * falling back to the root WebApplicationContext (the usual case).
+ * @param actionServlet the associated ActionServlet
+ * @return the WebApplicationContext
+ * @throws IllegalStateException if no WebApplicationContext could be found
+ * @see DelegatingActionUtils#findRequiredWebApplicationContext
+ */
+ protected WebApplicationContext initWebApplicationContext(ActionServlet actionServlet)
+ throws IllegalStateException {
+
+ return DelegatingActionUtils.findRequiredWebApplicationContext(actionServlet, null);
+ }
+
+
+ /**
+ * Return the current Spring WebApplicationContext.
+ */
+ protected final WebApplicationContext getWebApplicationContext() {
+ return this.webApplicationContext;
+ }
+
+ /**
+ * Return a MessageSourceAccessor for the application context
+ * used by this object, for easy message access.
+ */
+ protected final MessageSourceAccessor getMessageSourceAccessor() {
+ return this.messageSourceAccessor;
+ }
+
+ /**
+ * Return the current ServletContext.
+ */
+ protected final ServletContext getServletContext() {
+ return this.webApplicationContext.getServletContext();
+ }
+
+ /**
+ * Return the temporary directory for the current web application,
+ * as provided by the servlet container.
+ * @return the File representing the temporary directory
+ */
+ protected final File getTempDir() {
+ return WebUtils.getTempDir(getServletContext());
+ }
+
+
+ /**
+ * Callback for custom initialization after the context has been set up.
+ * @see #setServlet
+ */
+ protected void onInit() {
+ }
+
+ /**
+ * Callback for custom destruction when the ActionServlet shuts down.
+ * @see #setServlet
+ */
+ protected void onDestroy() {
+ }
+
+} | true |
Other | spring-projects | spring-framework | 7fa910509672270f952a250c4ed64b7db69ccdac.json | SPR-6236: Reintroduce Struts support | org.springframework.web.struts/src/main/java/org/springframework/web/struts/SpringBindingActionForm.java | @@ -0,0 +1,288 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * 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.springframework.web.struts;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Iterator;
+import java.util.Locale;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.commons.beanutils.BeanUtilsBean;
+import org.apache.commons.beanutils.ConvertUtilsBean;
+import org.apache.commons.beanutils.PropertyUtilsBean;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.struts.Globals;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionMessage;
+import org.apache.struts.action.ActionMessages;
+import org.apache.struts.util.MessageResources;
+
+import org.springframework.context.MessageSourceResolvable;
+import org.springframework.validation.Errors;
+import org.springframework.validation.FieldError;
+import org.springframework.validation.ObjectError;
+
+/**
+ * A thin Struts ActionForm adapter that delegates to Spring's more complete
+ * and advanced data binder and Errors object underneath the covers to bind
+ * to POJOs and manage rejected values.
+ *
+ * <p>Exposes Spring-managed errors to the standard Struts view tags, through
+ * exposing a corresponding Struts ActionMessages object as request attribute.
+ * Also exposes current field values in a Struts-compliant fashion, including
+ * rejected values (which Spring's binding keeps even for non-String fields).
+ *
+ * <p>Consequently, Struts views can be written in a completely traditional
+ * fashion (with standard <code>html:form</code>, <code>html:errors</code>, etc),
+ * seamlessly accessing a Spring-bound POJO form object underneath.
+ *
+ * <p>Note this ActionForm is designed explicitly for use in <i>request scope</i>.
+ * It expects to receive an <code>expose</code> call from the Action, passing
+ * in the Errors object to expose plus the current HttpServletRequest.
+ *
+ * <p>Example definition in <code>struts-config.xml</code>:
+ *
+ * <pre>
+ * <form-beans>
+ * <form-bean name="actionForm" type="org.springframework.web.struts.SpringBindingActionForm"/>
+ * </form-beans></pre>
+ *
+ * Example code in a custom Struts <code>Action</code>:
+ *
+ * <pre>
+ * public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception {
+ * SpringBindingActionForm form = (SpringBindingActionForm) actionForm;
+ * MyPojoBean bean = ...;
+ * ServletRequestDataBinder binder = new ServletRequestDataBinder(bean, "myPojo");
+ * binder.bind(request);
+ * form.expose(binder.getBindingResult(), request);
+ * return actionMapping.findForward("success");
+ * }</pre>
+ *
+ * This class is compatible with both Struts 1.2.x and Struts 1.1.
+ * On Struts 1.2, default messages registered with Spring binding errors
+ * are exposed when none of the error codes could be resolved.
+ * On Struts 1.1, this is not possible due to a limitation in the Struts
+ * message facility; hence, we expose the plain default error code there.
+ *
+ * @author Keith Donald
+ * @author Juergen Hoeller
+ * @since 1.2.2
+ * @see #expose(org.springframework.validation.Errors, javax.servlet.http.HttpServletRequest)
+ * @deprecated as of Spring 3.0
+ */
+@Deprecated
+public class SpringBindingActionForm extends ActionForm {
+
+ private static final Log logger = LogFactory.getLog(SpringBindingActionForm.class);
+
+ private static boolean defaultActionMessageAvailable = true;
+
+
+ static {
+ // Register special PropertyUtilsBean subclass that knows how to
+ // extract field values from a SpringBindingActionForm.
+ // As a consequence of the static nature of Commons BeanUtils,
+ // we have to resort to this initialization hack here.
+ ConvertUtilsBean convUtils = new ConvertUtilsBean();
+ PropertyUtilsBean propUtils = new SpringBindingAwarePropertyUtilsBean();
+ BeanUtilsBean beanUtils = new BeanUtilsBean(convUtils, propUtils);
+ BeanUtilsBean.setInstance(beanUtils);
+
+ // Determine whether the Struts 1.2 support for default messages
+ // is available on ActionMessage: ActionMessage(String, boolean)
+ // with "false" to be passed into the boolean flag.
+ try {
+ ActionMessage.class.getConstructor(new Class[] {String.class, boolean.class});
+ }
+ catch (NoSuchMethodException ex) {
+ defaultActionMessageAvailable = false;
+ }
+ }
+
+
+ private Errors errors;
+
+ private Locale locale;
+
+ private MessageResources messageResources;
+
+
+ /**
+ * Set the Errors object that this SpringBindingActionForm is supposed
+ * to wrap. The contained field values and errors will be exposed
+ * to the view, accessible through Struts standard tags.
+ * @param errors the Spring Errors object to wrap, usually taken from
+ * a DataBinder that has been used for populating a POJO form object
+ * @param request the HttpServletRequest to retrieve the attributes from
+ * @see org.springframework.validation.DataBinder#getBindingResult()
+ */
+ public void expose(Errors errors, HttpServletRequest request) {
+ this.errors = errors;
+
+ // Obtain the locale from Struts well-known location.
+ this.locale = (Locale) request.getSession().getAttribute(Globals.LOCALE_KEY);
+
+ // Obtain the MessageResources from Struts' well-known location.
+ this.messageResources = (MessageResources) request.getAttribute(Globals.MESSAGES_KEY);
+
+ if (errors != null && errors.hasErrors()) {
+ // Add global ActionError instances from the Spring Errors object.
+ ActionMessages actionMessages = (ActionMessages) request.getAttribute(Globals.ERROR_KEY);
+ if (actionMessages == null) {
+ request.setAttribute(Globals.ERROR_KEY, getActionMessages());
+ }
+ else {
+ actionMessages.add(getActionMessages());
+ }
+ }
+ }
+
+
+ /**
+ * Return an ActionMessages representation of this SpringBindingActionForm,
+ * exposing all errors contained in the underlying Spring Errors object.
+ * @see org.springframework.validation.Errors#getAllErrors()
+ */
+ private ActionMessages getActionMessages() {
+ ActionMessages actionMessages = new ActionMessages();
+ Iterator it = this.errors.getAllErrors().iterator();
+ while (it.hasNext()) {
+ ObjectError objectError = (ObjectError) it.next();
+ String effectiveMessageKey = findEffectiveMessageKey(objectError);
+ if (effectiveMessageKey == null && !defaultActionMessageAvailable) {
+ // Need to specify default code despite it not being resolvable:
+ // Struts 1.1 ActionMessage doesn't support default messages.
+ effectiveMessageKey = objectError.getCode();
+ }
+ ActionMessage message = (effectiveMessageKey != null) ?
+ new ActionMessage(effectiveMessageKey, resolveArguments(objectError.getArguments())) :
+ new ActionMessage(objectError.getDefaultMessage(), false);
+ if (objectError instanceof FieldError) {
+ FieldError fieldError = (FieldError) objectError;
+ actionMessages.add(fieldError.getField(), message);
+ }
+ else {
+ actionMessages.add(ActionMessages.GLOBAL_MESSAGE, message);
+ }
+ }
+ if (logger.isDebugEnabled()) {
+ logger.debug("Final ActionMessages used for binding: " + actionMessages);
+ }
+ return actionMessages;
+ }
+
+ private Object[] resolveArguments(Object[] arguments) {
+ if (arguments == null || arguments.length == 0) {
+ return arguments;
+ }
+ for (int i = 0; i < arguments.length; i++) {
+ Object arg = arguments[i];
+ if (arg instanceof MessageSourceResolvable) {
+ MessageSourceResolvable resolvable = (MessageSourceResolvable)arg;
+ String[] codes = resolvable.getCodes();
+ boolean resolved = false;
+ if (this.messageResources != null) {
+ for (int j = 0; j < codes.length; j++) {
+ String code = codes[j];
+ if (this.messageResources.isPresent(this.locale, code)) {
+ arguments[i] = this.messageResources.getMessage(
+ this.locale, code, resolveArguments(resolvable.getArguments()));
+ resolved = true;
+ break;
+ }
+ }
+ }
+ if (!resolved) {
+ arguments[i] = resolvable.getDefaultMessage();
+ }
+ }
+ }
+ return arguments;
+ }
+
+ /**
+ * Find the most specific message key for the given error.
+ * @param error the ObjectError to find a message key for
+ * @return the most specific message key found
+ */
+ private String findEffectiveMessageKey(ObjectError error) {
+ if (this.messageResources != null) {
+ String[] possibleMatches = error.getCodes();
+ for (int i = 0; i < possibleMatches.length; i++) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Looking for error code '" + possibleMatches[i] + "'");
+ }
+ if (this.messageResources.isPresent(this.locale, possibleMatches[i])) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Found error code '" + possibleMatches[i] + "' in resource bundle");
+ }
+ return possibleMatches[i];
+ }
+ }
+ }
+ if (logger.isDebugEnabled()) {
+ logger.debug("Could not find a suitable message error code, returning default message");
+ }
+ return null;
+ }
+
+
+ /**
+ * Get the formatted value for the property at the provided path.
+ * The formatted value is a string value for display, converted
+ * via a registered property editor.
+ * @param propertyPath the property path
+ * @return the formatted property value
+ * @throws NoSuchMethodException if called during Struts binding
+ * (without Spring Errors object being exposed), to indicate no
+ * available property to Struts
+ */
+ private Object getFieldValue(String propertyPath) throws NoSuchMethodException {
+ if (this.errors == null) {
+ throw new NoSuchMethodException(
+ "No bean properties exposed to Struts binding - performing Spring binding later on");
+ }
+ return this.errors.getFieldValue(propertyPath);
+ }
+
+
+ /**
+ * Special subclass of PropertyUtilsBean that it is aware of SpringBindingActionForm
+ * and uses it for retrieving field values. The field values will be taken from
+ * the underlying POJO form object that the Spring Errors object was created for.
+ */
+ private static class SpringBindingAwarePropertyUtilsBean extends PropertyUtilsBean {
+
+ @Override
+ public Object getNestedProperty(Object bean, String propertyPath)
+ throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
+
+ // Extract Spring-managed field value in case of SpringBindingActionForm.
+ if (bean instanceof SpringBindingActionForm) {
+ SpringBindingActionForm form = (SpringBindingActionForm) bean;
+ return form.getFieldValue(propertyPath);
+ }
+
+ // Else fall back to default PropertyUtils behavior.
+ return super.getNestedProperty(bean, propertyPath);
+ }
+ }
+
+} | true |
Other | spring-projects | spring-framework | 7fa910509672270f952a250c4ed64b7db69ccdac.json | SPR-6236: Reintroduce Struts support | org.springframework.web.struts/src/main/java/org/springframework/web/struts/package-info.java | @@ -0,0 +1,28 @@
+/**
+ * Support classes for integrating a Struts web tier with a Spring middle
+ * tier which is typically hosted in a Spring root WebApplicationContext.
+ *
+ * <p>Supports easy access to the Spring root WebApplicationContext
+ * from Struts Actions via the ActionSupport and DispatchActionSupport
+ * classes. Actions have full access to Spring's WebApplicationContext
+ * facilities in this case, and explicitly look up Spring-managed beans.
+ *
+ * <p>Also supports wiring Struts Actions as Spring-managed beans in
+ * a ContextLoaderPlugIn context, passing middle tier references to them
+ * via bean references, using the Action path as bean name. There are two
+ * ways to make Struts delegate Action lookup to the ContextLoaderPlugIn:
+ *
+ * <ul>
+ * <li>Use DelegationActionProxy as Action "type" in struts-config.
+ * There's no further setup necessary; you can choose any RequestProcessor.
+ * Each such proxy will automatically delegate to the corresponding
+ * Spring-managed Action bean in the ContextLoaderPlugIn context.
+ *
+ * <li>Configure DelegatingRequestProcessor as "processorClass" in
+ * struts-config, using the original Action "type" (possibly generated
+ * by XDoclet) or no "type" at all. To also use Tiles, configure
+ * DelegatingTilesRequestProcessor instead.
+ * </ul>
+ */
+@Deprecated
+package org.springframework.web.struts;
\ No newline at end of file | true |
Other | spring-projects | spring-framework | 7fa910509672270f952a250c4ed64b7db69ccdac.json | SPR-6236: Reintroduce Struts support | org.springframework.web.struts/src/test/java/org/springframework/web/servlet/view/tiles/TestComponentController.java | @@ -0,0 +1,36 @@
+/*
+ * Copyright 2002-2005 the original author or authors.
+ *
+ * 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.springframework.web.servlet.view.tiles;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.struts.tiles.ComponentContext;
+
+/**
+ * @author Juergen Hoeller
+ * @since 22.08.2003
+ */
+public class TestComponentController extends ComponentControllerSupport {
+
+ @Override
+ protected void doPerform(ComponentContext componentContext, HttpServletRequest request, HttpServletResponse response) {
+ request.setAttribute("testAttr", "testVal");
+ TilesView.setPath(request, "/WEB-INF/jsp/layout.jsp");
+ }
+
+} | true |
Other | spring-projects | spring-framework | 7fa910509672270f952a250c4ed64b7db69ccdac.json | SPR-6236: Reintroduce Struts support | org.springframework.web.struts/src/test/java/org/springframework/web/servlet/view/tiles/TilesViewTests.java | @@ -0,0 +1,181 @@
+/*
+ * Copyright 2002-2008 the original author or authors.
+ *
+ * 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.springframework.web.servlet.view.tiles;
+
+import java.util.HashMap;
+import java.util.Locale;
+import javax.servlet.jsp.jstl.core.Config;
+import javax.servlet.jsp.jstl.fmt.LocalizationContext;
+
+import org.apache.struts.taglib.tiles.ComponentConstants;
+import org.apache.struts.tiles.ComponentContext;
+import org.apache.struts.tiles.PathAttribute;
+import static org.junit.Assert.*;
+import org.junit.Test;
+
+import org.springframework.mock.web.MockHttpServletRequest;
+import org.springframework.mock.web.MockHttpServletResponse;
+import org.springframework.mock.web.MockServletContext;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.context.support.StaticWebApplicationContext;
+import org.springframework.web.servlet.DispatcherServlet;
+import org.springframework.web.servlet.View;
+import org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver;
+import org.springframework.web.servlet.i18n.FixedLocaleResolver;
+import org.springframework.web.servlet.view.InternalResourceViewResolver;
+
+/**
+ * @author Alef Arendsen
+ * @author Juergen Hoeller
+ */
+public class TilesViewTests {
+
+ protected StaticWebApplicationContext prepareWebApplicationContext() throws Exception {
+ StaticWebApplicationContext wac = new StaticWebApplicationContext();
+ MockServletContext sc = new MockServletContext("/org/springframework/web/servlet/view/tiles/");
+ wac.setServletContext(sc);
+ wac.refresh();
+
+ TilesConfigurer tc = new TilesConfigurer();
+ tc.setDefinitions(new String[] {"tiles-test.xml"});
+ tc.setValidateDefinitions(true);
+ tc.setApplicationContext(wac);
+ tc.afterPropertiesSet();
+
+ return wac;
+ }
+
+ @Test
+ public void tilesView() throws Exception {
+ WebApplicationContext wac = prepareWebApplicationContext();
+
+ InternalResourceViewResolver irvr = new InternalResourceViewResolver();
+ irvr.setApplicationContext(wac);
+ irvr.setViewClass(TilesView.class);
+ View view = irvr.resolveViewName("testTile", new Locale("nl", ""));
+
+ MockHttpServletRequest request = new MockHttpServletRequest(wac.getServletContext());
+ MockHttpServletResponse response = new MockHttpServletResponse();
+ request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
+ request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, new AcceptHeaderLocaleResolver());
+
+ view.render(new HashMap<String, Object>(), request, response);
+ assertEquals("/WEB-INF/jsp/layout.jsp", response.getForwardedUrl());
+ ComponentContext cc = (ComponentContext) request.getAttribute(ComponentConstants.COMPONENT_CONTEXT);
+ assertNotNull(cc);
+ PathAttribute attr = (PathAttribute) cc.getAttribute("content");
+ assertEquals("/WEB-INF/jsp/content.jsp", attr.getValue());
+
+ view.render(new HashMap<String, Object>(), request, response);
+ assertEquals("/WEB-INF/jsp/layout.jsp", response.getForwardedUrl());
+ cc = (ComponentContext) request.getAttribute(ComponentConstants.COMPONENT_CONTEXT);
+ assertNotNull(cc);
+ attr = (PathAttribute) cc.getAttribute("content");
+ assertEquals("/WEB-INF/jsp/content.jsp", attr.getValue());
+ }
+
+ @Test
+ public void tilesJstlView() throws Exception {
+ Locale locale = !Locale.GERMAN.equals(Locale.getDefault()) ? Locale.GERMAN : Locale.FRENCH;
+
+ StaticWebApplicationContext wac = prepareWebApplicationContext();
+
+ InternalResourceViewResolver irvr = new InternalResourceViewResolver();
+ irvr.setApplicationContext(wac);
+ irvr.setViewClass(TilesJstlView.class);
+ View view = irvr.resolveViewName("testTile", new Locale("nl", ""));
+
+ MockHttpServletRequest request = new MockHttpServletRequest(wac.getServletContext());
+ MockHttpServletResponse response = new MockHttpServletResponse();
+ request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
+ request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, new FixedLocaleResolver(locale));
+ wac.addMessage("code1", locale, "messageX");
+ view.render(new HashMap<String, Object>(), request, response);
+
+ assertEquals("/WEB-INF/jsp/layout.jsp", response.getForwardedUrl());
+ ComponentContext cc = (ComponentContext) request.getAttribute(ComponentConstants.COMPONENT_CONTEXT);
+ assertNotNull(cc);
+ PathAttribute attr = (PathAttribute) cc.getAttribute("content");
+ assertEquals("/WEB-INF/jsp/content.jsp", attr.getValue());
+
+ assertEquals(locale, Config.get(request, Config.FMT_LOCALE));
+ LocalizationContext lc = (LocalizationContext) Config.get(request, Config.FMT_LOCALIZATION_CONTEXT);
+ assertEquals("messageX", lc.getResourceBundle().getString("code1"));
+ }
+
+ @Test
+ public void tilesJstlViewWithContextParam() throws Exception {
+ Locale locale = !Locale.GERMAN.equals(Locale.getDefault()) ? Locale.GERMAN : Locale.FRENCH;
+
+ StaticWebApplicationContext wac = prepareWebApplicationContext();
+ ((MockServletContext) wac.getServletContext()).addInitParameter(
+ Config.FMT_LOCALIZATION_CONTEXT, "org/springframework/web/servlet/view/tiles/context-messages");
+
+ InternalResourceViewResolver irvr = new InternalResourceViewResolver();
+ irvr.setApplicationContext(wac);
+ irvr.setViewClass(TilesJstlView.class);
+ View view = irvr.resolveViewName("testTile", new Locale("nl", ""));
+
+ MockHttpServletRequest request = new MockHttpServletRequest(wac.getServletContext());
+ MockHttpServletResponse response = new MockHttpServletResponse();
+ wac.addMessage("code1", locale, "messageX");
+ request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
+ request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, new FixedLocaleResolver(locale));
+
+ view.render(new HashMap<String, Object>(), request, response);
+ assertEquals("/WEB-INF/jsp/layout.jsp", response.getForwardedUrl());
+ ComponentContext cc = (ComponentContext) request.getAttribute(ComponentConstants.COMPONENT_CONTEXT);
+ assertNotNull(cc);
+ PathAttribute attr = (PathAttribute) cc.getAttribute("content");
+ assertEquals("/WEB-INF/jsp/content.jsp", attr.getValue());
+
+ LocalizationContext lc = (LocalizationContext) Config.get(request, Config.FMT_LOCALIZATION_CONTEXT);
+ assertEquals("message1", lc.getResourceBundle().getString("code1"));
+ assertEquals("message2", lc.getResourceBundle().getString("code2"));
+ }
+
+ @Test
+ public void tilesViewWithController() throws Exception {
+ WebApplicationContext wac = prepareWebApplicationContext();
+
+ InternalResourceViewResolver irvr = new InternalResourceViewResolver();
+ irvr.setApplicationContext(wac);
+ irvr.setViewClass(TilesView.class);
+ View view = irvr.resolveViewName("testTileWithController", new Locale("nl", ""));
+
+ MockHttpServletRequest request = new MockHttpServletRequest(wac.getServletContext());
+ MockHttpServletResponse response = new MockHttpServletResponse();
+ request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
+ request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, new AcceptHeaderLocaleResolver());
+ view.render(new HashMap<String, Object>(), request, response);
+ assertEquals("/WEB-INF/jsp/layout.jsp", response.getForwardedUrl());
+ ComponentContext cc = (ComponentContext) request.getAttribute(ComponentConstants.COMPONENT_CONTEXT);
+ assertNotNull(cc);
+ PathAttribute attr = (PathAttribute) cc.getAttribute("content");
+ assertEquals("/WEB-INF/jsp/otherContent.jsp", attr.getValue());
+ assertEquals("testVal", request.getAttribute("testAttr"));
+
+ view.render(new HashMap<String, Object>(), request, response);
+ assertEquals("/WEB-INF/jsp/layout.jsp", response.getForwardedUrl());
+ cc = (ComponentContext) request.getAttribute(ComponentConstants.COMPONENT_CONTEXT);
+ assertNotNull(cc);
+ attr = (PathAttribute) cc.getAttribute("content");
+ assertEquals("/WEB-INF/jsp/otherContent.jsp", attr.getValue());
+ assertEquals("testVal", request.getAttribute("testAttr"));
+ }
+
+} | true |
Other | spring-projects | spring-framework | 7fa910509672270f952a250c4ed64b7db69ccdac.json | SPR-6236: Reintroduce Struts support | org.springframework.web.struts/src/test/java/org/springframework/web/struts/StrutsSupportTests.java | @@ -0,0 +1,337 @@
+/*
+ * Copyright 2002-2005 the original author or authors.
+ *
+ * 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.springframework.web.struts;
+
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.ActionServlet;
+import org.apache.struts.config.ModuleConfig;
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+
+import org.springframework.mock.web.MockHttpServletRequest;
+import org.springframework.mock.web.MockHttpServletResponse;
+import org.springframework.mock.web.MockServletContext;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.context.support.StaticWebApplicationContext;
+
+/**
+ * @author Juergen Hoeller
+ * @since 09.04.2004
+ */
+public class StrutsSupportTests {
+
+ @Test
+ public void actionSupportWithContextLoaderPlugIn() throws ServletException {
+ StaticWebApplicationContext wac = new StaticWebApplicationContext();
+ wac.addMessage("test", Locale.getDefault(), "testmessage");
+ final ServletContext servletContext = new MockServletContext();
+ wac.setServletContext(servletContext);
+ wac.refresh();
+ servletContext.setAttribute(ContextLoaderPlugIn.SERVLET_CONTEXT_PREFIX, wac);
+
+ ActionServlet actionServlet = new ActionServlet() {
+ @Override
+ public ServletContext getServletContext() {
+ return servletContext;
+ }
+ };
+ ActionSupport action = new ActionSupport() {
+ };
+ action.setServlet(actionServlet);
+
+ assertEquals(wac, action.getWebApplicationContext());
+ assertEquals(servletContext, action.getServletContext());
+ assertEquals("testmessage", action.getMessageSourceAccessor().getMessage("test"));
+
+ action.setServlet(null);
+ }
+
+ @Test
+ public void actionSupportWithRootContext() throws ServletException {
+ StaticWebApplicationContext wac = new StaticWebApplicationContext();
+ wac.addMessage("test", Locale.getDefault(), "testmessage");
+ final ServletContext servletContext = new MockServletContext();
+ wac.setServletContext(servletContext);
+ wac.refresh();
+ servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
+
+ ActionServlet actionServlet = new ActionServlet() {
+ @Override
+ public ServletContext getServletContext() {
+ return servletContext;
+ }
+ };
+ ActionSupport action = new ActionSupport() {
+ };
+ action.setServlet(actionServlet);
+
+ assertEquals(wac, action.getWebApplicationContext());
+ assertEquals(servletContext, action.getServletContext());
+ assertEquals("testmessage", action.getMessageSourceAccessor().getMessage("test"));
+
+ action.setServlet(null);
+ }
+
+ @Test
+ public void dispatchActionSupportWithContextLoaderPlugIn() throws ServletException {
+ StaticWebApplicationContext wac = new StaticWebApplicationContext();
+ wac.addMessage("test", Locale.getDefault(), "testmessage");
+ final ServletContext servletContext = new MockServletContext();
+ wac.setServletContext(servletContext);
+ wac.refresh();
+ servletContext.setAttribute(ContextLoaderPlugIn.SERVLET_CONTEXT_PREFIX, wac);
+
+ ActionServlet actionServlet = new ActionServlet() {
+ @Override
+ public ServletContext getServletContext() {
+ return servletContext;
+ }
+ };
+ DispatchActionSupport action = new DispatchActionSupport() {
+ };
+ action.setServlet(actionServlet);
+
+ assertEquals(wac, action.getWebApplicationContext());
+ assertEquals(servletContext, action.getServletContext());
+ assertEquals("testmessage", action.getMessageSourceAccessor().getMessage("test"));
+
+ action.setServlet(null);
+ }
+
+ @Test
+ public void dispatchActionSupportWithRootContext() throws ServletException {
+ StaticWebApplicationContext wac = new StaticWebApplicationContext();
+ wac.addMessage("test", Locale.getDefault(), "testmessage");
+ final ServletContext servletContext = new MockServletContext();
+ wac.setServletContext(servletContext);
+ wac.refresh();
+ servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
+
+ ActionServlet actionServlet = new ActionServlet() {
+ @Override
+ public ServletContext getServletContext() {
+ return servletContext;
+ }
+ };
+ DispatchActionSupport action = new DispatchActionSupport() {
+ };
+ action.setServlet(actionServlet);
+
+ assertEquals(wac, action.getWebApplicationContext());
+ assertEquals(servletContext, action.getServletContext());
+ assertEquals("testmessage", action.getMessageSourceAccessor().getMessage("test"));
+
+ action.setServlet(null);
+ }
+
+ @Test
+ public void lookupDispatchActionSupportWithContextLoaderPlugIn() throws ServletException {
+ StaticWebApplicationContext wac = new StaticWebApplicationContext();
+ wac.addMessage("test", Locale.getDefault(), "testmessage");
+ final ServletContext servletContext = new MockServletContext();
+ wac.setServletContext(servletContext);
+ wac.refresh();
+ servletContext.setAttribute(ContextLoaderPlugIn.SERVLET_CONTEXT_PREFIX, wac);
+
+ ActionServlet actionServlet = new ActionServlet() {
+ @Override
+ public ServletContext getServletContext() {
+ return servletContext;
+ }
+ };
+ LookupDispatchActionSupport action = new LookupDispatchActionSupport() {
+ @Override
+ protected Map getKeyMethodMap() {
+ return new HashMap();
+ }
+ };
+ action.setServlet(actionServlet);
+
+ assertEquals(wac, action.getWebApplicationContext());
+ assertEquals(servletContext, action.getServletContext());
+ assertEquals("testmessage", action.getMessageSourceAccessor().getMessage("test"));
+
+ action.setServlet(null);
+ }
+
+ @Test
+ public void lookupDispatchActionSupportWithRootContext() throws ServletException {
+ StaticWebApplicationContext wac = new StaticWebApplicationContext();
+ wac.addMessage("test", Locale.getDefault(), "testmessage");
+ final ServletContext servletContext = new MockServletContext();
+ wac.setServletContext(servletContext);
+ wac.refresh();
+ servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
+
+ ActionServlet actionServlet = new ActionServlet() {
+ @Override
+ public ServletContext getServletContext() {
+ return servletContext;
+ }
+ };
+ LookupDispatchActionSupport action = new LookupDispatchActionSupport() {
+ @Override
+ protected Map getKeyMethodMap() {
+ return new HashMap();
+ }
+ };
+ action.setServlet(actionServlet);
+
+ assertEquals(wac, action.getWebApplicationContext());
+ assertEquals(servletContext, action.getServletContext());
+ assertEquals("testmessage", action.getMessageSourceAccessor().getMessage("test"));
+
+ action.setServlet(null);
+ }
+
+ @Test
+ public void testDelegatingActionProxy() throws Exception {
+ final MockServletContext servletContext = new MockServletContext("/org/springframework/web/struts/");
+ ContextLoaderPlugIn plugin = new ContextLoaderPlugIn();
+ ActionServlet actionServlet = new ActionServlet() {
+ @Override
+ public String getServletName() {
+ return "action";
+ }
+ @Override
+ public ServletContext getServletContext() {
+ return servletContext;
+ }
+ };
+
+ ModuleConfig moduleConfig = createMock(ModuleConfig.class);
+ expect(moduleConfig.getPrefix()).andReturn("").anyTimes();
+ replay(moduleConfig);
+
+ plugin.init(actionServlet, moduleConfig);
+ assertTrue(servletContext.getAttribute(ContextLoaderPlugIn.SERVLET_CONTEXT_PREFIX) != null);
+
+ DelegatingActionProxy proxy = new DelegatingActionProxy();
+ proxy.setServlet(actionServlet);
+ ActionMapping mapping = new ActionMapping();
+ mapping.setPath("/test");
+ mapping.setModuleConfig(moduleConfig);
+ ActionForward forward = proxy.execute(
+ mapping, null, new MockHttpServletRequest(servletContext), new MockHttpServletResponse());
+ assertEquals("/test", forward.getPath());
+
+ TestAction testAction = (TestAction) plugin.getWebApplicationContext().getBean("/test");
+ assertTrue(testAction.getServlet() != null);
+ proxy.setServlet(null);
+ plugin.destroy();
+ assertTrue(testAction.getServlet() == null);
+
+ verify(moduleConfig);
+ }
+
+ @Test
+ public void delegatingActionProxyWithModule() throws Exception {
+ final MockServletContext servletContext = new MockServletContext("/org/springframework/web/struts/WEB-INF");
+ ContextLoaderPlugIn plugin = new ContextLoaderPlugIn();
+ plugin.setContextConfigLocation("action-servlet.xml");
+ ActionServlet actionServlet = new ActionServlet() {
+ @Override
+ public String getServletName() {
+ return "action";
+ }
+ @Override
+ public ServletContext getServletContext() {
+ return servletContext;
+ }
+ };
+
+ ModuleConfig moduleConfig = createMock(ModuleConfig.class);
+ expect(moduleConfig.getPrefix()).andReturn("/module").anyTimes();
+ replay(moduleConfig);
+
+ plugin.init(actionServlet, moduleConfig);
+ assertTrue(servletContext.getAttribute(ContextLoaderPlugIn.SERVLET_CONTEXT_PREFIX) == null);
+ assertTrue(servletContext.getAttribute(ContextLoaderPlugIn.SERVLET_CONTEXT_PREFIX + "/module") != null);
+
+ DelegatingActionProxy proxy = new DelegatingActionProxy();
+ proxy.setServlet(actionServlet);
+ ActionMapping mapping = new ActionMapping();
+ mapping.setPath("/test2");
+ mapping.setModuleConfig(moduleConfig);
+ ActionForward forward = proxy.execute(
+ mapping, null, new MockHttpServletRequest(servletContext), new MockHttpServletResponse());
+ assertEquals("/module/test2", forward.getPath());
+
+ TestAction testAction = (TestAction) plugin.getWebApplicationContext().getBean("/module/test2");
+ assertTrue(testAction.getServlet() != null);
+ proxy.setServlet(null);
+ plugin.destroy();
+ assertTrue(testAction.getServlet() == null);
+
+ verify(moduleConfig);
+ }
+
+ @Test
+ public void delegatingActionProxyWithModuleAndDefaultContext() throws Exception {
+ final MockServletContext servletContext = new MockServletContext("/org/springframework/web/struts/WEB-INF");
+ ContextLoaderPlugIn plugin = new ContextLoaderPlugIn();
+ plugin.setContextConfigLocation("action-servlet.xml");
+ ActionServlet actionServlet = new ActionServlet() {
+ @Override
+ public String getServletName() {
+ return "action";
+ }
+ @Override
+ public ServletContext getServletContext() {
+ return servletContext;
+ }
+ };
+
+ ModuleConfig defaultModuleConfig = createMock(ModuleConfig.class);
+ expect(defaultModuleConfig.getPrefix()).andReturn("").anyTimes();
+
+ ModuleConfig moduleConfig = createMock(ModuleConfig.class);
+ expect(moduleConfig.getPrefix()).andReturn("/module").anyTimes();
+
+ replay(defaultModuleConfig, moduleConfig);
+
+ plugin.init(actionServlet, defaultModuleConfig);
+ assertTrue(servletContext.getAttribute(ContextLoaderPlugIn.SERVLET_CONTEXT_PREFIX) != null);
+ assertTrue(servletContext.getAttribute(ContextLoaderPlugIn.SERVLET_CONTEXT_PREFIX + "/module") == null);
+
+ DelegatingActionProxy proxy = new DelegatingActionProxy();
+ proxy.setServlet(actionServlet);
+ ActionMapping mapping = new ActionMapping();
+ mapping.setPath("/test2");
+ mapping.setModuleConfig(moduleConfig);
+ ActionForward forward = proxy.execute(
+ mapping, null, new MockHttpServletRequest(servletContext), new MockHttpServletResponse());
+ assertEquals("/module/test2", forward.getPath());
+
+ TestAction testAction = (TestAction) plugin.getWebApplicationContext().getBean("/module/test2");
+ assertTrue(testAction.getServlet() != null);
+ proxy.setServlet(null);
+ plugin.destroy();
+ assertTrue(testAction.getServlet() == null);
+
+ verify(defaultModuleConfig, moduleConfig);
+ }
+
+} | true |
Other | spring-projects | spring-framework | 7fa910509672270f952a250c4ed64b7db69ccdac.json | SPR-6236: Reintroduce Struts support | org.springframework.web.struts/src/test/java/org/springframework/web/struts/TestAction.java | @@ -0,0 +1,48 @@
+/*
+ * Copyright 2002-2006 the original author or authors.
+ *
+ * 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.springframework.web.struts;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.struts.action.Action;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+
+import org.springframework.beans.factory.BeanNameAware;
+
+/**
+ * @author Juergen Hoeller
+ * @since 09.04.2004
+ */
+public class TestAction extends Action implements BeanNameAware {
+
+ private String beanName;
+
+ public void setBeanName(String beanName) {
+ this.beanName = beanName;
+ }
+
+ @Override
+ public ActionForward execute(
+ ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response){
+
+ return new ActionForward(this.beanName);
+ }
+
+} | true |
Other | spring-projects | spring-framework | 7fa910509672270f952a250c4ed64b7db69ccdac.json | SPR-6236: Reintroduce Struts support | org.springframework.web.struts/src/test/resources/log4j.xml | @@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+ <!-- Appenders -->
+ <appender name="console" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out" />
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%-5p: %c - %m%n" />
+ </layout>
+ </appender>
+
+ <logger name="org.springframework.beans">
+ <level value="warn" />
+ </logger>
+
+ <logger name="org.springframework.binding">
+ <level value="debug" />
+ </logger>
+
+ <!-- Root Logger -->
+ <root>
+ <priority value="warn" />
+ <appender-ref ref="console" />
+ </root>
+
+</log4j:configuration>
\ No newline at end of file | true |
Other | spring-projects | spring-framework | 7fa910509672270f952a250c4ed64b7db69ccdac.json | SPR-6236: Reintroduce Struts support | org.springframework.web.struts/src/test/resources/org/springframework/web/servlet/view/tiles/context-messages.properties | @@ -0,0 +1,6 @@
+code1=message1
+code2=message2
+
+# Example taken from the javadocs for the java.text.MessageFormat class
+message.format.example1=At '{1,time}' on "{1,date}", there was "{2}" on planet {0,number,integer}.
+message.format.example2=This is a test message in the message catalog with no args. | true |
Other | spring-projects | spring-framework | 7fa910509672270f952a250c4ed64b7db69ccdac.json | SPR-6236: Reintroduce Struts support | org.springframework.web.struts/src/test/resources/org/springframework/web/servlet/view/tiles/context-messages_en_GB.properties | @@ -0,0 +1,2 @@
+# Example taken from the javadocs for the java.text.MessageFormat class
+message.format.example1=At '{1,time}' on "{1,date}", there was "{2}" on station number {0,number,integer}.
\ No newline at end of file | true |
Other | spring-projects | spring-framework | 7fa910509672270f952a250c4ed64b7db69ccdac.json | SPR-6236: Reintroduce Struts support | org.springframework.web.struts/src/test/resources/org/springframework/web/servlet/view/tiles/context-messages_en_US.properties | @@ -0,0 +1,5 @@
+code1=message1
+
+# Example taken from the javadocs for the java.text.MessageFormat class
+message.format.example1=At '{1,time}' on "{1,date}", there was "{2}" on planet {0,number,integer}.
+message.format.example2=This is a test message in the message catalog with no args.
\ No newline at end of file | true |
Other | spring-projects | spring-framework | 7fa910509672270f952a250c4ed64b7db69ccdac.json | SPR-6236: Reintroduce Struts support | org.springframework.web.struts/src/test/resources/org/springframework/web/servlet/view/tiles/tiles-test.xml | @@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+
+<!DOCTYPE tiles-definitions PUBLIC
+ "-//Apache Software Foundation//DTD Tiles Configuration 1.1//EN"
+ "http://jakarta.apache.org/struts/dtds/tiles-config_1_1.dtd">
+
+<tiles-definitions>
+
+ <definition name="testTile" path="/WEB-INF/jsp/layout.jsp">
+ <put name="content" value="/WEB-INF/jsp/content.jsp" type="page"/>
+ </definition>
+
+ <definition name="testTileWithController" controllerClass="org.springframework.web.servlet.view.tiles.TestComponentController">
+ <put name="content" value="/WEB-INF/jsp/otherContent.jsp" type="page"/>
+ </definition>
+
+</tiles-definitions>
\ No newline at end of file | true |
Other | spring-projects | spring-framework | 7fa910509672270f952a250c4ed64b7db69ccdac.json | SPR-6236: Reintroduce Struts support | org.springframework.web.struts/src/test/resources/org/springframework/web/struts/WEB-INF/action-servlet.xml | @@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
+
+<beans>
+
+ <bean name="/test" class="org.springframework.web.struts.TestAction"/>
+
+ <bean name="/module/test2" class="org.springframework.web.struts.TestAction"/>
+
+</beans> | true |
Other | spring-projects | spring-framework | 7fa910509672270f952a250c4ed64b7db69ccdac.json | SPR-6236: Reintroduce Struts support | org.springframework.web.struts/template.mf | @@ -0,0 +1,19 @@
+Bundle-SymbolicName: org.springframework.web.struts
+Bundle-Name: Spring Web Struts
+Bundle-Vendor: SpringSource
+Bundle-ManifestVersion: 2
+Import-Template:
+ javax.servlet.*;version="[2.4.0, 3.0.0)",
+ org.apache.commons.beanutils.*;version="[1.7.0, 2.0.0)",
+ org.apache.commons.logging.*;version="[1.0.4, 2.0.0)",
+ org.apache.struts.*;version="[1.2.9, 2.0.0)",
+ org.springframework.beans.*;version="[3.0.0, 3.0.1)",
+ org.springframework.context.*;version="[3.0.0, 3.0.1)",
+ org.springframework.util.*;version="[3.0.0, 3.0.1)",
+ org.springframework.validation.*;version="[3.0.0, 3.0.1)",
+ org.springframework.web.*;version="[3.0.0, 3.0.1)"
+Ignored-Existing-Headers:
+ Bnd-LastModified,
+ Import-Package,
+ Export-Package,
+ Tool | true |
Other | spring-projects | spring-framework | 7fa910509672270f952a250c4ed64b7db69ccdac.json | SPR-6236: Reintroduce Struts support | org.springframework.web.struts/web-struts.iml | @@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module relativePaths="true" type="JAVA_MODULE" version="4">
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
+ <exclude-output />
+ <content url="file://$MODULE_DIR$">
+ <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/src/main/resources" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
+ <sourceFolder url="file://$MODULE_DIR$/src/test/resources" isTestSource="true" />
+ <excludeFolder url="file://$MODULE_DIR$/target" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="module" module-name="beans" />
+ <orderEntry type="module" module-name="context" />
+ <orderEntry type="module" module-name="core" />
+ <orderEntry type="module" module-name="test" />
+ <orderEntry type="module" module-name="web" />
+ <orderEntry type="library" name="Commons Logging" level="project" />
+ <orderEntry type="library" name="javax.servlet" level="project" />
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$IVY_CACHE$/org.apache.struts/com.springsource.org.apache.struts/1.2.9/com.springsource.org.apache.struts-1.2.9.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES>
+ <root url="jar://$IVY_CACHE$/org.apache.struts/com.springsource.org.apache.struts/1.2.9/com.springsource.org.apache.struts-sources-1.2.9.jar!/" />
+ </SOURCES>
+ </library>
+ </orderEntry>
+ <orderEntry type="library" name="JUnit" level="project" />
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$IVY_CACHE$/org.apache.commons/com.springsource.org.apache.commons.beanutils/1.7.0/com.springsource.org.apache.commons.beanutils-1.7.0.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES>
+ <root url="jar://$IVY_CACHE$/org.apache.commons/com.springsource.org.apache.commons.beanutils/1.7.0/com.springsource.org.apache.commons.beanutils-sources-1.7.0.jar!/" />
+ </SOURCES>
+ </library>
+ </orderEntry>
+ <orderEntry type="library" name="EasyMock" level="project" />
+ <orderEntry type="module" module-name="web-servlet" />
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$IVY_CACHE$/javax.servlet/com.springsource.javax.servlet.jsp.jstl/1.1.2/com.springsource.javax.servlet.jsp.jstl-1.1.2.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES>
+ <root url="jar://$IVY_CACHE$/javax.servlet/com.springsource.javax.servlet.jsp.jstl/1.1.2/com.springsource.javax.servlet.jsp.jstl-sources-1.1.2.jar!/" />
+ </SOURCES>
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$IVY_CACHE$/javax.servlet/com.springsource.javax.servlet.jsp/2.1.0/com.springsource.javax.servlet.jsp-2.1.0.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES>
+ <root url="jar://$IVY_CACHE$/javax.servlet/com.springsource.javax.servlet.jsp/2.1.0/com.springsource.javax.servlet.jsp-sources-2.1.0.jar!/" />
+ </SOURCES>
+ </library>
+ </orderEntry>
+ </component>
+</module>
+ | true |
Other | spring-projects | spring-framework | b58069655003bf6dba077d9e49b57a2670a0ce8a.json | Exclude Jetty version of servlet API | org.springframework.web/pom.xml | @@ -160,6 +160,12 @@
<artifactId>jetty</artifactId>
<version>6.1.9</version>
<scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <artifactId>servlet-api-2.5</artifactId>
+ <groupId>org.mortbay.jetty</groupId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>xmlunit</groupId> | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.