You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by mc...@apache.org on 2009/12/02 19:24:21 UTC
svn commit: r886237 - in
/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application:
_SystemEventServletRequest.java _SystemEventServletResponse.java
Author: mconcini
Date: Wed Dec 2 18:24:20 2009
New Revision: 886237
URL: http://svn.apache.org/viewvc?rev=886237&view=rev
Log:
MYFACES-2434 - check-in corrected implementation of request/response wrappers using proxy.
Modified:
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/_SystemEventServletRequest.java
myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/_SystemEventServletResponse.java
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/_SystemEventServletRequest.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/_SystemEventServletRequest.java?rev=886237&r1=886236&r2=886237&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/_SystemEventServletRequest.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/_SystemEventServletRequest.java Wed Dec 2 18:24:20 2009
@@ -21,6 +21,7 @@
import javax.servlet.ServletRequest;
import javax.servlet.ServletInputStream;
import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletRequestWrapper;
import javax.naming.OperationNotSupportedException;
import java.util.Enumeration;
import java.util.Map;
@@ -29,6 +30,9 @@
import java.io.UnsupportedEncodingException;
import java.io.IOException;
import java.io.BufferedReader;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
/**
* @author Werner Punz (latest modification by $Author$)
@@ -42,83 +46,27 @@
*/
-public class _SystemEventServletRequest implements ServletRequest{
- private static final String ERR_OP = "This request class is an empty placeholder";
+public class _SystemEventServletRequest extends ServletRequestWrapper{
Map<String, Object> _attributesMap = new HashMap<String, Object>();
+ public _SystemEventServletRequest()
+ {
+ super( (ServletRequest) Proxy.newProxyInstance(
+ ServletRequest.class.getClassLoader(),
+ new Class[] { ServletRequest.class },
+ new InvocationHandler()
+ {
+ public Object invoke(Object proxy, Method m, Object[] args)
+ {
+ throw new UnsupportedOperationException("This request class is an empty placeholder");
+ }
+ }));
+ }
public Object getAttribute(String s) {
return _attributesMap.get(s);
}
- public Enumeration getAttributeNames() {
- throw new RuntimeException(ERR_OP);
- }
-
- public String getCharacterEncoding() {
- throw new RuntimeException(ERR_OP);
- }
-
- public void setCharacterEncoding(String s) throws UnsupportedEncodingException {
- throw new RuntimeException(ERR_OP);
- }
-
- public int getContentLength() {
- throw new RuntimeException(ERR_OP);
- }
-
- public String getContentType() {
- throw new RuntimeException(ERR_OP);
- }
-
- public ServletInputStream getInputStream() throws IOException {
- throw new RuntimeException(ERR_OP);
- }
-
- public String getParameter(String s) {
- throw new RuntimeException(ERR_OP);
- }
-
- public Enumeration getParameterNames() {
- throw new RuntimeException(ERR_OP);
- }
-
- public String[] getParameterValues(String s) {
- throw new RuntimeException(ERR_OP);
- }
-
- public Map getParameterMap() {
- throw new RuntimeException(ERR_OP);
- }
-
- public String getProtocol() {
- throw new RuntimeException(ERR_OP);
- }
-
- public String getScheme() {
- throw new RuntimeException(ERR_OP);
- }
-
- public String getServerName() {
- throw new RuntimeException(ERR_OP);
- }
-
- public int getServerPort() {
- throw new RuntimeException(ERR_OP);
- }
-
- public BufferedReader getReader() throws IOException {
- throw new RuntimeException(ERR_OP);
- }
-
- public String getRemoteAddr() {
- throw new RuntimeException(ERR_OP);
- }
-
- public String getRemoteHost() {
- throw new RuntimeException(ERR_OP);
- }
-
public void setAttribute(String s, Object o) {
_attributesMap.put(s, o);
}
@@ -126,40 +74,4 @@
public void removeAttribute(String s) {
_attributesMap.remove(s);
}
-
- public Locale getLocale() {
- throw new RuntimeException(ERR_OP);
- }
-
- public Enumeration getLocales() {
- throw new RuntimeException(ERR_OP);
- }
-
- public boolean isSecure() {
- throw new RuntimeException(ERR_OP);
- }
-
- public RequestDispatcher getRequestDispatcher(String s) {
- throw new RuntimeException(ERR_OP);
- }
-
- public String getRealPath(String s) {
- throw new RuntimeException(ERR_OP);
- }
-
- public int getRemotePort() {
- throw new RuntimeException(ERR_OP);
- }
-
- public String getLocalName() {
- throw new RuntimeException(ERR_OP);
- }
-
- public String getLocalAddr() {
- throw new RuntimeException(ERR_OP);
- }
-
- public int getLocalPort() {
- throw new RuntimeException(ERR_OP);
- }
}
Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/_SystemEventServletResponse.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/_SystemEventServletResponse.java?rev=886237&r1=886236&r2=886237&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/_SystemEventServletResponse.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/_SystemEventServletResponse.java Wed Dec 2 18:24:20 2009
@@ -20,8 +20,13 @@
import javax.servlet.ServletResponse;
import javax.servlet.ServletOutputStream;
+import javax.servlet.ServletResponseWrapper;
+
import java.io.IOException;
import java.io.PrintWriter;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
import java.util.Locale;
/**
@@ -33,67 +38,20 @@
* hence we have to provide dummy objects
*/
-public class _SystemEventServletResponse implements ServletResponse {
- private static final String ERR_OP = "This response class is an empty placeholder";
-
-
- public String getCharacterEncoding() {
- throw new RuntimeException(ERR_OP);
- }
-
- public String getContentType() {
- throw new RuntimeException(ERR_OP);
- }
-
- public ServletOutputStream getOutputStream() throws IOException {
- throw new RuntimeException(ERR_OP);
- }
+public class _SystemEventServletResponse extends ServletResponseWrapper {
- public PrintWriter getWriter() throws IOException {
- throw new RuntimeException(ERR_OP);
+ public _SystemEventServletResponse()
+ {
+ super( (ServletResponse) Proxy.newProxyInstance(
+ ServletResponse.class.getClassLoader(),
+ new Class[] { ServletResponse.class },
+ new InvocationHandler()
+ {
+ public Object invoke(Object proxy, Method m, Object[] args)
+ {
+ throw new UnsupportedOperationException("This response class is an empty placeholder");
+ }
+ }));
}
- public void setCharacterEncoding(String s) {
- throw new RuntimeException(ERR_OP);
- }
-
- public void setContentLength(int i) {
- throw new RuntimeException(ERR_OP);
- }
-
- public void setContentType(String s) {
- throw new RuntimeException(ERR_OP);
- }
-
- public void setBufferSize(int i) {
- throw new RuntimeException(ERR_OP);
- }
-
- public int getBufferSize() {
- throw new RuntimeException(ERR_OP);
- }
-
- public void flushBuffer() throws IOException {
- throw new RuntimeException(ERR_OP);
- }
-
- public void resetBuffer() {
- throw new RuntimeException(ERR_OP);
- }
-
- public boolean isCommitted() {
- throw new RuntimeException(ERR_OP);
- }
-
- public void reset() {
- throw new RuntimeException(ERR_OP);
- }
-
- public void setLocale(Locale locale) {
- throw new RuntimeException(ERR_OP);
- }
-
- public Locale getLocale() {
- throw new RuntimeException(ERR_OP);
- }
}