KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ejb3 > metamodel > EnterpriseBean


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.ejb3.metamodel;
23
24 import java.util.ArrayList JavaDoc;
25 import java.util.List JavaDoc;
26 import java.util.Collection JavaDoc;
27 import java.util.HashSet JavaDoc;
28 import javax.ejb.TransactionManagementType JavaDoc;
29 import org.jboss.logging.Logger;
30
31 import org.jboss.metamodel.descriptor.EnvironmentRefGroup;
32 import org.jboss.metamodel.descriptor.InjectionTarget;
33 import org.jboss.metamodel.descriptor.MessageDestinationRef;
34 import org.jboss.metamodel.descriptor.PersistenceUnitRef;
35 import org.jboss.metamodel.descriptor.ResourceEnvRef;
36 import org.jboss.metamodel.descriptor.ResourceRef;
37 import org.jboss.metamodel.descriptor.PersistenceContextRef;
38
39 /**
40  * Represents an EJB element of the ejb-jar.xml deployment descriptor for the
41  * 1.4 schema
42  *
43  * @author <a HREF="mailto:bdecoste@jboss.com">William DeCoste</a>
44  * @version <tt>$Revision: 55512 $</tt>
45  */

46 public abstract class EnterpriseBean
47    extends EnvironmentRefGroup implements Injectable
48 {
49    private static final Logger log = Logger.getLogger(EnterpriseBean.class);
50
51    public static final String JavaDoc BEAN = "Bean";
52
53    public static final String JavaDoc CONTAINER = "Container";
54
55    // ejb-jar.xml
56
private String JavaDoc ejbName = null;
57
58    private String JavaDoc home = null;
59
60    private String JavaDoc remote = null;
61
62    private String JavaDoc localHome = null;
63
64    private String JavaDoc local = null;
65
66    private String JavaDoc ejbClass = null;
67
68    private List JavaDoc<RemoteBinding> remoteBindings = new ArrayList JavaDoc();
69
70    private SecurityIdentity securityIdentity;
71
72    protected TransactionManagementType JavaDoc tmType = null;
73
74    // jboss.xml
75
private String JavaDoc jndiName;
76
77    private String JavaDoc localJndiName;
78
79    private String JavaDoc securityDomain;
80
81    private boolean callByValue = false;
82
83    private String JavaDoc aopDomainName = null;
84
85    private MethodAttributes methodAttributes = null;
86
87    private Collection JavaDoc<String JavaDoc> dependencies = new HashSet JavaDoc<String JavaDoc>();
88
89    private Collection JavaDoc<InjectionTarget> ignoreDependencies = new HashSet JavaDoc<InjectionTarget>();
90    
91    private Collection JavaDoc<XmlAnnotation> xmlAnnotations = new HashSet JavaDoc<XmlAnnotation>();
92
93    private PoolConfig poolConfig = null;
94    
95    public void addXmlAnnotation(XmlAnnotation annotation)
96    {
97       xmlAnnotations.add(annotation);
98    }
99
100    public Collection JavaDoc<XmlAnnotation> getXmlAnnotations()
101    {
102       return xmlAnnotations;
103    }
104
105    public void setPoolConfig(PoolConfig poolConfig)
106    {
107       this.poolConfig = poolConfig;
108    }
109
110    public PoolConfig getPoolConfig()
111    {
112       return poolConfig;
113    }
114
115    public void addRemoteBinding(RemoteBinding binding)
116    {
117       remoteBindings.add(binding);
118    }
119
120    public List JavaDoc<RemoteBinding> getRemoteBindings()
121    {
122       return remoteBindings;
123    }
124
125    public void addDependency(String JavaDoc depends)
126    {
127       dependencies.add(depends);
128    }
129
130    public Collection JavaDoc<String JavaDoc> getDependencies()
131    {
132       return dependencies;
133    }
134
135    public void addIgnoreDependency(InjectionTarget ignore)
136    {
137       ignoreDependencies.add(ignore);
138    }
139
140    public Collection JavaDoc<InjectionTarget> getIgnoreDependencies()
141    {
142       return ignoreDependencies;
143    }
144
145    public void mergeMessageDestinationRef(MessageDestinationRef ref)
146    {
147       MessageDestinationRef tmpRef = (MessageDestinationRef)messageDestinationRefs.get(ref.getMessageDestinationRefName());
148       if (tmpRef != null)
149          tmpRef.merge(ref);
150    }
151
152    public void mergeResourceRef(ResourceRef ref)
153    {
154       ResourceRef tmpRef = (ResourceRef)resourceRefs.get(ref.getResRefName());
155       if (tmpRef != null)
156          tmpRef.merge(ref);
157    }
158
159    public void mergeResourceEnvRef(ResourceEnvRef ref)
160    {
161       ResourceEnvRef tmpRef = (ResourceEnvRef)resourceEnvRefs.get(ref.getResRefName());
162       if (tmpRef != null)
163          tmpRef.merge(ref);
164    }
165
166    public void setMethodAttributes(MethodAttributes methodAttributes)
167    {
168       this.methodAttributes = methodAttributes;
169    }
170
171    public MethodAttributes getMethodAttributes()
172    {
173       return methodAttributes;
174    }
175
176    public void setAopDomainName(String JavaDoc aopDomainName)
177    {
178       this.aopDomainName = aopDomainName;
179    }
180
181    public String JavaDoc getAopDomainName()
182    {
183       return aopDomainName;
184    }
185
186    public void setRunAsPrincipal(String JavaDoc principal)
187    {
188       if (securityIdentity != null)
189          securityIdentity.setRunAsPrincipal(principal);
190    }
191
192    public void setCallByValue(boolean callByValue)
193    {
194       this.callByValue = callByValue;
195    }
196
197    public boolean isCallByValue()
198    {
199       return callByValue;
200    }
201
202    public String JavaDoc getSecurityDomain()
203    {
204       return securityDomain;
205    }
206
207    public void setSecurityDomain(String JavaDoc securityDomain)
208    {
209       this.securityDomain = securityDomain;
210    }
211
212    public String JavaDoc getJndiName()
213    {
214       return jndiName;
215    }
216
217    public void setJndiName(String JavaDoc jndiName)
218    {
219       this.jndiName = jndiName;
220    }
221
222    public String JavaDoc getLocalJndiName()
223    {
224       return localJndiName;
225    }
226
227    public void setLocalJndiName(String JavaDoc localJndiName)
228    {
229       this.localJndiName = localJndiName;
230    }
231
232    public TransactionManagementType JavaDoc getTransactionManagementType()
233    {
234       return tmType;
235    }
236
237    public void setTransactionManagementType(String JavaDoc transactionType)
238    {
239       if (transactionType.equals(BEAN))
240          tmType = TransactionManagementType.BEAN;
241       else if (transactionType.equals(CONTAINER))
242          tmType = TransactionManagementType.CONTAINER;
243    }
244
245    public boolean isSessionBean()
246    {
247       return this instanceof SessionEnterpriseBean;
248    }
249
250    public boolean isConsumer()
251    {
252       return this instanceof Consumer;
253    }
254
255    public boolean isEntityBean()
256    {
257       return this instanceof EntityEnterpriseBean;
258    }
259
260    public boolean isMessageDrivenBean()
261    {
262       return this instanceof MessageDrivenBean;
263    }
264
265    public boolean isService()
266    {
267       return this instanceof Service;
268    }
269
270    public String JavaDoc getEjbName()
271    {
272       return ejbName;
273    }
274
275    public void setEjbName(String JavaDoc ejbName)
276    {
277       this.ejbName = ejbName;
278    }
279
280    public String JavaDoc getHome()
281    {
282       return home;
283    }
284
285    public void setHome(String JavaDoc home)
286    {
287       this.home = home;
288    }
289
290    public String JavaDoc getRemote()
291    {
292       return remote;
293    }
294
295    public void setRemote(String JavaDoc remote)
296    {
297       this.remote = remote;
298    }
299
300    public String JavaDoc getLocalHome()
301    {
302       return localHome;
303    }
304
305    public void setLocalHome(String JavaDoc localHome)
306    {
307       this.localHome = localHome;
308    }
309
310    public String JavaDoc getLocal()
311    {
312       return local;
313    }
314
315    public void setLocal(String JavaDoc local)
316    {
317       this.local = local;
318    }
319
320    public String JavaDoc getEjbClass()
321    {
322       return ejbClass;
323    }
324
325    public void setEjbClass(String JavaDoc ejbClass)
326    {
327       this.ejbClass = ejbClass;
328    }
329
330    public SecurityIdentity getSecurityIdentity()
331    {
332       return securityIdentity;
333    }
334
335    public void setSecurityIdentity(SecurityIdentity securityIdentity)
336    {
337       this.securityIdentity = securityIdentity;
338    }
339
340    public String JavaDoc toString()
341    {
342       StringBuffer JavaDoc sb = new StringBuffer JavaDoc(100);
343       sb.append("ejbName=").append(ejbName);
344       sb.append(",remoteBindings=").append(remoteBindings);
345       sb.append(",jndiName=").append(jndiName);
346       sb.append(",local=").append(local);
347       sb.append(",remote=").append(remote);
348       sb.append(",home=").append(home);
349       sb.append(",localHome=").append(localHome);
350       sb.append(",ejbClass=").append(ejbClass);
351       sb.append(",ejbRefs=").append(ejbRefs);
352       sb.append(",ejbLocalRefs=").append(ejbLocalRefs);
353       sb.append(",resourceRefs=").append(resourceRefs);
354       sb.append(",resourceEnvRefs=").append(resourceEnvRefs);
355       sb.append(",methodAttributes=").append(methodAttributes);
356       sb.append(",aopDomainName=").append(aopDomainName);
357       sb.append(",dependencies=").append(dependencies);
358       return sb.toString();
359    }
360
361 }
362
Popular Tags