KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > node > runtime > PMDescriptorsNode


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 package com.sun.enterprise.deployment.node.runtime;
24
25 import java.util.Vector JavaDoc;
26 import java.util.Iterator JavaDoc;
27 import org.w3c.dom.Node JavaDoc;
28
29 import com.sun.enterprise.deployment.node.XMLElement;
30 import com.sun.enterprise.deployment.EjbBundleDescriptor;
31 import com.sun.enterprise.deployment.runtime.IASPersistenceManagerDescriptor;
32 import com.sun.enterprise.deployment.runtime.PersistenceManagerInUse;
33 import com.sun.enterprise.deployment.xml.RuntimeTagNames;
34
35 /**
36  * This node handles the pm-descriptors runtime xml element
37  *
38  * @author Jerome Dochez
39  * @version
40  */

41
42 public class PMDescriptorsNode extends RuntimeDescriptorNode {
43
44     /** Creates new CmpNode */
45     public PMDescriptorsNode() {
46         registerElementHandler(new XMLElement(RuntimeTagNames.PM_DESCRIPTOR),
47                                PMDescriptorNode.class, "addPersistenceManager");
48         registerElementHandler(new XMLElement(RuntimeTagNames.PM_INUSE),
49                                PMInUseNode.class, "setPersistenceManagerInUse");
50     }
51     
52     /**
53      * write the descriptor class to a DOM tree and return it
54      *
55      * @param parent node for the DOM tree
56      * @param node name
57      * @param the descriptor to write
58      * @return the DOM tree top node
59      */

60     public Node JavaDoc writeDescriptor(Node JavaDoc parent, String JavaDoc nodeName, EjbBundleDescriptor descriptor) {
61         
62     Node JavaDoc pms = null;
63     Vector JavaDoc pmDescriptors = descriptor.getPersistenceManagers();
64     if (pmDescriptors!=null && !pmDescriptors.isEmpty()) {
65             pms = super.writeDescriptor(parent, nodeName, descriptor);
66             PMDescriptorNode pmNode = new PMDescriptorNode();
67             
68             for (Iterator JavaDoc pmIterator = pmDescriptors.iterator();pmIterator.hasNext();) {
69                 IASPersistenceManagerDescriptor pmDescriptor = (IASPersistenceManagerDescriptor) pmIterator.next();
70                 pmNode.writeDescriptor(pms, RuntimeTagNames.PM_DESCRIPTOR, pmDescriptor);
71             }
72             PersistenceManagerInUse inUse = descriptor.getPersistenceManagerInUse();
73             if (inUse!=null) {
74         PMInUseNode inUseNode = new PMInUseNode();
75         inUseNode.writeDescriptor(pms, RuntimeTagNames.PM_INUSE, inUse);
76             }
77         }
78     return pms;
79     }
80 }
81
Popular Tags