You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by lt...@apache.org on 2006/10/30 08:48:40 UTC
svn commit: r469083 - in
/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon:
environment/Request.java environment/ValueHolder.java
environment/http/HttpRequest.java
servlet/multipart/MultipartHttpServletRequest.java
Author: ltrieloff
Date: Sun Oct 29 23:48:39 2006
New Revision: 469083
URL: http://svn.apache.org/viewvc?view=rev&rev=469083
Log:
Introduced interface ValueHolder, which is already implemented by Request and MultipartHttpServletRequest, in order to change the instanceof check in HttpRequest from a concrete class to an interface.
Added:
cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/environment/ValueHolder.java (with props)
Modified:
cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/environment/Request.java
cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/environment/http/HttpRequest.java
cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/multipart/MultipartHttpServletRequest.java
Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/environment/Request.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/environment/Request.java?view=diff&rev=469083&r1=469082&r2=469083
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/environment/Request.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/environment/Request.java Sun Oct 29 23:48:39 2006
@@ -39,7 +39,7 @@
*
* @version $Id$
*/
-public interface Request {
+public interface Request extends ValueHolder {
/**
* This constant defines an request wide scope for the request attribute.
Added: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/environment/ValueHolder.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/environment/ValueHolder.java?view=auto&rev=469083
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/environment/ValueHolder.java (added)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/environment/ValueHolder.java Sun Oct 29 23:48:39 2006
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.environment;
+
+/**
+ * A class of this interface is able to store and retrieve references to
+ * other objects by a key.
+ *
+ * @version $Id$
+ */
+public interface ValueHolder {
+ /**
+ * Gets the value assigned to a key.
+ * @param key the key to lookup a stored object
+ * @return the value assigned to the key or null if no object can be found
+ */
+ public Object get(String key);
+}
Propchange: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/environment/ValueHolder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/environment/ValueHolder.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/environment/http/HttpRequest.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/environment/http/HttpRequest.java?view=diff&rev=469083&r1=469082&r2=469083
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/environment/http/HttpRequest.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/environment/http/HttpRequest.java Sun Oct 29 23:48:39 2006
@@ -34,6 +34,7 @@
import org.apache.cocoon.environment.Cookie;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.environment.Session;
+import org.apache.cocoon.environment.ValueHolder;
import org.apache.cocoon.environment.impl.AbstractRequest;
import org.apache.cocoon.servlet.multipart.MultipartHttpServletRequest;
import org.apache.commons.collections.IteratorUtils;
@@ -79,8 +80,8 @@
*/
public Object get(String name) {
// if the request has been wrapped then access its method
- if (req instanceof MultipartHttpServletRequest) {
- return ((MultipartHttpServletRequest) req).get(name);
+ if (req instanceof ValueHolder) {
+ return ((ValueHolder) req).get(name);
}
String[] values = req.getParameterValues(name);
if (values == null) {
Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/multipart/MultipartHttpServletRequest.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/multipart/MultipartHttpServletRequest.java?view=diff&rev=469083&r1=469082&r2=469083
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/multipart/MultipartHttpServletRequest.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/multipart/MultipartHttpServletRequest.java Sun Oct 29 23:48:39 2006
@@ -24,12 +24,14 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
+import org.apache.cocoon.environment.ValueHolder;
+
/**
* Servlet request wrapper for multipart parser.
*
* @version $Id$
*/
-public class MultipartHttpServletRequest extends HttpServletRequestWrapper {
+public class MultipartHttpServletRequest extends HttpServletRequestWrapper implements ValueHolder {
/** The submitted parts */
private Hashtable values;
@@ -60,10 +62,7 @@
}
/**
- * Method get
- *
- * @param name
- *
+ * @see org.apache.cocoon.environment.ValueHolder#get(java.lang.String)
*/
public Object get(String name) {
Object result = null;