KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > EjbAbstractDescriptor


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;
24
25 import java.util.Set JavaDoc;
26 import java.util.HashSet JavaDoc;
27
28 /**
29  * I am an abstract super class of all ejb descriptors.
30  *
31  * @author Danny Coward
32  */

33
34 public abstract class EjbAbstractDescriptor extends Descriptor implements NamedDescriptor {
35     private String JavaDoc homeClassName;
36     private String JavaDoc remoteClassName;
37     private String JavaDoc localHomeClassName;
38     private String JavaDoc localClassName;
39
40     private Set JavaDoc<String JavaDoc> remoteBusinessClassNames = new HashSet JavaDoc<String JavaDoc>();
41     private Set JavaDoc<String JavaDoc> localBusinessClassNames = new HashSet JavaDoc<String JavaDoc>();
42
43     // This is the value of the EJB 2.1 deployment descriptor entry
44
// for service endpoint interface.
45
private String JavaDoc webServiceEndpointInterfaceName;
46
47     private String JavaDoc jndiName = "";
48     private String JavaDoc mappedName = "";
49     
50        
51     /**
52     * Default constructor.
53     */

54     public EjbAbstractDescriptor() {
55     }
56     
57     /**
58     * Copy constructor.
59     */

60     protected EjbAbstractDescriptor(EjbAbstractDescriptor other) {
61     super(other);
62     this.homeClassName = other.homeClassName;
63     this.remoteClassName = other.remoteClassName;
64         this.remoteBusinessClassNames =
65             new HashSet JavaDoc<String JavaDoc>(other.remoteBusinessClassNames);
66         this.localHomeClassName = other.localHomeClassName;
67         this.localClassName = other.localClassName;
68         this.localBusinessClassNames =
69             new HashSet JavaDoc<String JavaDoc>(other.localBusinessClassNames);
70         this.webServiceEndpointInterfaceName =
71             other.webServiceEndpointInterfaceName;
72     this.jndiName = other.jndiName;
73     }
74     
75  
76     public abstract String JavaDoc getType();
77     public abstract void setType(String JavaDoc type);
78     
79     /**
80     * Returns the classname of the Home interface of this ejb.
81     */

82     public String JavaDoc getHomeClassName() {
83     return this.homeClassName;
84     }
85     
86     /**
87     * Sets the classname of the Home interface of this ejb.
88     */

89     public void setHomeClassName(String JavaDoc homeClassName) {
90     this.homeClassName = homeClassName;
91     }
92     
93     /**
94     * Sets the classname of the Remote interface of this ejb.
95     */

96     public void setRemoteClassName(String JavaDoc remoteClassName) {
97     this.remoteClassName = remoteClassName;
98     }
99     
100
101     /**
102     * Returns the classname of the Remote interface of this ejb.
103     */

104     public String JavaDoc getRemoteClassName() {
105     return this.remoteClassName;
106     }
107     
108     /**
109      * Sets the classname for the local home interface of this ejb
110      *
111      * @param localHomeClassName fully qualified class name for the interface
112      */

113     public void setLocalHomeClassName(String JavaDoc localHomeClassName) {
114         this.localHomeClassName = localHomeClassName;
115     }
116     
117     /**
118      * @return the fully qualified class name for the local home interface of this ejb
119      */

120     public String JavaDoc getLocalHomeClassName() {
121         return localHomeClassName;
122     }
123     
124     /**
125      * Sets the classname for the local interface of this ejb
126      *
127      * @param localClassName fully qualified class name for the interface
128      */

129     public void setLocalClassName(String JavaDoc localClassName) {
130         this.localClassName = localClassName;
131     }
132     
133     /**
134      * @return the fully qualified class name for the local interface of this ejb
135      */

136     public String JavaDoc getLocalClassName() {
137         return localClassName;
138     }
139
140     public void addRemoteBusinessClassName(String JavaDoc className) {
141         remoteBusinessClassNames.add(className);
142     }
143
144     public void addLocalBusinessClassName(String JavaDoc className) {
145         localBusinessClassNames.add(className);
146     }
147
148     /**
149      * Returns the set of remote business interface names for this ejb.
150      * If the bean does not expose a remote business view, return a set
151      * of size 0.
152      */

153     public Set JavaDoc<String JavaDoc> getRemoteBusinessClassNames() {
154         return new HashSet JavaDoc<String JavaDoc>( remoteBusinessClassNames );
155     }
156
157     /**
158      * Returns the set of local business interface names for this ejb.
159      * If the bean does not expose a local business view, return a set
160      * of size 0.
161      */

162     public Set JavaDoc<String JavaDoc> getLocalBusinessClassNames() {
163         return new HashSet JavaDoc<String JavaDoc>( localBusinessClassNames );
164     }
165
166     public void setWebServiceEndpointInterfaceName(String JavaDoc name) {
167         this.webServiceEndpointInterfaceName = name;
168     }
169
170     public String JavaDoc getWebServiceEndpointInterfaceName() {
171         return webServiceEndpointInterfaceName;
172     }
173
174     /**
175     * Return the JNDI name which will be assigned to the ejb home object ar runtime.
176     */

177     public String JavaDoc getJndiName() {
178     if (this.jndiName == null) {
179         this.jndiName = "";
180     }
181     return (jndiName != null && jndiName.length() > 0)?
182                 jndiName : getMappedName();
183     }
184    
185     /**
186     * Sets the JNDI name which will be assigned to the ejb home object ar runtime.
187     */

188     public void setJndiName(String JavaDoc jndiName) {
189     this.jndiName = jndiName;
190     if (this.getName().equals("")) {
191         super.setName(jndiName);
192     }
193     this.changed();
194     }
195
196     public String JavaDoc getMappedName() {
197         return (mappedName != null)? mappedName : "";
198     }
199
200     public void setMappedName(String JavaDoc mappedName) {
201         this.mappedName = mappedName;
202         this.changed();
203     }
204     
205     /**
206     * Returns a formatted String of the attributes of this object.
207     */

208     public void print(StringBuffer JavaDoc toStringBuffer) {
209         super.print(toStringBuffer);
210     toStringBuffer.append("\n homeClassName ").append(homeClassName);
211     toStringBuffer.append("\n remoteClassName ").append(remoteClassName);
212     toStringBuffer.append("\n remoteBusinessIntfs ").append(remoteBusinessClassNames).append("\n");
213     toStringBuffer.append("\n localhomeClassName ").append(localHomeClassName);
214     toStringBuffer.append("\n localClassName ").append(localClassName);
215     toStringBuffer.append("\n localBusinessIntfs ").append(localBusinessClassNames).append("\n");
216     toStringBuffer.append("\n jndiName ").append(jndiName).append("\n");
217     }
218     
219     /**
220      * @return true if the EJB described has a LocalHome/Local interface
221      */

222     public boolean isLocalInterfacesSupported() {
223         return (getLocalHomeClassName() != null);
224     }
225
226     /**
227      * @return true if the EJB has 1 or more local business interfaces
228      */

229     public boolean isLocalBusinessInterfacesSupported() {
230         return (localBusinessClassNames.size() > 0);
231     }
232     
233     /**
234      * @return true if the EJB has a RemoteHome/Remote interface
235      */

236     public boolean isRemoteInterfacesSupported() {
237         return (getHomeClassName() != null);
238     }
239
240     /**
241      * @return true if the EJB has 1 or more remote business interfaces
242      */

243     public boolean isRemoteBusinessInterfacesSupported() {
244         return (remoteBusinessClassNames.size() > 0);
245     }
246
247
248     /**
249      * @return true if this is an EJB that implements a web service endpoint.
250      */

251     public boolean hasWebServiceEndpointInterface() {
252         return (getWebServiceEndpointInterfaceName() != null);
253     }
254
255 }
256     
257
Popular Tags