KickJava   Java API By Example, From Geeks To Geeks.

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


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 import org.w3c.dom.Element JavaDoc;
28
29 import com.sun.enterprise.deployment.node.XMLElement;
30 import com.sun.enterprise.deployment.runtime.RuntimeDescriptor;
31 import com.sun.enterprise.deployment.runtime.web.SessionManager;
32 import com.sun.enterprise.deployment.xml.RuntimeTagNames;
33
34 /**
35 * superclass node for WebProperty container
36 *
37 * @author Jerome Dochez
38 */

39 public class SessionManagerNode extends WebRuntimeNode {
40
41     /**
42      * Initialize the child handlers
43      */

44     public SessionManagerNode() {
45     
46         registerElementHandler(new XMLElement(RuntimeTagNames.MANAGER_PROPERTIES),
47                                WebPropertyContainerNode.class, "setManagerProperties");
48         registerElementHandler(new XMLElement(RuntimeTagNames.STORE_PROPERTIES),
49                                WebPropertyContainerNode.class, "setStoreProperties");
50     }
51     
52     /**
53      * receives notification of the value for a particular tag
54      *
55      * @param element the xml element
56      * @param value it's associated value
57      */

58     public void setElementValue(XMLElement element, String JavaDoc value) {
59     RuntimeDescriptor descriptor = getRuntimeDescriptor();
60     if (descriptor==null) {
61         throw new RuntimeException JavaDoc("Trying to set values on a null descriptor");
62     }
63     if (element.getQName().equals(RuntimeTagNames.PERSISTENCE_TYPE)) {
64         descriptor.setAttributeValue(SessionManager.PERSISTENCE_TYPE, value);
65     }
66     }
67
68     /**
69      * write the descriptor class to a DOM tree and return it
70      *
71      * @param parent node for the DOM tree
72      * @param node name
73      * @param the descriptor to write
74      * @return the DOM tree top node
75      */

76     public Node JavaDoc writeDescriptor(Node JavaDoc parent, String JavaDoc nodeName, SessionManager descriptor) {
77     
78     Element JavaDoc sessionMgr = (Element JavaDoc) super.writeDescriptor(parent, nodeName, descriptor);
79     
80     // manager-properties?
81
if (descriptor.getManagerProperties()!=null) {
82         WebPropertyNode wpn = new WebPropertyNode();
83         Node JavaDoc mgrProps = appendChild(sessionMgr, RuntimeTagNames.MANAGER_PROPERTIES);
84         wpn.writeDescriptor(mgrProps, RuntimeTagNames.PROPERTY, descriptor.getManagerProperties().getWebProperty());
85     }
86     
87     // store-properties?
88
if (descriptor.getStoreProperties()!=null) {
89         WebPropertyNode wpn = new WebPropertyNode();
90         Node JavaDoc storeProps = appendChild(sessionMgr, RuntimeTagNames.STORE_PROPERTIES);
91         wpn.writeDescriptor(storeProps, RuntimeTagNames.PROPERTY, descriptor.getStoreProperties().getWebProperty());
92     }
93     
94     // persistence-type?
95
setAttribute(sessionMgr, RuntimeTagNames.PERSISTENCE_TYPE, (String JavaDoc) descriptor.getAttributeValue(SessionManager.PERSISTENCE_TYPE));
96     
97     return sessionMgr;
98     }
99     
100 }
101
Popular Tags