KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > node > ejb > InterfaceBasedEjbNode


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.ejb;
25
26 import java.util.Map JavaDoc;
27 import java.util.Iterator JavaDoc;
28
29 import org.w3c.dom.Node JavaDoc;
30
31 import com.sun.enterprise.deployment.node.XMLElement;
32 import com.sun.enterprise.deployment.node.SecurityRoleRefNode;
33 import com.sun.enterprise.deployment.node.SecurityRoleNode;
34
35 import com.sun.enterprise.deployment.Descriptor;
36 import com.sun.enterprise.deployment.EjbDescriptor;
37 import com.sun.enterprise.deployment.RoleReference;
38 import com.sun.enterprise.deployment.xml.EjbTagNames;
39
40 /**
41  * This class is responsible for reading/writing all information
42  * common to all EJB which are interfaces based (entity, session)
43  *
44  * @author Jerome Dochez
45  * @version
46  */

47 public abstract class InterfaceBasedEjbNode extends EjbNode {
48
49    public InterfaceBasedEjbNode() {
50        super();
51        // register sub XMLNodes
52
registerElementHandler(new XMLElement(EjbTagNames.ROLE_REFERENCE), SecurityRoleRefNode.class, "addRoleReference");
53    }
54    
55     /**
56      * all sub-implementation of this class can use a dispatch table to map xml element to
57      * method name on the descriptor class for setting the element value.
58      *
59      * @return the map with the element name as a key, the setter method as a value
60      */

61     protected Map JavaDoc getDispatchTable() {
62         // no need to be synchronized for now
63
Map JavaDoc table = super.getDispatchTable();
64         table.put(EjbTagNames.HOME, "setHomeClassName");
65         table.put(EjbTagNames.REMOTE, "setRemoteClassName");
66         table.put(EjbTagNames.LOCAL_HOME, "setLocalHomeClassName");
67         table.put(EjbTagNames.LOCAL, "setLocalClassName");
68         table.put(EjbTagNames.BUSINESS_LOCAL, "addLocalBusinessClassName");
69         table.put(EjbTagNames.BUSINESS_REMOTE, "addRemoteBusinessClassName");
70         table.put(EjbTagNames.SERVICE_ENDPOINT_INTERFACE,
71                   "setWebServiceEndpointInterfaceName");
72         return table;
73     }
74     
75     /**
76      * write the common descriptor info to a DOM tree and return it
77      *
78      * @param parent node for the DOM tree
79      * @param the descriptor to write
80      */

81     protected void writeCommonHeaderEjbDescriptor(Node JavaDoc ejbNode, EjbDescriptor descriptor) {
82         super.writeCommonHeaderEjbDescriptor(ejbNode, descriptor);
83         appendTextChild(ejbNode, EjbTagNames.HOME, descriptor.getHomeClassName());
84         appendTextChild(ejbNode, EjbTagNames.REMOTE, descriptor.getRemoteClassName());
85         appendTextChild(ejbNode, EjbTagNames.LOCAL_HOME, descriptor.getLocalHomeClassName());
86         appendTextChild(ejbNode, EjbTagNames.LOCAL, descriptor.getLocalClassName());
87
88         for(String JavaDoc next : descriptor.getLocalBusinessClassNames()) {
89             appendTextChild(ejbNode, EjbTagNames.BUSINESS_LOCAL, next);
90         }
91
92         for(String JavaDoc next : descriptor.getRemoteBusinessClassNames()) {
93             appendTextChild(ejbNode, EjbTagNames.BUSINESS_REMOTE, next);
94         }
95
96         appendTextChild(ejbNode, EjbTagNames.SERVICE_ENDPOINT_INTERFACE,
97                         descriptor.getWebServiceEndpointInterfaceName());
98         appendTextChild(ejbNode, EjbTagNames.EJB_CLASS,
99                         descriptor.getEjbClassName());
100     }
101     
102     /**
103      * write the security role references to the DOM Tree
104      *
105      * @param parent node for the DOM tree
106      * @param the iterator over the RoleReference descriptors to write
107      */

108     protected void writeRoleReferenceDescriptors(Node JavaDoc parentNode, Iterator JavaDoc refs) {
109         SecurityRoleRefNode node = new SecurityRoleRefNode();
110         for (;refs.hasNext();) {
111             RoleReference roleRef = (RoleReference) refs.next();
112             node.writeDescriptor(parentNode, EjbTagNames.ROLE_REFERENCE, roleRef);
113         }
114     }
115 }
116
Popular Tags