cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dani...@apache.org
Subject svn commit: r170436 - in /cocoon/trunk: ./ src/java/org/apache/cocoon/environment/ src/java/org/apache/cocoon/environment/commandline/ src/java/org/apache/cocoon/environment/http/ src/java/org/apache/cocoon/environment/impl/ src/java/org/apache/cocoon/environment/wrapper/ src/test/org/apache/cocoon/environment/mock/
Date Mon, 16 May 2005 19:50:26 GMT
Author: danielf
Date: Mon May 16 12:50:25 2005
New Revision: 170436

URL: http://svn.apache.org/viewcvs?rev=170436&view=rev
Log:
Added reflection friendly utility methods for map like structures in the environment classes
Request, Context and Sessionaccording to vote http://marc.theaimsgroup.com/?t=111590936900001&r=1&w=2.
Updated all implementing classes. The implementation is based on some classes that I moved
from the faces block to core.

Added:
    cocoon/trunk/src/java/org/apache/cocoon/environment/impl/
    cocoon/trunk/src/java/org/apache/cocoon/environment/impl/AbstractContext.java   (with
props)
    cocoon/trunk/src/java/org/apache/cocoon/environment/impl/AbstractRequest.java   (with
props)
    cocoon/trunk/src/java/org/apache/cocoon/environment/impl/AbstractSession.java   (with
props)
    cocoon/trunk/src/java/org/apache/cocoon/environment/impl/BaseMap.java
      - copied, changed from r170363, cocoon/blocks/unsupported/faces/trunk/java/org/apache/cocoon/faces/context/BaseMap.java
    cocoon/trunk/src/java/org/apache/cocoon/environment/impl/ContextMap.java   (with props)
    cocoon/trunk/src/java/org/apache/cocoon/environment/impl/RequestHeaderMap.java
      - copied, changed from r170363, cocoon/blocks/unsupported/faces/trunk/java/org/apache/cocoon/faces/context/RequestHeaderMap.java
    cocoon/trunk/src/java/org/apache/cocoon/environment/impl/RequestMap.java
      - copied, changed from r170363, cocoon/blocks/unsupported/faces/trunk/java/org/apache/cocoon/faces/context/RequestMap.java
    cocoon/trunk/src/java/org/apache/cocoon/environment/impl/RequestParameterMap.java
      - copied, changed from r170363, cocoon/blocks/unsupported/faces/trunk/java/org/apache/cocoon/faces/context/RequestParameterMap.java
    cocoon/trunk/src/java/org/apache/cocoon/environment/impl/SessionMap.java
      - copied, changed from r170363, cocoon/blocks/unsupported/faces/trunk/java/org/apache/cocoon/faces/context/SessionMap.java
Modified:
    cocoon/trunk/src/java/org/apache/cocoon/environment/Context.java
    cocoon/trunk/src/java/org/apache/cocoon/environment/Request.java
    cocoon/trunk/src/java/org/apache/cocoon/environment/Session.java
    cocoon/trunk/src/java/org/apache/cocoon/environment/commandline/CommandLineContext.java
    cocoon/trunk/src/java/org/apache/cocoon/environment/commandline/CommandLineRequest.java
    cocoon/trunk/src/java/org/apache/cocoon/environment/commandline/CommandLineSession.java
    cocoon/trunk/src/java/org/apache/cocoon/environment/http/HttpContext.java
    cocoon/trunk/src/java/org/apache/cocoon/environment/http/HttpRequest.java
    cocoon/trunk/src/java/org/apache/cocoon/environment/http/HttpSession.java
    cocoon/trunk/src/java/org/apache/cocoon/environment/wrapper/AbstractRequestWrapper.java
    cocoon/trunk/src/test/org/apache/cocoon/environment/mock/MockContext.java
    cocoon/trunk/src/test/org/apache/cocoon/environment/mock/MockRequest.java
    cocoon/trunk/src/test/org/apache/cocoon/environment/mock/MockSession.java
    cocoon/trunk/status.xml

Modified: cocoon/trunk/src/java/org/apache/cocoon/environment/Context.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/environment/Context.java?rev=170436&r1=170435&r2=170436&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/environment/Context.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/environment/Context.java Mon May 16 12:50:25 2005
@@ -18,6 +18,7 @@
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.Enumeration;
+import java.util.Map;
 import java.io.InputStream;
 
 /**
@@ -33,6 +34,8 @@
     Object getAttribute(String name);
 
     void setAttribute(String name, Object value);
+
+    Map getAttributes();
 
     void removeAttribute(String name);
 

Modified: cocoon/trunk/src/java/org/apache/cocoon/environment/Request.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/environment/Request.java?rev=170436&r1=170435&r2=170436&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/environment/Request.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/environment/Request.java Mon May 16 12:50:25 2005
@@ -240,6 +240,15 @@
     void removeAttribute(String name, int scope);
 
     /**
+     * Utility method for getting a <code>Map</code> view of the request attributes.
+     * Returns a <code>Map</code> with attributes from the <code>GLOBAL_SCOPE</code>.
+     *
+     * @return                a <code>Map</code> containing the request attributes.
+     *
+     */
+    Map getAttributes();
+
+    /**
      *
      * Returns the name of the authentication scheme used to protect
      * the servlet, for example, "BASIC" or "SSL," or null if the servlet was
@@ -349,6 +358,15 @@
 
 
     /**
+     * Utility method for getting a <code>Map</code> view of the request parameters.
+     * Returns a <code>Map</code> with request parameters.
+     *
+     * @return                a <code>Map</code> containing the request parameters.
+     *
+     */
+    Map getParameters();
+
+    /**
      * Returns the name and version of the protocol the request uses
      * in the form <i>protocol/majorVersion.minorVersion</i>, for
      * example, HTTP/1.1. For HTTP servlets, the value
@@ -600,6 +618,15 @@
 
     Enumeration getHeaderNames();
     
+    /**
+     * Utility method for getting a <code>Map</code> view of the request headers.
+     * Returns a <code>Map</code> with request headers.
+     *
+     * @return                a <code>Map</code> containing the request headers.
+     *
+     */
+    Map getHeaders();
+
     /**
      * Retrieves the body of the request as binary data using 
      * an <code>InputStream</code>.

Modified: cocoon/trunk/src/java/org/apache/cocoon/environment/Session.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/environment/Session.java?rev=170436&r1=170435&r2=170436&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/environment/Session.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/environment/Session.java Mon May 16 12:50:25 2005
@@ -16,6 +16,7 @@
 package org.apache.cocoon.environment;
 
 import java.util.Enumeration;
+import java.util.Map;
 
 /**
  *
@@ -195,6 +196,15 @@
      *                                        invalidated session
      */
     void removeAttribute(String name);
+
+    /**
+     * Utility method for getting a <code>Map</code> view of the request attributes.
+     * Returns a <code>Map</code> with attributes.
+     *
+     * @return                a <code>Map</code> containing the request attributes.
+     *
+     */
+    Map getAttributes();
 
     /**
      *

Modified: cocoon/trunk/src/java/org/apache/cocoon/environment/commandline/CommandLineContext.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/environment/commandline/CommandLineContext.java?rev=170436&r1=170435&r2=170436&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/environment/commandline/CommandLineContext.java
(original)
+++ cocoon/trunk/src/java/org/apache/cocoon/environment/commandline/CommandLineContext.java
Mon May 16 12:50:25 2005
@@ -18,6 +18,7 @@
 import org.apache.commons.collections.iterators.IteratorEnumeration;
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
 import org.apache.cocoon.environment.Context;
+import org.apache.cocoon.environment.impl.ContextMap;
 
 import java.io.File;
 import java.net.MalformedURLException;
@@ -31,7 +32,7 @@
  *
  * Implements the {@link org.apache.cocoon.environment.Context} interface
  * @author ?
- * @version CVS $Id: CommandLineContext.java,v 1.3 2004/03/05 13:02:54 bdelacretaz Exp $
+ * @version CVS $Id$
  */
 
 public class CommandLineContext extends AbstractLogEnabled implements Context {
@@ -78,6 +79,10 @@
             getLogger().debug("CommandlineContext: getAttributeNames");
         }
         return new IteratorEnumeration(this.attributes.keySet().iterator());
+    }
+
+    public Map getAttributes() {
+	return new ContextMap(this);
     }
 
     public URL getResource(String path) throws MalformedURLException {

Modified: cocoon/trunk/src/java/org/apache/cocoon/environment/commandline/CommandLineRequest.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/environment/commandline/CommandLineRequest.java?rev=170436&r1=170435&r2=170436&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/environment/commandline/CommandLineRequest.java
(original)
+++ cocoon/trunk/src/java/org/apache/cocoon/environment/commandline/CommandLineRequest.java
Mon May 16 12:50:25 2005
@@ -28,6 +28,7 @@
 import org.apache.cocoon.environment.Environment;
 import org.apache.cocoon.environment.Request;
 import org.apache.cocoon.environment.Session;
+import org.apache.cocoon.environment.impl.AbstractRequest;
 import org.apache.commons.collections.IteratorUtils;
 import org.apache.commons.lang.SystemUtils;
 
@@ -43,7 +44,7 @@
  * NOTE: method with a non-compliant implementation are marked with FIXME
  * and should be fixed in the future if required
  */
-public class CommandLineRequest implements Request {
+public class CommandLineRequest extends AbstractRequest {
 
     private class EmptyEnumeration implements Enumeration {
         public boolean hasMoreElements() {

Modified: cocoon/trunk/src/java/org/apache/cocoon/environment/commandline/CommandLineSession.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/environment/commandline/CommandLineSession.java?rev=170436&r1=170435&r2=170436&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/environment/commandline/CommandLineSession.java
(original)
+++ cocoon/trunk/src/java/org/apache/cocoon/environment/commandline/CommandLineSession.java
Mon May 16 12:50:25 2005
@@ -16,6 +16,7 @@
 package org.apache.cocoon.environment.commandline;
 
 import org.apache.cocoon.environment.Session;
+import org.apache.cocoon.environment.impl.AbstractSession;
 
 import java.util.Enumeration;
 import java.util.Hashtable;
@@ -25,10 +26,10 @@
  * Command-line version of Http Session.
  *
  * @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
- * @version CVS $Id: CommandLineSession.java,v 1.2 2004/03/05 13:02:54 bdelacretaz Exp $
+ * @version CVS $Id$
  */
 public final class CommandLineSession
-implements Session {
+extends AbstractSession {
 
     private long creationTime = System.currentTimeMillis();
 

Modified: cocoon/trunk/src/java/org/apache/cocoon/environment/http/HttpContext.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/environment/http/HttpContext.java?rev=170436&r1=170435&r2=170436&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/environment/http/HttpContext.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/environment/http/HttpContext.java Mon May 16 12:50:25
2005
@@ -24,16 +24,16 @@
 import javax.servlet.ServletContext;
 
 import org.apache.avalon.framework.CascadingRuntimeException;
-import org.apache.cocoon.environment.Context;
+import org.apache.cocoon.environment.impl.AbstractContext;
 
 /**
  *
  * Implements the {@link org.apache.cocoon.environment.Context} interface
  * @author ?
- * @version CVS $Id: HttpContext.java,v 1.3 2004/05/07 17:23:42 joerg Exp $
+ * @version CVS $Id$
  */
 
-public final class HttpContext implements Context {
+public final class HttpContext extends AbstractContext {
 
     /** The ServletContext */
     private final ServletContext servletContext;

Modified: cocoon/trunk/src/java/org/apache/cocoon/environment/http/HttpRequest.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/environment/http/HttpRequest.java?rev=170436&r1=170435&r2=170436&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/environment/http/HttpRequest.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/environment/http/HttpRequest.java Mon May 16 12:50:25
2005
@@ -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.impl.AbstractRequest;
 import org.apache.cocoon.servlet.multipart.MultipartHttpServletRequest;
 import org.apache.commons.collections.IteratorUtils;
 
@@ -45,7 +46,7 @@
  * @version CVS $Id$
  */
 
-public final class HttpRequest implements Request {
+public final class HttpRequest extends AbstractRequest {
 
     /** The real HttpServletRequest object */
     private final HttpServletRequest req;

Modified: cocoon/trunk/src/java/org/apache/cocoon/environment/http/HttpSession.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/environment/http/HttpSession.java?rev=170436&r1=170435&r2=170436&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/environment/http/HttpSession.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/environment/http/HttpSession.java Mon May 16 12:50:25
2005
@@ -15,7 +15,7 @@
  */
 package org.apache.cocoon.environment.http;
 
-import org.apache.cocoon.environment.Session;
+import org.apache.cocoon.environment.impl.AbstractSession;
 
 import java.util.Enumeration;
 
@@ -44,12 +44,12 @@
  * will not be directly visible in another.
  *
  * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
- * @version CVS $Id: HttpSession.java,v 1.3 2004/03/05 13:02:55 bdelacretaz Exp $
+ * @version CVS $Id$
  *
  */
 
 public final class HttpSession
-implements Session {
+extends AbstractSession {
 
     javax.servlet.http.HttpSession wrappedSession;
 

Added: cocoon/trunk/src/java/org/apache/cocoon/environment/impl/AbstractContext.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/environment/impl/AbstractContext.java?rev=170436&view=auto
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/environment/impl/AbstractContext.java (added)
+++ cocoon/trunk/src/java/org/apache/cocoon/environment/impl/AbstractContext.java Mon May
16 12:50:25 2005
@@ -0,0 +1,33 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.environment.impl;
+
+import java.util.Map;
+
+import org.apache.cocoon.environment.Context;
+
+/**
+ * Base class for any context
+ *
+ * @version $Id$
+ */
+public abstract class AbstractContext 
+    implements Context {
+
+    public Map getAttributes() {
+	return new ContextMap(this);
+    }
+}

Propchange: cocoon/trunk/src/java/org/apache/cocoon/environment/impl/AbstractContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/src/java/org/apache/cocoon/environment/impl/AbstractContext.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/trunk/src/java/org/apache/cocoon/environment/impl/AbstractRequest.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/environment/impl/AbstractRequest.java?rev=170436&view=auto
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/environment/impl/AbstractRequest.java (added)
+++ cocoon/trunk/src/java/org/apache/cocoon/environment/impl/AbstractRequest.java Mon May
16 12:50:25 2005
@@ -0,0 +1,41 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.environment.impl;
+
+import java.util.Map;
+
+import org.apache.cocoon.environment.Request;
+
+/**
+ * Base class for any request
+ *
+ * @version $Id$
+ */
+public abstract class AbstractRequest 
+    implements Request {
+
+    public Map getAttributes() {
+	return new RequestMap(this);
+    }
+
+    public Map getParameters() {
+	return new RequestParameterMap(this);
+    }
+
+    public Map getHeaders() {
+	return new RequestHeaderMap(this);
+    }
+}

Propchange: cocoon/trunk/src/java/org/apache/cocoon/environment/impl/AbstractRequest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/src/java/org/apache/cocoon/environment/impl/AbstractRequest.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/trunk/src/java/org/apache/cocoon/environment/impl/AbstractSession.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/environment/impl/AbstractSession.java?rev=170436&view=auto
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/environment/impl/AbstractSession.java (added)
+++ cocoon/trunk/src/java/org/apache/cocoon/environment/impl/AbstractSession.java Mon May
16 12:50:25 2005
@@ -0,0 +1,33 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.environment.impl;
+
+import java.util.Map;
+
+import org.apache.cocoon.environment.Session;
+
+/**
+ * Base class for any session
+ *
+ * @version $Id$
+ */
+public abstract class AbstractSession 
+    implements Session {
+
+    public Map getAttributes() {
+	return new SessionMap(this);
+    }
+}

Propchange: cocoon/trunk/src/java/org/apache/cocoon/environment/impl/AbstractSession.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/src/java/org/apache/cocoon/environment/impl/AbstractSession.java
------------------------------------------------------------------------------
    svn:keywords = Id

Copied: cocoon/trunk/src/java/org/apache/cocoon/environment/impl/BaseMap.java (from r170363,
cocoon/blocks/unsupported/faces/trunk/java/org/apache/cocoon/faces/context/BaseMap.java)
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/environment/impl/BaseMap.java?p2=cocoon/trunk/src/java/org/apache/cocoon/environment/impl/BaseMap.java&p1=cocoon/blocks/unsupported/faces/trunk/java/org/apache/cocoon/faces/context/BaseMap.java&r1=170363&r2=170436&rev=170436&view=diff
==============================================================================
--- cocoon/blocks/unsupported/faces/trunk/java/org/apache/cocoon/faces/context/BaseMap.java
(original)
+++ cocoon/trunk/src/java/org/apache/cocoon/environment/impl/BaseMap.java Mon May 16 12:50:25
2005
@@ -13,24 +13,24 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.cocoon.faces.context;
+package org.apache.cocoon.environment.impl;
 
 import java.util.Map;
 import java.util.Set;
 
 /**
- * Base class for JSF context maps
+ * Base class for context maps
  *
  * @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
- * @version CVS $Id$
+ * @version $Id$
  */
-abstract class BaseMap extends java.util.AbstractMap {
+public abstract class BaseMap extends java.util.AbstractMap {
 
-    static class Entry implements Map.Entry {
+    protected static class Entry implements Map.Entry {
         private final Object key;
         private final Object value;
 
-        Entry(Object key, Object value) {
+        public Entry(Object key, Object value) {
             this.key = key;
             this.value = value;
         }
@@ -67,7 +67,7 @@
     }
 
 
-    BaseMap() {
+    public BaseMap() {
     }
 
     public void clear() {

Added: cocoon/trunk/src/java/org/apache/cocoon/environment/impl/ContextMap.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/environment/impl/ContextMap.java?rev=170436&view=auto
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/environment/impl/ContextMap.java (added)
+++ cocoon/trunk/src/java/org/apache/cocoon/environment/impl/ContextMap.java Mon May 16 12:50:25
2005
@@ -0,0 +1,73 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.environment.impl;
+
+import org.apache.cocoon.environment.Context;
+
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Context attributes map
+ *
+ * @version $Id$
+ */
+public class ContextMap extends BaseMap {
+
+    private Context context;
+
+
+    public ContextMap(Context context) {
+        this.context = context;
+    }
+
+    public Object get(Object key) {
+        return context.getAttribute(key.toString());
+    }
+
+    public Object put(Object key, Object value) {
+        String sKey = key.toString();
+        Object old = context.getAttribute(sKey);
+        context.setAttribute(sKey, value);
+        return old;
+    }
+
+    public Object remove(Object key) {
+        String sKey = key.toString();
+        Object old = context.getAttribute(sKey);
+        context.removeAttribute(sKey);
+        return old;
+    }
+
+    public Set entrySet() {
+        Set entries = new HashSet();
+        for (Enumeration e = context.getAttributeNames(); e.hasMoreElements();) {
+            String name = (String) e.nextElement();
+            entries.add(new BaseMap.Entry(name, context.getAttribute(name)));
+        }
+
+        return entries;
+    }
+
+    public boolean equals(Object obj) {
+        if (obj == null || !(obj instanceof ContextMap)) {
+            return false;
+        }
+
+        return super.equals(obj);
+    }
+}

Propchange: cocoon/trunk/src/java/org/apache/cocoon/environment/impl/ContextMap.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/src/java/org/apache/cocoon/environment/impl/ContextMap.java
------------------------------------------------------------------------------
    svn:keywords = Id

Copied: cocoon/trunk/src/java/org/apache/cocoon/environment/impl/RequestHeaderMap.java (from
r170363, cocoon/blocks/unsupported/faces/trunk/java/org/apache/cocoon/faces/context/RequestHeaderMap.java)
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/environment/impl/RequestHeaderMap.java?p2=cocoon/trunk/src/java/org/apache/cocoon/environment/impl/RequestHeaderMap.java&p1=cocoon/blocks/unsupported/faces/trunk/java/org/apache/cocoon/faces/context/RequestHeaderMap.java&r1=170363&r2=170436&rev=170436&view=diff
==============================================================================
--- cocoon/blocks/unsupported/faces/trunk/java/org/apache/cocoon/faces/context/RequestHeaderMap.java
(original)
+++ cocoon/trunk/src/java/org/apache/cocoon/environment/impl/RequestHeaderMap.java Mon May
16 12:50:25 2005
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.cocoon.faces.context;
+package org.apache.cocoon.environment.impl;
 
 import org.apache.cocoon.environment.Request;
 
@@ -25,14 +25,14 @@
  * Request headers map
  *
  * @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
- * @version CVS $Id$
+ * @version $Id$
  */
-class RequestHeaderMap extends BaseMap {
+public class RequestHeaderMap extends BaseMap {
 
     private Request request;
 
 
-    RequestHeaderMap(Request request) {
+    public RequestHeaderMap(Request request) {
         this.request = request;
     }
 

Copied: cocoon/trunk/src/java/org/apache/cocoon/environment/impl/RequestMap.java (from r170363,
cocoon/blocks/unsupported/faces/trunk/java/org/apache/cocoon/faces/context/RequestMap.java)
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/environment/impl/RequestMap.java?p2=cocoon/trunk/src/java/org/apache/cocoon/environment/impl/RequestMap.java&p1=cocoon/blocks/unsupported/faces/trunk/java/org/apache/cocoon/faces/context/RequestMap.java&r1=170363&r2=170436&rev=170436&view=diff
==============================================================================
--- cocoon/blocks/unsupported/faces/trunk/java/org/apache/cocoon/faces/context/RequestMap.java
(original)
+++ cocoon/trunk/src/java/org/apache/cocoon/environment/impl/RequestMap.java Mon May 16 12:50:25
2005
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.cocoon.faces.context;
+package org.apache.cocoon.environment.impl;
 
 import org.apache.cocoon.environment.Request;
 
@@ -25,14 +25,14 @@
  * Request attributes map
  *
  * @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
- * @version CVS $Id$
+ * @version $Id$
  */
-class RequestMap extends BaseMap {
+public class RequestMap extends BaseMap {
 
     private Request request;
 
 
-    RequestMap(Request request) {
+    public RequestMap(Request request) {
         this.request = request;
     }
 

Copied: cocoon/trunk/src/java/org/apache/cocoon/environment/impl/RequestParameterMap.java
(from r170363, cocoon/blocks/unsupported/faces/trunk/java/org/apache/cocoon/faces/context/RequestParameterMap.java)
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/environment/impl/RequestParameterMap.java?p2=cocoon/trunk/src/java/org/apache/cocoon/environment/impl/RequestParameterMap.java&p1=cocoon/blocks/unsupported/faces/trunk/java/org/apache/cocoon/faces/context/RequestParameterMap.java&r1=170363&r2=170436&rev=170436&view=diff
==============================================================================
--- cocoon/blocks/unsupported/faces/trunk/java/org/apache/cocoon/faces/context/RequestParameterMap.java
(original)
+++ cocoon/trunk/src/java/org/apache/cocoon/environment/impl/RequestParameterMap.java Mon
May 16 12:50:25 2005
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.cocoon.faces.context;
+package org.apache.cocoon.environment.impl;
 
 import org.apache.cocoon.environment.Request;
 
@@ -25,14 +25,14 @@
  * Request parameters map
  *
  * @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
- * @version CVS $Id$
+ * @version $Id$
  */
-class RequestParameterMap extends BaseMap {
+public class RequestParameterMap extends BaseMap {
 
     private Request request;
 
 
-    RequestParameterMap(Request request) {
+    public RequestParameterMap(Request request) {
         this.request = request;
     }
 

Copied: cocoon/trunk/src/java/org/apache/cocoon/environment/impl/SessionMap.java (from r170363,
cocoon/blocks/unsupported/faces/trunk/java/org/apache/cocoon/faces/context/SessionMap.java)
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/environment/impl/SessionMap.java?p2=cocoon/trunk/src/java/org/apache/cocoon/environment/impl/SessionMap.java&p1=cocoon/blocks/unsupported/faces/trunk/java/org/apache/cocoon/faces/context/SessionMap.java&r1=170363&r2=170436&rev=170436&view=diff
==============================================================================
--- cocoon/blocks/unsupported/faces/trunk/java/org/apache/cocoon/faces/context/SessionMap.java
(original)
+++ cocoon/trunk/src/java/org/apache/cocoon/environment/impl/SessionMap.java Mon May 16 12:50:25
2005
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.cocoon.faces.context;
+package org.apache.cocoon.environment.impl;
 
 import org.apache.cocoon.environment.Session;
 
@@ -25,14 +25,14 @@
  * Session attributes map
  *
  * @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
- * @version CVS $Id$
+ * @version $Id$
  */
-class SessionMap extends BaseMap {
+public class SessionMap extends BaseMap {
 
     private Session session;
 
 
-    SessionMap(Session session) {
+    public SessionMap(Session session) {
         this.session = session;
     }
 

Modified: cocoon/trunk/src/java/org/apache/cocoon/environment/wrapper/AbstractRequestWrapper.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/environment/wrapper/AbstractRequestWrapper.java?rev=170436&r1=170435&r2=170436&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/environment/wrapper/AbstractRequestWrapper.java
(original)
+++ cocoon/trunk/src/java/org/apache/cocoon/environment/wrapper/AbstractRequestWrapper.java
Mon May 16 12:50:25 2005
@@ -25,6 +25,7 @@
 import org.apache.cocoon.environment.Cookie;
 import org.apache.cocoon.environment.Request;
 import org.apache.cocoon.environment.Session;
+import org.apache.cocoon.environment.impl.AbstractRequest;
 
 
 /**
@@ -36,7 +37,7 @@
  * @version CVS $Id$
  * @since 2.2
  */
-public abstract class AbstractRequestWrapper implements Request {
+public abstract class AbstractRequestWrapper extends AbstractRequest {
 
     /** The real {@link Request} object */
     protected final Request req;

Modified: cocoon/trunk/src/test/org/apache/cocoon/environment/mock/MockContext.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/test/org/apache/cocoon/environment/mock/MockContext.java?rev=170436&r1=170435&r2=170436&view=diff
==============================================================================
--- cocoon/trunk/src/test/org/apache/cocoon/environment/mock/MockContext.java (original)
+++ cocoon/trunk/src/test/org/apache/cocoon/environment/mock/MockContext.java Mon May 16 12:50:25
2005
@@ -21,9 +21,9 @@
 import java.util.Hashtable;
 import java.io.InputStream;
 
-import org.apache.cocoon.environment.Context;
+import org.apache.cocoon.environment.impl.AbstractContext;
 
-public class MockContext implements Context {
+public class MockContext extends AbstractContext {
 
     private Hashtable attributes = new Hashtable();
     private Hashtable resources = new Hashtable();

Modified: cocoon/trunk/src/test/org/apache/cocoon/environment/mock/MockRequest.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/test/org/apache/cocoon/environment/mock/MockRequest.java?rev=170436&r1=170435&r2=170436&view=diff
==============================================================================
--- cocoon/trunk/src/test/org/apache/cocoon/environment/mock/MockRequest.java (original)
+++ cocoon/trunk/src/test/org/apache/cocoon/environment/mock/MockRequest.java Mon May 16 12:50:25
2005
@@ -35,8 +35,9 @@
 import org.apache.cocoon.environment.Environment;
 import org.apache.cocoon.environment.Request;
 import org.apache.cocoon.environment.Session;
+import org.apache.cocoon.environment.impl.AbstractRequest;
 
-public class MockRequest implements Request {
+public class MockRequest extends AbstractRequest {
     
     private Hashtable attributes = new Hashtable();
     private Hashtable globalAttributes = new Hashtable();

Modified: cocoon/trunk/src/test/org/apache/cocoon/environment/mock/MockSession.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/test/org/apache/cocoon/environment/mock/MockSession.java?rev=170436&r1=170435&r2=170436&view=diff
==============================================================================
--- cocoon/trunk/src/test/org/apache/cocoon/environment/mock/MockSession.java (original)
+++ cocoon/trunk/src/test/org/apache/cocoon/environment/mock/MockSession.java Mon May 16 12:50:25
2005
@@ -20,9 +20,9 @@
 
 import junit.framework.AssertionFailedError;
 
-import org.apache.cocoon.environment.Session;
+import org.apache.cocoon.environment.impl.AbstractSession;
 
-public class MockSession implements Session {
+public class MockSession extends AbstractSession {
 
     private long creationtime = System.currentTimeMillis();
     private String id = "MockSession";

Modified: cocoon/trunk/status.xml
URL: http://svn.apache.org/viewcvs/cocoon/trunk/status.xml?rev=170436&r1=170435&r2=170436&view=diff
==============================================================================
--- cocoon/trunk/status.xml (original)
+++ cocoon/trunk/status.xml Mon May 16 12:50:25 2005
@@ -75,6 +75,7 @@
   <person name="Torsten Curdt" email="tcurdt@apache.org" id="TC"/>
   <person name="Bertrand Delacr&#233;taz" email="bdelacretaz@apache.org" id="BD"/>
   <person name="Bruno Dumon" email="bruno@apache.org" id="BRD"/>
+  <person name="Daniel Fagerstrom" email="danielf@apache.org" id="DF"/>
   <person name="Gerhard Froehlich" email="froehlich@apache.org" id="GF"/>
   <person name="Pierpaolo Fumagalli" email="pier@apache.org" id="PF"/>
   <person name="Antonio Gallardo" email="antonio@apache.org" id="AG"/>
@@ -195,6 +196,12 @@
 
   <changes>
   <release version="@version@" date="@date@">
+   <action dev="DF" type="update">
+     Added reflection friendly utility methods for the Cocoon environment according to vote
+     http://marc.theaimsgroup.com/?t=111590936900001&amp;r=1&amp;w=2:
+     Map getAttributes(), Map getParameters(), Map getHeaders() for Request
+     and Map getAttributes() for Session and Context.
+   </action>
    <action dev="LG" type="update">
      JXTemplateGenerator's ScriptManager uses transient store to cache parsed templates.
    </action>



Mime
View raw message