KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > node > runtime > web > SessionConfigNode


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.deployment.node.runtime.web;
25
26 import org.w3c.dom.Node JavaDoc;
27
28 import com.sun.enterprise.deployment.node.XMLElement;
29 import com.sun.enterprise.deployment.runtime.web.SessionConfig;
30 import com.sun.enterprise.deployment.xml.RuntimeTagNames;
31
32 /**
33 * superclass node for WebProperty container
34 *
35 * @author Jerome Dochez
36 */

37
38 public class SessionConfigNode extends WebRuntimeNode {
39     
40     /**
41      * Initialize the child handlers
42      */

43     public SessionConfigNode() {
44     
45         registerElementHandler(new XMLElement(RuntimeTagNames.SESSION_MANAGER),
46                                SessionManagerNode.class, "setSessionManager");
47         registerElementHandler(new XMLElement(RuntimeTagNames.SESSION_PROPERTIES),
48                                WebPropertyContainerNode.class, "setSessionProperties");
49         registerElementHandler(new XMLElement(RuntimeTagNames.COOKIE_PROPERTIES),
50                                WebPropertyContainerNode.class, "setCookieProperties");
51     }
52     
53     /**
54      * write the descriptor class to a DOM tree and return it
55      *
56      * @param parent node for the DOM tree
57      * @param node name
58      * @param the descriptor to write
59      * @return the DOM tree top node
60      */

61     public Node JavaDoc writeDescriptor(Node JavaDoc parent, String JavaDoc nodeName, SessionConfig descriptor) {
62     Node JavaDoc sessionConfig = super.writeDescriptor(parent, nodeName, descriptor);
63
64     // session-manager?
65
if (descriptor.getSessionManager()!=null) {
66         SessionManagerNode smn = new SessionManagerNode();
67         smn.writeDescriptor(sessionConfig, RuntimeTagNames.SESSION_MANAGER, descriptor.getSessionManager());
68     }
69     
70     // session-properties?
71
if (descriptor.getSessionProperties()!=null) {
72         WebPropertyNode wpn = new WebPropertyNode();
73         Node JavaDoc sessionProps = appendChild(sessionConfig, RuntimeTagNames.SESSION_PROPERTIES);
74         wpn.writeDescriptor(sessionProps, RuntimeTagNames.PROPERTY, descriptor.getSessionProperties().getWebProperty());
75     }
76     
77     // cookie-properties?
78
if (descriptor.getCookieProperties()!=null) {
79         WebPropertyNode wpn = new WebPropertyNode();
80         Node JavaDoc cookieProps = appendChild(sessionConfig, RuntimeTagNames.COOKIE_PROPERTIES);
81         wpn.writeDescriptor(cookieProps, RuntimeTagNames.PROPERTY, descriptor.getCookieProperties().getWebProperty());
82     }
83     
84     return sessionConfig;
85     }
86 }
87
Popular Tags