01: /*
02: * Copyright 2004-2007 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License. You may obtain a copy of
06: * the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13: * License for the specific language governing permissions and limitations under
14: * the License.
15: */
16: package org.springframework.webflow.context.portlet;
17:
18: import java.util.Iterator;
19:
20: import javax.portlet.PortletRequest;
21:
22: import org.springframework.binding.collection.StringKeyedMapAdapter;
23: import org.springframework.webflow.core.collection.CollectionUtils;
24:
25: /**
26: * Map backed by the Portlet request for accessing request scoped attributes.
27: *
28: * @author Keith Donald
29: */
30: public class PortletRequestMap extends StringKeyedMapAdapter {
31:
32: /**
33: * The wrapped portlet request.
34: */
35: private PortletRequest request;
36:
37: /**
38: * Create a new map wrapping the attributes of given portlet request.
39: */
40: public PortletRequestMap(PortletRequest request) {
41: this .request = request;
42: }
43:
44: protected Object getAttribute(String key) {
45: return request.getAttribute(key);
46: }
47:
48: protected void setAttribute(String key, Object value) {
49: request.setAttribute(key, value);
50: }
51:
52: protected void removeAttribute(String key) {
53: request.removeAttribute(key);
54: }
55:
56: protected Iterator getAttributeNames() {
57: return CollectionUtils.toIterator(request.getAttributeNames());
58: }
59: }
|