KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ejb3 > dd > EnterpriseBeans


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.ejb3.dd;
8
9 import java.util.ArrayList JavaDoc;
10 import java.util.Iterator JavaDoc;
11 import java.util.List JavaDoc;
12
13 import org.jboss.logging.Logger;
14
15 /**
16  * Represents EJB elements of the ejb-jar.xml deployment descriptor for the 1.4
17  * schema
18  *
19  * @version <tt>$Revision: 1.9.2.2 $</tt>
20  * @author <a HREF="mailto:bdecoste@jboss.com">William DeCoste</a>
21  * ejbs.setCurrentEjbName(value); } else if
22  * (localName.equals("jndi-name")){ ejbs.setJndiName(value);
23  */

24 public class EnterpriseBeans
25 {
26    private static final Logger log = Logger.getLogger(EnterpriseBeans.class);
27
28    private List JavaDoc enterpriseBeans = new ArrayList JavaDoc();
29
30    private EnterpriseBean currentEjb;
31
32    public void setCurrentEjbName(String JavaDoc currentEjbName)
33    {
34       currentEjb = findEjbByEjbName(currentEjbName);
35    }
36    
37    public void updateEjbRef(EjbRef ref)
38    {
39       currentEjb.updateEjbRef(ref);
40    }
41    
42    public void updateEjbLocalRef(EjbLocalRef ref)
43    {
44       currentEjb.updateEjbLocalRef(ref);
45    }
46    
47    public void updateResourceRef(ResourceRef ref)
48    {
49       currentEjb.updateResourceRef(ref);
50    }
51    
52    public void setAopDomainName(String JavaDoc aopDomainName)
53    {
54       currentEjb.setAopDomainName(aopDomainName);
55    }
56    
57    public void setRunAsPrincipal(String JavaDoc principal)
58    {
59       currentEjb.setRunAsPrincipal(principal);
60    }
61    
62    public void setClusterConfig(ClusterConfig config)
63    {
64       currentEjb.setClusterConfig(config);
65    }
66    
67    public void setCallByValue(boolean callByValue)
68    {
69       currentEjb.setCallByValue(callByValue);
70    }
71
72    public void setJndiName(String JavaDoc jndiName)
73    {
74       currentEjb.setJndiName(jndiName);
75    }
76    
77    public void setSecurityDomain(String JavaDoc securityDomain)
78    {
79       currentEjb.setSecurityDomain(securityDomain);
80    }
81    
82    public void setLocalJndiName(String JavaDoc jndiName)
83    {
84       currentEjb.setLocalJndiName(jndiName);
85    }
86
87    public EnterpriseBean findEjbByEjbName(String JavaDoc ejbName)
88    {
89       Iterator JavaDoc ejbs = enterpriseBeans.iterator();
90       while (ejbs.hasNext())
91       {
92          EnterpriseBean ejb = (EnterpriseBean) ejbs.next();
93          if (ejb.getEjbName().equals(ejbName))
94             return ejb;
95       }
96       return null;
97    }
98    
99    public List JavaDoc<EnterpriseBean> findEjbsByClass(String JavaDoc className)
100    {
101       ArrayList JavaDoc result = new ArrayList JavaDoc();
102       
103       Iterator JavaDoc ejbs = enterpriseBeans.iterator();
104       while (ejbs.hasNext())
105       {
106          EnterpriseBean ejb = (EnterpriseBean) ejbs.next();
107          String JavaDoc ejbClassName = ejb.getEjbClass();
108          if (ejbClassName != null && ejbClassName.equals(className))
109             result.add(ejb);
110       }
111       return result;
112    }
113    
114    public EnterpriseBean findEjbByRemote(String JavaDoc remote)
115    {
116       Iterator JavaDoc ejbs = enterpriseBeans.iterator();
117       while (ejbs.hasNext())
118       {
119          EnterpriseBean ejb = (EnterpriseBean) ejbs.next();
120          if (ejb.getRemote() != null && ejb.getRemote().equals(remote))
121             return ejb;
122       }
123       return null;
124    }
125    
126    public EnterpriseBean findEjbByLocal(String JavaDoc local)
127    {
128       Iterator JavaDoc ejbs = enterpriseBeans.iterator();
129       while (ejbs.hasNext())
130       {
131          EnterpriseBean ejb = (EnterpriseBean) ejbs.next();
132          if (ejb.getLocal() != null && ejb.getLocal().equals(local))
133             return ejb;
134       }
135       return null;
136    }
137
138    public List JavaDoc getEnterpriseBeans()
139    {
140       return enterpriseBeans;
141    }
142
143    public void setEnterpriseBeans(List JavaDoc enterpriseBeans)
144    {
145       this.enterpriseBeans = enterpriseBeans;
146    }
147
148    public void addEnterpriseBean(EnterpriseBean ejb)
149    {
150       enterpriseBeans.add(ejb);
151    }
152
153    public String JavaDoc toString()
154    {
155       StringBuffer JavaDoc sb = new StringBuffer JavaDoc(100);
156       sb.append("[");
157       sb.append("enterpriseBeans=").append(enterpriseBeans);
158       sb.append("]");
159       return sb.toString();
160    }
161
162    public boolean equals(Object JavaDoc o)
163    {
164       if (this == o)
165          return true;
166       if (!(o instanceof EnterpriseBeans))
167          return false;
168
169       final EnterpriseBeans ejbs = (EnterpriseBeans) o;
170
171       if (enterpriseBeans != null ? !enterpriseBeans
172             .equals(ejbs.enterpriseBeans) : ejbs.enterpriseBeans != null)
173          return false;
174
175       return true;
176    }
177
178    public int hashCode()
179    {
180       int result;
181       result = (enterpriseBeans != null ? enterpriseBeans.hashCode() : 0);
182       // result = 29 * result + (version != null ? version.hashCode() : 0);
183
return result;
184    }
185 }
186
Popular Tags