KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > jxpath > CocoonSessionHandler


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.cocoon.jxpath;
17
18 import java.util.Enumeration JavaDoc;
19
20 import org.apache.cocoon.environment.Session;
21 import org.apache.commons.collections.EnumerationUtils;
22 import org.apache.commons.jxpath.DynamicPropertyHandler;
23
24 /**
25  * Implementation of the DynamicPropertyHandler interface that provides
26  * access to attributes of a Cocoon Session.
27  *
28  * @author <a HREF="mailto:volker.schmitt@basf-it-services.com">Volker Schmitt</a>
29  * @version CVS $Id: CocoonSessionHandler.java 65528 2004-11-13 22:58:29Z vgritsenko $
30  */

31 public class CocoonSessionHandler implements DynamicPropertyHandler {
32
33     public String JavaDoc[] getPropertyNames(Object JavaDoc session) {
34         final Enumeration JavaDoc e = ((Session) session).getAttributeNames();
35         return (String JavaDoc[]) EnumerationUtils.toList(e).toArray();
36     }
37
38     public Object JavaDoc getProperty(Object JavaDoc session, String JavaDoc property) {
39         return ((Session) session).getAttribute(property);
40     }
41
42     public void setProperty(Object JavaDoc session, String JavaDoc property, Object JavaDoc value) {
43         ((Session) session).setAttribute(property, value);
44     }
45 }
46
Popular Tags