KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas_ejb > container > JContainer


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999-2005 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: JContainer.java,v 1.81 2005/07/13 06:29:45 durieuxp Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas_ejb.container;
27
28 import java.io.File JavaDoc;
29 import java.lang.reflect.Method JavaDoc;
30 import java.util.Collections JavaDoc;
31 import java.util.Enumeration JavaDoc;
32 import java.util.HashMap JavaDoc;
33 import java.util.HashSet JavaDoc;
34 import java.util.Iterator JavaDoc;
35 import java.util.Properties JavaDoc;
36 import java.util.Set JavaDoc;
37
38 import javax.ejb.AccessLocalException JavaDoc;
39 import javax.ejb.EJBException JavaDoc;
40 import javax.naming.Context JavaDoc;
41 import javax.naming.InitialContext JavaDoc;
42 import javax.naming.LinkRef JavaDoc;
43 import javax.naming.NamingException JavaDoc;
44 import javax.naming.NameNotFoundException JavaDoc;
45 import javax.naming.Reference JavaDoc;
46 import javax.naming.StringRefAddr JavaDoc;
47 import javax.resource.spi.ActivationSpec JavaDoc;
48 import javax.resource.spi.work.WorkManager JavaDoc;
49 import javax.security.jacc.PolicyContext JavaDoc;
50
51 import org.objectweb.jonas.common.JProp;
52 import org.objectweb.jonas.resource.Rar;
53 import org.objectweb.jonas.ws.JServiceFactory;
54 import org.objectweb.jonas.ws.JServiceFactoryFinder;
55 import org.objectweb.jonas_ejb.container.jorm.RdbFactory;
56 import org.objectweb.jonas_ejb.deployment.api.BeanDesc;
57 import org.objectweb.jonas_ejb.deployment.api.EntityBmpDesc;
58 import org.objectweb.jonas_ejb.deployment.api.EntityCmpDesc;
59 import org.objectweb.jonas_ejb.deployment.api.EntityDesc;
60 import org.objectweb.jonas_ejb.deployment.api.EntityJdbcCmp1Desc;
61 import org.objectweb.jonas_ejb.deployment.api.EntityJdbcCmp2Desc;
62 import org.objectweb.jonas_ejb.deployment.api.MessageDrivenDesc;
63 import org.objectweb.jonas_ejb.deployment.api.SessionStatefulDesc;
64 import org.objectweb.jonas_ejb.deployment.api.SessionStatelessDesc;
65 import org.objectweb.jonas_ejb.lib.EJBInvocation;
66
67 import org.objectweb.jonas_lib.deployment.api.EjbLocalRefDesc;
68 import org.objectweb.jonas_lib.deployment.api.EjbRefDesc;
69 import org.objectweb.jonas_lib.deployment.api.EnvEntryDesc;
70 import org.objectweb.jonas_lib.deployment.api.MessageDestinationRefDesc;
71 import org.objectweb.jonas_lib.deployment.api.ResourceEnvRefDesc;
72 import org.objectweb.jonas_lib.deployment.api.ResourceRefDesc;
73 import org.objectweb.jonas_lib.naming.ContainerNaming;
74 import org.objectweb.jonas_lib.security.PermissionManagerException;
75
76 import org.objectweb.jonas_jms.api.JmsManager;
77
78 import org.objectweb.jonas_ws.deployment.api.ServiceRefDesc;
79
80 import org.objectweb.transaction.jta.TransactionManager;
81
82 import org.objectweb.carol.rmi.exception.NamingExceptionHelper;
83
84 import org.objectweb.util.monolog.api.BasicLevel;
85
86 /**
87  * This class represents an EJB container. A container is where an enterprise
88  * Bean object lives. All beans from a same ejb-jar file are installed in a
89  * single container. For each EJB installed, the container provides a factory
90  * and makes it available in the JNDI name space. The JContainer basically
91  * manages a set of BeanFactory objects.
92  * @author Philippe Coq
93  * @author Jeff Mesnil (Security)
94  * @author Christophe Ney (Making easier Enhydra integration)
95  * @author Philippe Durieux (New architecture for local interfaces)
96  * @author Florent Benoit (Ear service, ejb-link, JACC security)
97  * @author Ludovic Bert (Ear service, ejb-link)
98  * @author Benjamin Bonnet (max size for thread pool)
99  */

100
101 public class JContainer implements Container {
102
103     /**
104      * This class is the default factory class name used for the Entity bean.
105      */

106     public static final String JavaDoc DEFAULT_FACTORY_CLASS_NAME = "org.objectweb.jonas_ejb.container.JEntityFactory";
107
108     /**
109      * Work Manager, used as a pool of threads.
110      */

111     private static WorkManager JavaDoc workManager = null;
112
113     /**
114      * List of beans (key=EJBName / Value=BeanFactory)
115      */

116     private HashMap JavaDoc beanList = new HashMap JavaDoc();
117
118     /**
119      * Name of the ear application containing this container.
120      */

121     private String JavaDoc earFileName = null;
122
123     /**
124      * Container file name x.jar or x.xml
125      */

126     private String JavaDoc fileName;
127
128     /**
129      * External file name
130      */

131     private String JavaDoc externalFileName;
132
133     /**
134      * Jms manager
135      */

136     private JmsManager jms = null;
137
138     /**
139      * Classloader used by this container
140      */

141     private ClassLoader JavaDoc loader = null;
142
143     /**
144      * Container name
145      */

146     private String JavaDoc myname;
147
148     /**
149      * Naming object used to do lookup/bind in environment
150      */

151     private ContainerNaming naming = null;
152
153     /**
154      * Permission manager of this container. JACC
155      */

156     private PermissionManager permissionManager = null;
157
158     /**
159      * Factory used to make Principal objects
160      */

161     private PrincipalFactory principalFactory = null;
162
163     /**
164      * Enable / disable security
165      */

166     private boolean securityFlag = true;
167
168     /**
169      * Swapper object
170      */

171     private Swapper swapper;
172
173     /**
174      * Transaction manager
175      */

176     private TransactionManager tm = null;
177
178     private String JavaDoc tmpDirName = null;
179     
180     /**
181      * This is the default name for JORAM that will be used when trying to configure an MDB
182      * when the JMS service is not running.
183      */

184     private static final String JavaDoc DEFAULT_ACTIVATION_SPEC_NAME = "joramActivationSpec";
185
186     /**
187      * constructor
188      * @param name name of the container.
189      * @param extFileName external file name
190      * @param file file name (.jar or .xml)
191      * @param ld the class loader to be used
192      */

193     public JContainer(String JavaDoc name, String JavaDoc extFileName, String JavaDoc file, ClassLoader JavaDoc ld) {
194         myname = name;
195         externalFileName = extFileName;
196         fileName = file;
197         loader = ld;
198         swapper = new Swapper(this);
199         swapper.start();
200         if (TraceEjb.isDebugIc()) {
201             TraceEjb.interp.log(BasicLevel.DEBUG, "New Container extFN= " + externalFileName + " filename=" + fileName);
202         }
203         tmpDirName = JProp.getJonasBase() + File.separator + "tmp";
204         File JavaDoc d = new File JavaDoc(tmpDirName);
205         d.mkdir();
206     }
207
208     public String JavaDoc getTmpDirName() {
209         return tmpDirName;
210     }
211     
212     // -------------------------------------------------------------------
213
// Methods used by JOnAS Server (but not part of JContainer interface)
214
// -------------------------------------------------------------------
215

216     /**
217      * Adds beans in container. This method is not part of JContainer interface,
218      * although it is used by JOnAS Server, because we don't want to get all
219      * BeanDesc classes (jonas_ejb.deployment.api) LATER: Replace this by
220      * setDeploymentDesc ?
221      * @param dd The Bean Deployment Descriptor
222      * @return The bean factory created for this bean.
223      * @throws EJBException
224      */

225     public synchronized BeanFactory addBean(BeanDesc dd) {
226         BeanFactory bf = null;
227         String JavaDoc beanName = dd.getEjbName();
228         if (dd instanceof SessionStatefulDesc) {
229             if (TraceEjb.isDebugIc()) {
230                 TraceEjb.interp.log(BasicLevel.DEBUG, "add SessionStatefulBean " + beanName);
231             }
232             bf = new JStatefulFactory((SessionStatefulDesc) dd, this);
233         } else if (dd instanceof SessionStatelessDesc) {
234             if (TraceEjb.isDebugIc()) {
235                 TraceEjb.interp.log(BasicLevel.DEBUG, "add SessionStatelessBean " + beanName);
236             }
237             bf = new JStatelessFactory((SessionStatelessDesc) dd, this);
238         } else if (dd instanceof MessageDrivenDesc) {
239             if (TraceEjb.isDebugIc()) {
240                 TraceEjb.interp.log(BasicLevel.DEBUG, "add MessageDrivenBean " + beanName);
241             }
242             Object JavaDoc obj = null;
243             InitialContext JavaDoc ictx = null;
244             String JavaDoc destJName = ((MessageDrivenDesc) dd).getDestinationJndiName();
245             try {
246                 ictx = naming.getInitialContext();
247                 obj = ictx.lookup(destJName);
248             } catch (NamingException JavaDoc ex) {
249                 // Test also the root cause as with iiop, we got a NamingException with a NameNotFoundException as root cause
250
if (ex instanceof NameNotFoundException JavaDoc || ex.getCause() instanceof NameNotFoundException JavaDoc) {
251                     if (TraceEjb.isDebugIc()) {
252                         TraceEjb.interp.log(BasicLevel.DEBUG, "Can not find destination JNDI name " + destJName, ex);
253                     }
254                 } else {
255                     throw new EJBException JavaDoc(ex);
256                 }
257             }
258             if (obj != null && obj instanceof ActivationSpec JavaDoc) {
259                 bf = new JMdbEndpointFactory((MessageDrivenDesc) dd, this, (ActivationSpec JavaDoc) obj);
260             } else if (getJmsManager() == null) {
261                 // This is the case where we need to attach the MDB to an RAR, but it is either configured
262
// as an EJB 2.0 MDB or incorrectly for a 2.1 MDB.
263
if (((MessageDrivenDesc) dd).getDestination() != null) {
264                     if (TraceEjb.isDebugIc()) {
265                         TraceEjb.interp.log(BasicLevel.DEBUG, "JMS service not started and specified ActivationSpec(" + destJName + ") not deployed");
266                     }
267                     throw new EJBException JavaDoc("JMS service not started and specified ActivationSpec(" + destJName + ") not deployed");
268                 }
269
270                 // Get the default ActivationSpec name and attempt to configure it
271
String JavaDoc dest = Rar.getDefaultAS(); //default name
272
if (dest == null) {
273                     dest = DEFAULT_ACTIVATION_SPEC_NAME; //default name
274
}
275
276                 try {
277                     obj = ictx.lookup(dest);
278                 } catch (Exception JavaDoc ex) {
279                     if (TraceEjb.isDebugIc()) {
280                         TraceEjb.interp.log(BasicLevel.DEBUG, "JMS service not started and default ActivationSpec(" + dest + ") not deployed");
281                     }
282                     throw new EJBException JavaDoc("JMS service not started and default ActivationSpec(" + dest + ") not deployed", ex);
283                 }
284                 if (obj != null && obj instanceof ActivationSpec JavaDoc) {
285                     bf = new JMdbEndpointFactory((MessageDrivenDesc) dd, dest, this, (ActivationSpec JavaDoc) obj);
286                 } else {
287                     if (TraceEjb.isDebugIc()) {
288                         TraceEjb.interp.log(BasicLevel.DEBUG, "Invalid destination: No ActivationSpec deployed matching " + dest);
289                     }
290                     throw new EJBException JavaDoc("Invalid destination: No ActivationSpec deployed matching " + dest);
291                 }
292             } else {
293                 // This is the case where a 2.1 MDB is trying to connect to an RAR that isn't deployed
294
if (((MessageDrivenDesc) dd).getDestination() != null) {
295                     if (TraceEjb.isDebugIc()) {
296                         TraceEjb.interp.log(BasicLevel.DEBUG, "JMS service started and specified ActivationSpec(" + destJName + ") not deployed");
297                     }
298                     throw new EJBException JavaDoc("JMS service started and specified ActivationSpec(" + destJName + ") not deployed");
299                 }
300                 bf = new JMdbFactory((MessageDrivenDesc) dd, this);
301             }
302         } else if (dd instanceof EntityJdbcCmp2Desc) {
303             EntityJdbcCmp2Desc ecd = (EntityJdbcCmp2Desc) dd;
304             // TODO We only manage "Jdbc" CMP2 entity beans today.
305
if (TraceEjb.isDebugIc()) {
306                 TraceEjb.interp.log(BasicLevel.DEBUG, "add CMP2 EntityBean " + beanName);
307             }
308             // Instanciate the Factory depending on the mapper
309
String JavaDoc cn = null;
310             try {
311                 String JavaDoc dsn = ecd.getDatasourceJndiName();
312                 // Pb: We need the mapper to instanciate the Factory.
313
// The mapper is in the Datasource. No way to get it in a
314
// standard way
315
// since Datasource interface is very simple (getConnection()
316
// only)
317
//
318
// This will now try to call a getMapperName method for the
319
// datasource,
320
// if it doesn't exist then get the mapper.properties file and
321
// look for the
322
// jndiname. This allows flexibility for additional data source
323
// support,
324
// but still is not perfect.
325

326                 InitialContext JavaDoc ictx = naming.getInitialContext();
327                 String JavaDoc mapperName = null;
328                 // Attempt to call getMapperName method and if it doesn't exist
329
// then
330
// read the mapper.properties file
331
try {
332                     Object JavaDoc cls = ictx.lookup(dsn);
333                     Method JavaDoc meth = cls.getClass().getMethod("getMapperName", (Class JavaDoc[]) null);
334                     mapperName = (String JavaDoc) meth.invoke(cls, (Object JavaDoc[]) null);
335                 } catch (Exception JavaDoc e1) {
336                     if (TraceEjb.isDebugIc()) {
337                         TraceEjb.interp.log(BasicLevel.DEBUG, "Cannot read mapper name", e1);
338                     }
339                 }
340                 if (mapperName == null || mapperName.trim().length() == 0) {
341                     // Method doesn't exist so go read mapper.properties and
342
// look for jndiname mapping
343
try {
344                         JProp dsProps = JProp.getInstance("mapper");
345                         mapperName = dsProps.getValue(dsn, "");
346                     } catch (Exception JavaDoc e2) {
347                         throw new EJBException JavaDoc("Unable to retrieve mapperName for " + dsn, e2);
348                     }
349                     if (mapperName == null) {
350                         throw new EJBException JavaDoc("Unable to retrieve mapperName for " + dsn + ". mappername is null.");
351                     }
352                 }
353
354                 cn = ecd.getFactoryClassName();
355                 bf = (JEntityFactory) loader.loadClass(cn).newInstance();
356                 ((RdbFactory) bf).init(ecd, this, mapperName);
357                 setSwapTime(((EntityDesc) ecd).getPassivationTimeout());
358                 TraceEjb.interp.log(BasicLevel.INFO, beanName + " is loaded and using " + mapperName);
359             } catch (Exception JavaDoc e) {
360                 TraceEjb.interp.log(BasicLevel.ERROR, "Impossible to instanciate the entity factory: " + cn, e);
361                 throw new EJBException JavaDoc("Impossible to instanciate the entity factory: " + cn, e);
362             }
363         } else if (dd instanceof EntityDesc) {
364             if (TraceEjb.isDebugIc()) {
365                 TraceEjb.interp.log(BasicLevel.DEBUG, "add EntityBean " + beanName);
366             }
367             // Instanciate the default factory
368
String JavaDoc cn = null;
369             try {
370                 cn = DEFAULT_FACTORY_CLASS_NAME;
371                 bf = (JEntityFactory) loader.loadClass(cn).newInstance();
372             } catch (Exception JavaDoc e) {
373                 throw new EJBException JavaDoc("Impossible to instanciate the specified entity factory: " + cn, e);
374             }
375             ((JEntityFactory) bf).init((EntityDesc) dd, this);
376             setSwapTime(((EntityDesc) dd).getPassivationTimeout());
377         } else {
378             throw new EJBException JavaDoc("Bad Descriptor Type for " + beanName);
379         }
380         beanList.put(beanName, bf);
381         TraceEjb.interp.log(BasicLevel.INFO, beanName + " available");
382         return bf;
383     }
384
385     /**
386      * Used by the above getXXXDependence() methods.
387      * @param beanFactories the bean factories managed by this container.
388      * @param rName jndi name of a resource (datasource, JMS destination or
389      * connection factory, mail factory).
390      * @param isResRef true for resource-ref, false for resource-env-ref.
391      * @return set of Properties, where each Properties provides the bean name,
392      * the container's file-name and the type of the bean which uses the
393      * resource.
394      */

395     private Set JavaDoc beansDependence(Enumeration JavaDoc beanFactories, String JavaDoc rName, boolean isResRef) {
396         HashSet JavaDoc result = new HashSet JavaDoc();
397         BeanFactory bf = null;
398         while (beanFactories.hasMoreElements()) {
399             // for each bean,
400
bf = (BeanFactory) beanFactories.nextElement();
401             BeanDesc ejbDesc = bf.getDeploymentDescriptor();
402
403             boolean isDependent = false; // suppose its not dependent
404

405             // get its type from the DeploymentDescriptor
406
String JavaDoc ejbType = null;
407             if (bf instanceof JEntityFactory) {
408                 if (ejbDesc instanceof EntityBmpDesc) {
409                     ejbType = "ejbbmp";
410                 }
411                 if (ejbDesc instanceof EntityCmpDesc) {
412                     ejbType = "ejbcmp";
413                 }
414             } else if (bf instanceof JStatefulFactory) {
415                 ejbType = "ejbsbf";
416             } else if (bf instanceof JStatelessFactory) {
417                 ejbType = "ejbsbl";
418             } else if (bf instanceof JMdbFactory || bf instanceof JMdbEndpointFactory) {
419                 ejbType = "ejbmdb";
420             }
421
422             if (isResRef) {
423                 // if this is a cmp bean, directly compare rName with the data
424
// source JNDI name
425
// from its deployment descriptor
426
if (ejbType.equals("ejbcmp")) {
427                     String JavaDoc jndiName = null;
428                     if (ejbDesc instanceof EntityJdbcCmp1Desc) {
429                         jndiName = ((EntityJdbcCmp1Desc) ejbDesc).getDatasourceJndiName();
430                     } else if (ejbDesc instanceof EntityJdbcCmp2Desc) {
431                         jndiName = ((EntityJdbcCmp2Desc) ejbDesc).getDatasourceJndiName();
432                     }
433                     isDependent = rName.equals(jndiName);
434                 }
435                 // get the description of the bean's resource-refs
436
ResourceRefDesc[] rrDesc = ejbDesc.getResourceRefDesc();
437                 for (int i = 0; i < rrDesc.length; i++) {
438                     // for each resource-ref compare its name with rName
439
if (rrDesc[i].getJndiName().equals(rName)) {
440                         isDependent = true;
441                         break;
442                     }
443                 }
444             } else {
445                 if (ejbType.equals("ejbmdb")) {
446                     if (rName.equals(((MessageDrivenDesc) ejbDesc).getDestinationJndiName())) {
447                         isDependent = true;
448                     }
449                 }
450                 // get the description of the bean's resource-env-refs
451
ResourceEnvRefDesc[] rerDesc = ejbDesc.getResourceEnvRefDesc();
452                 for (int i = 0; i < rerDesc.length; i++) {
453                     // for each resource-env-ref compare its name with rName
454
if (rerDesc[i].getJndiName().equals(rName)) {
455                         isDependent = true;
456                         break;
457                     }
458                 }
459             }
460
461             if (isDependent) {
462                 Properties JavaDoc toAdd = new Properties JavaDoc();
463                 toAdd.setProperty("type", ejbType);
464                 toAdd.setProperty("fname", getFileName());
465                 toAdd.setProperty("name", ejbDesc.getEjbName());
466                 toAdd.setProperty("cname", getName());
467                 String JavaDoc earFileName = getEarFileName();
468                 if (earFileName != null) {
469                     toAdd.setProperty("earFileName", earFileName);
470                 }
471                 result.add(toAdd);
472             }
473
474         }
475         return result;
476     }
477
478     /**
479      * Check Security. No control for Message Driven Beans
480      * @param ejbName name of the EJB of which do control
481      * @param ejbInv object containing security signature of the method, args of
482      * method, etc
483      * @param inRunAs bean calling this method is running in run-as mode or not ?
484      */

485     protected void checkSecurity(String JavaDoc ejbName, EJBInvocation ejbInv, boolean inRunAs) {
486         String JavaDoc oldContextId = PolicyContext.getContextID();
487
488         boolean accessIsOk = false;
489         try {
490             // Set contextID to PermissionManager contextID (EJB ContextID)
491
if (permissionManager != null) {
492                 accessIsOk = permissionManager.checkSecurity(ejbName, ejbInv, inRunAs);
493             }
494         } catch (Exception JavaDoc e) {
495             TraceEjb.security.log(BasicLevel.ERROR, "Error while checking security", e);
496         } finally {
497             PolicyContext.setContextID(oldContextId);
498         }
499         if (!accessIsOk) {
500             StringBuffer JavaDoc errMsg = new StringBuffer JavaDoc("Access Denied on bean '");
501             errMsg.append(ejbName);
502             errMsg.append("' with run-as = '");
503             errMsg.append(inRunAs);
504             errMsg.append("'. ");
505             if (ejbInv != null && ejbInv.methodPermissionSignature != null) {
506                 errMsg.append(" Method signature = '");
507                 errMsg.append(ejbInv.methodPermissionSignature);
508                 errMsg.append("'.");
509             }
510             throw new AccessLocalException JavaDoc(errMsg.toString());
511         }
512
513     }
514
515     /**
516      * Get the bean factory for the given bean.
517      * @param ejbName the name of the bean
518      * @return the bean factory for this bean
519      */

520     public BeanFactory getBeanFactory(String JavaDoc ejbName) {
521         return (BeanFactory) beanList.get(ejbName);
522     }
523
524     /**
525      * @return total Number of Beans
526      */

527     public int getBeanNb() {
528         return beanList.size();
529     }
530
531     /**
532      * @return the classloader used for this Container
533      */

534     public ClassLoader JavaDoc getClassLoader() {
535         if (loader == null) {
536             TraceEjb.logger.log(BasicLevel.ERROR, "container has been removed");
537             //return Thread.currentThread().getContextClassLoader();
538
return null;
539         } else {
540             return loader;
541         }
542     }
543
544     /**
545      * used internally by all the EJB Container classes.
546      * @return the ContainerNaming object
547      */

548     public ContainerNaming getContainerNaming() {
549         return naming;
550     }
551
552     /**
553      * Management method used by the EJBServiceImpl MBean. Determine which are
554      * the ejbs using a given data source.
555      * @param dsName JNDI name of the data source
556      * @return a set of Properties describing the beans that use the data source
557      */

558     public Set JavaDoc getDataSourceDependence(String JavaDoc dsName) {
559         // the true param corresponds to a resource-ref
560
return beansDependence(Collections.enumeration(beanList.values()), dsName, true);
561     }
562
563     /**
564      * get the name of the ear application containing this container.
565      * @return the name of the ear application containing this container.
566      */

567     public String JavaDoc getEarFileName() {
568         return earFileName;
569     }
570
571     /**
572      * @return int Number of BMP type currently in this container
573      */

574     public int getEntityBMPNb() {
575         BeanFactory bf;
576         int total = 0;
577         Iterator JavaDoc it = beanList.values().iterator();
578         while (it.hasNext()) {
579             bf = (BeanFactory) it.next();
580             if (bf.getDeploymentDescriptor() instanceof EntityBmpDesc) {
581                 total++;
582             }
583         }
584         return total;
585     }
586
587     /**
588      * @return int Number of CMP type currently in this container
589      */

590     public int getEntityCMPNb() {
591         BeanFactory bf;
592         int total = 0;
593         Iterator JavaDoc it = beanList.values().iterator();
594         while (it.hasNext()) {
595             bf = (BeanFactory) it.next();
596             if (bf.getDeploymentDescriptor() instanceof EntityCmpDesc) {
597                 total++;
598             }
599         }
600         return total;
601     }
602
603     /**
604      * @return the file name of the container (.xml or .jar)
605      */

606     public String JavaDoc getFileName() {
607         return fileName;
608     }
609
610     /**
611      * @return the external file name of the container
612      */

613     public String JavaDoc getExternalFileName() {
614         return externalFileName;
615     }
616
617     /**
618      * Management method used by the EJBServiceImpl MBean. Determine which are
619      * the ejbs using a JMS Connection Factory.
620      * @param cfName JNDI name of a JMS Connection Factory.
621      * @return a set of Properties describing the beans that use the JMS
622      * Connection Factory.
623      */

624     public Set JavaDoc getJmsConnectionFactoryDependence(String JavaDoc cfName) {
625         // the true param corresponds to a resource-ref
626
return beansDependence(Collections.enumeration(beanList.values()), cfName, true);
627     }
628
629     /**
630      * Management method used by the EJBServiceImpl MBean. Determine which are
631      * the beans using a JMS destination.
632      * @param destName JNDI name of a JMS destination
633      * @return a set of Properties describing the ejbs that use the JMS
634      * destination.
635      */

636     public Set JavaDoc getJmsDestinationDependence(String JavaDoc destName) {
637         // the true param corresponds to a resource-ref
638
return beansDependence(Collections.enumeration(beanList.values()), destName, false);
639     }
640
641     /**
642      * used internally by all the EJB Container classes.
643      * @return the JmsManager object
644      */

645     public JmsManager getJmsManager() {
646         return jms;
647     }
648
649     /**
650      * Management method used by the EJBServiceImpl MBean. Determine which are
651      * the ejbs using a Mail Factory.
652      * @param mfName JNDI name of a Mail Factory.
653      * @return a set of Properties describing the beans that use the given Mail
654      * Factory.
655      */

656     public Set JavaDoc getMailFactoryDependence(String JavaDoc mfName) {
657         // the true param corresponds to a resource-ref
658
return beansDependence(Collections.enumeration(beanList.values()), mfName, true);
659     }
660
661     /**
662      * @return int Number of MDB type currently in this container
663      */

664     public int getMessageDrivenNb() {
665         BeanFactory bf;
666         int total = 0;
667         Iterator JavaDoc it = beanList.values().iterator();
668         while (it.hasNext()) {
669             bf = (BeanFactory) it.next();
670             if (bf.getDeploymentDescriptor() instanceof MessageDrivenDesc) {
671                 total++;
672             }
673         }
674         return total;
675     }
676
677     /**
678      * @return name of this Container
679      */

680     public String JavaDoc getName() {
681         return myname;
682     }
683
684     /**
685      * Gets the permission manager
686      * @return the permission manager
687      */

688     public PermissionManager getPermissionManager() {
689         return permissionManager;
690     }
691
692     /**
693      * @return the PrincipalFactory of the Container
694      */

695     public PrincipalFactory getPrincipalFactory() {
696         return principalFactory;
697     }
698
699     /**
700      * @return int Number of SBF type currently in this container
701      */

702     public int getStatefulSessionNb() {
703         BeanFactory bf;
704         int total = 0;
705         Iterator JavaDoc it = beanList.values().iterator();
706         while (it.hasNext()) {
707             bf = (BeanFactory) it.next();
708             if (bf.getDeploymentDescriptor() instanceof SessionStatefulDesc) {
709                 total++;
710             }
711         }
712         return total;
713     }
714
715     /**
716      * @return int Number of SBL type currently in this container
717      */

718     public int getStatelessSessionNb() {
719         BeanFactory bf;
720         int total = 0;
721         Iterator JavaDoc it = beanList.values().iterator();
722         while (it.hasNext()) {
723             bf = (BeanFactory) it.next();
724             if (bf.getDeploymentDescriptor() instanceof SessionStatelessDesc) {
725                 total++;
726    &nbs