diff --git a/build.gradle b/build.gradle index c9ac3724630..c2a7ac81217 100644 --- a/build.gradle +++ b/build.gradle @@ -443,15 +443,14 @@ project("spring-web") { optional(project(":spring-oxm")) // for MarshallingHttpMessageConverter compile("aopalliance:aopalliance:1.0") provided("javax.el:javax.el-api:2.2.4") - provided("javax.faces:jsf-api:1.2_08") + provided("com.sun.faces:jsf-api:2.1.7") provided("javax.portlet:portlet-api:2.0") provided("javax.servlet:javax.servlet-api:3.0.1") provided("javax.servlet.jsp:jsp-api:2.1") provided("javax.activation:activation:1.1") optional("com.caucho:hessian:3.2.1") optional("rome:rome:1.0") - optional("commons-fileupload:commons-fileupload:1.2") - optional("commons-io:commons-io:1.3") + optional("commons-fileupload:commons-fileupload:1.3") optional("org.apache.httpcomponents:httpclient:4.2") optional("org.codehaus.jackson:jackson-mapper-asl:1.4.2") optional("com.fasterxml.jackson.core:jackson-databind:2.0.1") diff --git a/spring-web/src/main/java/org/springframework/web/jsf/DelegatingVariableResolver.java b/spring-web/src/main/java/org/springframework/web/jsf/DelegatingVariableResolver.java deleted file mode 100644 index 4b3b4858bfe..00000000000 --- a/spring-web/src/main/java/org/springframework/web/jsf/DelegatingVariableResolver.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright 2002-2012 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.jsf; - -import javax.faces.context.FacesContext; -import javax.faces.el.EvaluationException; -import javax.faces.el.VariableResolver; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.beans.factory.BeanFactory; -import org.springframework.util.Assert; -import org.springframework.web.context.WebApplicationContext; - -/** - * JSF 1.1 {@code VariableResolver} that first delegates to the - * original resolver of the underlying JSF implementation (for resolving - * managed-bean objects as defined in {@code faces-config.xml} - * as well as well-known implicit EL attributes), then to the Spring - * root {@code WebApplicationContext} (for resolving Spring beans). - * - *

Configure this resolver in your {@code faces-config.xml} file as follows: - * - *

- * <application>
- *   ...
- *   <variable-resolver>org.springframework.web.jsf.DelegatingVariableResolver</variable-resolver>
- * </application>
- * - * All your JSF expressions can then implicitly refer to the names of - * Spring-managed service layer beans, for example in property values of - * JSF-managed beans: - * - *
- * <managed-bean>
- *   <managed-bean-name>myJsfManagedBean</managed-bean-name>
- *   <managed-bean-class>example.MyJsfManagedBean</managed-bean-class>
- *   <managed-bean-scope>session</managed-bean-scope>
- *   <managed-property>
- *     <property-name>mySpringManagedBusinessObject</property-name>
- *     <value>#{mySpringManagedBusinessObject}</value>
- *   </managed-property>
- * </managed-bean>
- * - * with "mySpringManagedBusinessObject" defined as Spring bean in - * applicationContext.xml: - * - *
- * <bean id="mySpringManagedBusinessObject" class="example.MySpringManagedBusinessObject">
- *   ...
- * </bean>
- * - * @author Juergen Hoeller - * @since 1.1 - * @see WebApplicationContextVariableResolver - * @see FacesContextUtils#getRequiredWebApplicationContext - * @deprecated as of Spring 3.2, in favor of the JSF 1.2 based - * {@link org.springframework.web.jsf.el.SpringBeanFacesELResolver} - */ -@Deprecated -public class DelegatingVariableResolver extends VariableResolver { - - /** Logger available to subclasses */ - protected final Log logger = LogFactory.getLog(getClass()); - - protected final VariableResolver originalVariableResolver; - - - /** - * Create a new DelegatingVariableResolver, using the given original VariableResolver. - *

A JSF implementation will automatically pass its original resolver into the - * constructor of a configured resolver, provided that there is a corresponding - * constructor argument. - * @param originalVariableResolver the original VariableResolver - */ - public DelegatingVariableResolver(VariableResolver originalVariableResolver) { - Assert.notNull(originalVariableResolver, "Original JSF VariableResolver must not be null"); - this.originalVariableResolver = originalVariableResolver; - } - - /** - * Return the original JSF VariableResolver that this resolver delegates to. - * Used to resolve standard JSF-managed beans. - */ - protected final VariableResolver getOriginalVariableResolver() { - return this.originalVariableResolver; - } - - - /** - * Delegate to the original VariableResolver first, then try to - * resolve the variable as Spring bean in the root WebApplicationContext. - */ - @Override - public Object resolveVariable(FacesContext facesContext, String name) throws EvaluationException { - Object value = resolveOriginal(facesContext, name); - if (value != null) { - return value; - } - Object bean = resolveSpringBean(facesContext, name); - if (bean != null) { - return bean; - } - return null; - } - - /** - * Resolve the attribute via the original JSF VariableResolver. - */ - protected Object resolveOriginal(FacesContext facesContext, String name) { - Object value = getOriginalVariableResolver().resolveVariable(facesContext, name); - if (value != null && logger.isTraceEnabled()) { - logger.trace("Successfully resolved variable '" + name + "' via original VariableResolver"); - } - return value; - } - - /** - * Resolve the attribute as a Spring bean in the ApplicationContext. - */ - protected Object resolveSpringBean(FacesContext facesContext, String name) { - BeanFactory bf = getBeanFactory(facesContext); - if (bf.containsBean(name)) { - if (logger.isTraceEnabled()) { - logger.trace("Successfully resolved variable '" + name + "' in Spring BeanFactory"); - } - return bf.getBean(name); - } - else { - return null; - } - } - - /** - * Retrieve the Spring BeanFactory to delegate bean name resolution to. - *

The default implementation delegates to {@code getWebApplicationContext}. - * Can be overridden to provide an arbitrary BeanFactory reference to resolve - * against; usually, this will be a full Spring ApplicationContext. - * @param facesContext the current JSF context - * @return the Spring BeanFactory (never {@code null}) - * @see #getWebApplicationContext - */ - protected BeanFactory getBeanFactory(FacesContext facesContext) { - return getWebApplicationContext(facesContext); - } - - /** - * Retrieve the web application context to delegate bean name resolution to. - *

The default implementation delegates to FacesContextUtils. - * @param facesContext the current JSF context - * @return the Spring web application context (never {@code null}) - * @see FacesContextUtils#getRequiredWebApplicationContext - */ - protected WebApplicationContext getWebApplicationContext(FacesContext facesContext) { - return FacesContextUtils.getRequiredWebApplicationContext(facesContext); - } - -} diff --git a/spring-web/src/main/java/org/springframework/web/jsf/FacesContextUtils.java b/spring-web/src/main/java/org/springframework/web/jsf/FacesContextUtils.java index 3c2519f5a6d..7750f2d4458 100644 --- a/spring-web/src/main/java/org/springframework/web/jsf/FacesContextUtils.java +++ b/spring-web/src/main/java/org/springframework/web/jsf/FacesContextUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 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. @@ -24,9 +24,9 @@ import org.springframework.web.context.WebApplicationContext; import org.springframework.web.util.WebUtils; /** - * Convenience methods to retrieve the root WebApplicationContext for a given - * FacesContext. This is e.g. useful for accessing a Spring context from - * custom JSF code. + * Convenience methods to retrieve Spring's root {@link WebApplicationContext} + * for a given JSF {@link FacesContext}. This is useful for accessing a + * Spring application context from custom JSF-based code. * *

Analogous to Spring's WebApplicationContextUtils for the ServletContext. * @@ -38,8 +38,8 @@ import org.springframework.web.util.WebUtils; public abstract class FacesContextUtils { /** - * Find the root WebApplicationContext for this web app, which is - * typically loaded via ContextLoaderListener or ContextLoaderServlet. + * Find the root {@link WebApplicationContext} for this web app, + * typically loaded via ContextLoaderListener. *

Will rethrow an exception that happened on root context startup, * to differentiate between a failed context startup and no context at all. * @param fc the FacesContext to find the web application context for @@ -66,8 +66,8 @@ public abstract class FacesContextUtils { } /** - * Find the root WebApplicationContext for this web app, which is - * typically loaded via ContextLoaderListener or ContextLoaderServlet. + * Find the root {@link WebApplicationContext} for this web app, + * typically loaded via ContextLoaderListener. *

Will rethrow an exception that happened on root context startup, * to differentiate between a failed context startup and no context at all. * @param fc the FacesContext to find the web application context for @@ -76,7 +76,7 @@ public abstract class FacesContextUtils { * @see org.springframework.web.context.WebApplicationContext#ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE */ public static WebApplicationContext getRequiredWebApplicationContext(FacesContext fc) - throws IllegalStateException { + throws IllegalStateException { WebApplicationContext wac = getWebApplicationContext(fc); if (wac == null) { diff --git a/spring-web/src/main/java/org/springframework/web/jsf/SpringBeanVariableResolver.java b/spring-web/src/main/java/org/springframework/web/jsf/SpringBeanVariableResolver.java deleted file mode 100644 index 5292cfa5ccd..00000000000 --- a/spring-web/src/main/java/org/springframework/web/jsf/SpringBeanVariableResolver.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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.jsf; - -import javax.faces.context.FacesContext; -import javax.faces.el.EvaluationException; -import javax.faces.el.VariableResolver; - -/** - * This is a subclass of the JSF 1.1 {@link DelegatingVariableResolver}, - * letting Spring bean definitions override other attributes of the same name. - * - *

The main purpose of this class is to provide behavior that is analogous - * to the JSF 1.2 {@link org.springframework.web.jsf.el.SpringBeanFacesELResolver}. - * - * @author Juergen Hoeller - * @since 2.5 - * @see WebApplicationContextVariableResolver - * @see FacesContextUtils#getRequiredWebApplicationContext - * @deprecated as of Spring 3.2, in favor of the JSF 1.2 based - * {@link org.springframework.web.jsf.el.SpringBeanFacesELResolver} - */ -@Deprecated -public class SpringBeanVariableResolver extends DelegatingVariableResolver { - - public SpringBeanVariableResolver(VariableResolver originalVariableResolver) { - super(originalVariableResolver); - } - - @Override - public Object resolveVariable(FacesContext facesContext, String name) throws EvaluationException { - Object bean = resolveSpringBean(facesContext, name); - if (bean != null) { - return bean; - } - Object value = resolveOriginal(facesContext, name); - if (value != null) { - return value; - } - return null; - } - -} diff --git a/spring-web/src/main/java/org/springframework/web/jsf/WebApplicationContextVariableResolver.java b/spring-web/src/main/java/org/springframework/web/jsf/WebApplicationContextVariableResolver.java deleted file mode 100644 index 949f0042e4f..00000000000 --- a/spring-web/src/main/java/org/springframework/web/jsf/WebApplicationContextVariableResolver.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright 2002-2012 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.jsf; - -import javax.faces.context.FacesContext; -import javax.faces.el.EvaluationException; -import javax.faces.el.VariableResolver; - -import org.springframework.util.Assert; -import org.springframework.web.context.WebApplicationContext; - -/** - * Special JSF 1.1 {@code VariableResolver} that exposes the Spring - * {@code WebApplicationContext} instance under a variable named - * "webApplicationContext". - * - *

In contrast to {@link DelegatingVariableResolver}, this VariableResolver - * does not resolve JSF variable names as Spring bean names. It rather - * exposes Spring's root WebApplicationContext itself under a special name. - * JSF-managed beans can then use Spring's WebApplicationContext API to retrieve - * Spring-managed beans, access resources, etc. - * - *

Configure this resolver in your {@code faces-config.xml} file as follows: - * - *

- * <application>
- *   ...
- *   <variable-resolver>org.springframework.web.jsf.WebApplicationContextVariableResolver</variable-resolver>
- * </application>
- * - * @author Colin Sampaleanu - * @author Juergen Hoeller - * @since 1.2.5 - * @see DelegatingVariableResolver - * @see FacesContextUtils#getWebApplicationContext - * @deprecated as of Spring 3.2, in favor of the JSF 1.2 based - * {@link org.springframework.web.jsf.el.WebApplicationContextFacesELResolver} - */ -@Deprecated -public class WebApplicationContextVariableResolver extends VariableResolver { - - /** - * Name of the exposed WebApplicationContext variable: "webApplicationContext". - */ - public static final String WEB_APPLICATION_CONTEXT_VARIABLE_NAME = "webApplicationContext"; - - - protected final VariableResolver originalVariableResolver; - - - /** - * Create a new WebApplicationContextVariableResolver, using the given - * original VariableResolver. - *

A JSF implementation will automatically pass its original resolver into the - * constructor of a configured resolver, provided that there is a corresponding - * constructor argument. - * @param originalVariableResolver the original VariableResolver - */ - public WebApplicationContextVariableResolver(VariableResolver originalVariableResolver) { - Assert.notNull(originalVariableResolver, "Original JSF VariableResolver must not be null"); - this.originalVariableResolver = originalVariableResolver; - } - - /** - * Return the original JSF VariableResolver that this resolver delegates to. - * Used to resolve standard JSF-managed beans. - */ - protected final VariableResolver getOriginalVariableResolver() { - return this.originalVariableResolver; - } - - - /** - * Check for the special "webApplicationContext" variable first, - * then delegate to the original VariableResolver. - *

If no WebApplicationContext is available, all requests - * will be delegated to the original VariableResolver. - */ - @Override - public Object resolveVariable(FacesContext context, String name) throws EvaluationException { - Object value = null; - if (WEB_APPLICATION_CONTEXT_VARIABLE_NAME.equals(name)) { - value = getWebApplicationContext(context); - } - if (value == null) { - value = getOriginalVariableResolver().resolveVariable(context, name); - } - return value; - } - - /** - * Retrieve the WebApplicationContext reference to expose. - *

The default implementation delegates to FacesContextUtils, - * returning {@code null} if no WebApplicationContext found. - * @param facesContext the current JSF context - * @return the Spring web application context - * @see FacesContextUtils#getWebApplicationContext - */ - protected WebApplicationContext getWebApplicationContext(FacesContext facesContext) { - return FacesContextUtils.getWebApplicationContext(facesContext); - } - -} diff --git a/spring-web/src/main/java/org/springframework/web/jsf/el/SpringBeanFacesELResolver.java b/spring-web/src/main/java/org/springframework/web/jsf/el/SpringBeanFacesELResolver.java index be9f6888af4..0edc7b4b083 100644 --- a/spring-web/src/main/java/org/springframework/web/jsf/el/SpringBeanFacesELResolver.java +++ b/spring-web/src/main/java/org/springframework/web/jsf/el/SpringBeanFacesELResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 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. @@ -25,9 +25,8 @@ import org.springframework.web.context.WebApplicationContext; import org.springframework.web.jsf.FacesContextUtils; /** - * JSF 1.2 {@code ELResolver} that delegates to the Spring root - * {@code WebApplicationContext}, resolving name references to - * Spring-defined beans. + * JSF {@code ELResolver} that delegates to the Spring root {@code WebApplicationContext}, + * resolving name references to Spring-defined beans. * *

Configure this resolver in your {@code faces-config.xml} file as follows: * diff --git a/spring-web/src/main/java/org/springframework/web/jsf/el/WebApplicationContextFacesELResolver.java b/spring-web/src/main/java/org/springframework/web/jsf/el/WebApplicationContextFacesELResolver.java index 712e50f341c..454598405fe 100644 --- a/spring-web/src/main/java/org/springframework/web/jsf/el/WebApplicationContextFacesELResolver.java +++ b/spring-web/src/main/java/org/springframework/web/jsf/el/WebApplicationContextFacesELResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 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. @@ -18,7 +18,6 @@ package org.springframework.web.jsf.el; import java.beans.FeatureDescriptor; import java.util.Iterator; - import javax.el.ELContext; import javax.el.ELException; import javax.el.ELResolver; @@ -32,9 +31,8 @@ import org.springframework.web.context.WebApplicationContext; import org.springframework.web.jsf.FacesContextUtils; /** - * Special JSF 1.2 {@code ELResolver} that exposes the Spring - * {@code WebApplicationContext} instance under a variable named - * "webApplicationContext". + * Special JSF {@code ELResolver} that exposes the Spring {@code WebApplicationContext} + * instance under a variable named "webApplicationContext". * *

In contrast to {@link SpringBeanFacesELResolver}, this ELResolver variant * does not resolve JSF variable names as Spring bean names. It rather diff --git a/spring-web/src/main/java/org/springframework/web/jsf/el/package-info.java b/spring-web/src/main/java/org/springframework/web/jsf/el/package-info.java index ada7476aa52..d4340dc7d28 100644 --- a/spring-web/src/main/java/org/springframework/web/jsf/el/package-info.java +++ b/spring-web/src/main/java/org/springframework/web/jsf/el/package-info.java @@ -1,12 +1,9 @@ /** * - * Support classes for integrating a JSF 1.2 web tier with a Spring middle tier + * ELResolvers for integrating a JSF web tier with a Spring middle tier * which is hosted in a Spring root WebApplicationContext. * - *

Supports JSF 1.2's ELResolver mechanism, providing closer integration - * than JSF 1.1's VariableResolver mechanism allowed for. - * */ package org.springframework.web.jsf.el; diff --git a/spring-web/src/test/java/org/springframework/web/jsf/DelegatingVariableResolverTests.java b/spring-web/src/test/java/org/springframework/web/jsf/DelegatingVariableResolverTests.java deleted file mode 100644 index 053a53150ac..00000000000 --- a/spring-web/src/test/java/org/springframework/web/jsf/DelegatingVariableResolverTests.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2002-2013 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.jsf; - -import javax.faces.context.FacesContext; -import javax.faces.el.EvaluationException; -import javax.faces.el.VariableResolver; - -import junit.framework.TestCase; - -import org.springframework.tests.sample.beans.TestBean; -import org.springframework.web.context.WebApplicationContext; -import org.springframework.web.context.support.StaticWebApplicationContext; - -/** - * @author Juergen Hoeller - * @since 02.08.2004 - */ -@Deprecated -public class DelegatingVariableResolverTests extends TestCase { - - public void testDelegatingVariableResolver() { - final StaticWebApplicationContext wac = new StaticWebApplicationContext(); - wac.registerSingleton("bean1", TestBean.class, null); - wac.registerSingleton("var1", TestBean.class, null); - wac.refresh(); - TestBean bean1 = (TestBean) wac.getBean("bean1"); - - // We need to override the getWebApplicationContext method here: - // FacesContext and ExternalContext are hard to mock. - DelegatingVariableResolver resolver = new DelegatingVariableResolver(new OriginalVariableResolver()) { - @Override - protected WebApplicationContext getWebApplicationContext(FacesContext facesContext) { - return wac; - } - }; - assertEquals(bean1, resolver.resolveVariable(null, "bean1")); - assertEquals("val1", resolver.resolveVariable(null, "var1")); - } - - public void testSpringBeanVariableResolver() { - final StaticWebApplicationContext wac = new StaticWebApplicationContext(); - wac.registerSingleton("bean1", TestBean.class, null); - wac.registerSingleton("var1", TestBean.class, null); - wac.refresh(); - TestBean bean1 = (TestBean) wac.getBean("bean1"); - TestBean var1 = (TestBean) wac.getBean("var1"); - - // We need to override the getWebApplicationContext method here: - // FacesContext and ExternalContext are hard to mock. - SpringBeanVariableResolver resolver = new SpringBeanVariableResolver(new OriginalVariableResolver()) { - @Override - protected WebApplicationContext getWebApplicationContext(FacesContext facesContext) { - return wac; - } - }; - assertEquals(bean1, resolver.resolveVariable(null, "bean1")); - assertEquals(var1, resolver.resolveVariable(null, "var1")); - } - - - private static class OriginalVariableResolver extends VariableResolver { - - @Override - public Object resolveVariable(FacesContext facesContext, String name) throws EvaluationException { - if ("var1".equals(name)) { - return "val1"; - } - return null; - } - } - -} diff --git a/spring-web/src/test/java/org/springframework/web/multipart/commons/CommonsMultipartResolverTests.java b/spring-web/src/test/java/org/springframework/web/multipart/commons/CommonsMultipartResolverTests.java index b264a446136..11c2c9511b6 100644 --- a/spring-web/src/test/java/org/springframework/web/multipart/commons/CommonsMultipartResolverTests.java +++ b/spring-web/src/test/java/org/springframework/web/multipart/commons/CommonsMultipartResolverTests.java @@ -44,6 +44,7 @@ import javax.servlet.http.HttpServletResponse; import org.apache.commons.fileupload.FileItem; import org.apache.commons.fileupload.FileItemFactory; +import org.apache.commons.fileupload.FileItemHeaders; import org.apache.commons.fileupload.FileUpload; import org.apache.commons.fileupload.servlet.ServletFileUpload; import org.junit.Test; @@ -494,6 +495,16 @@ public class CommonsMultipartResolverTests { public OutputStream getOutputStream() throws IOException { throw new UnsupportedOperationException(); } + + @Override + public FileItemHeaders getHeaders() { + throw new UnsupportedOperationException(); + } + + @Override + public void setHeaders(FileItemHeaders headers) { + throw new UnsupportedOperationException(); + } }