KickJava   Java API By Example, From Geeks To Geeks.

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


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;
25
26 import java.util.*;
27 import java.io.File JavaDoc;
28 import java.util.logging.*;
29 import com.sun.logging.*;
30
31 import com.sun.enterprise.deployment.Role;
32 import com.sun.enterprise.util.LocalStringManagerImpl;
33
34 import com.sun.enterprise.deployment.node.ejb.EjbBundleNode;
35 import com.sun.enterprise.deployment.runtime.common.SecurityRoleMapping;
36 import com.sun.enterprise.deployment.runtime.IASPersistenceManagerDescriptor;
37 import com.sun.enterprise.deployment.runtime.PersistenceManagerInUse;
38 import com.sun.enterprise.deployment.util.DescriptorVisitor;
39 import com.sun.enterprise.deployment.util.DOLUtils;
40 import com.sun.enterprise.deployment.util.EjbBundleVisitor;
41 import com.sun.enterprise.deployment.util.EjbVisitor;
42 import com.sun.enterprise.deployment.util.LogDomains;
43 import com.sun.enterprise.deployment.xml.ApplicationTagNames;
44 import javax.enterprise.deploy.shared.ModuleType JavaDoc;
45
46 /**
47  * I represent all the configurable deployment information contained in
48  * an EJB JAR.
49  *
50  * @author Danny Coward
51  */

52
53 public class EjbBundleDescriptor extends BundleDescriptor {
54  
55     public final static String JavaDoc SPEC_VERSION = "2.1";
56    
57     private long uniqueId;
58     private Set ejbs = new HashSet();
59     private Set relationships = new HashSet();
60     private String JavaDoc relationshipsDescription;
61     private String JavaDoc ejbClientJarUri;
62     
63     // list of configured persistence manager
64
private Vector configured_pms = null;
65     private PersistenceManagerInUse pm_inuse = null;
66     
67     // the resource (database) to be used for persisting CMP EntityBeans
68
// the same resource is used for all beans in this ejb jar.
69
private ResourceReferenceDescriptor cmpResourceReference;
70
71     // Application exceptions defined for the ejbs in this module.
72
private Set<EjbApplicationExceptionInfo> applicationExceptions =
73         new HashSet<EjbApplicationExceptionInfo>();
74
75     private static LocalStringManagerImpl localStrings =
76         new LocalStringManagerImpl(EjbBundleDescriptor.class);
77         
78     static Logger _logger = DOLUtils.getDefaultLogger();
79     
80     private List<SecurityRoleMapping> roleMaps = new ArrayList<SecurityRoleMapping>();
81
82     // All interceptor classes defined within this ejb module, keyed by
83
// interceptor class name.
84
private Map<String JavaDoc, EjbInterceptor> interceptors =
85         new HashMap<String JavaDoc, EjbInterceptor>();
86         
87     private LinkedList<InterceptorBindingDescriptor> interceptorBindings =
88         new LinkedList<InterceptorBindingDescriptor>();
89
90     /**
91     * Constructs an ejb bundle descriptor with no ejbs.
92     */

93     public EjbBundleDescriptor() {
94     }
95
96     /**
97      * True if EJB version is 2.x. This is the default
98      * for any new modules.
99      */

100     // XXX
101
// this method is not true anymore now we have ejb3.0, keep this
102
// method as it is for now, will revisit once ejb30 persistence
103
// is implemented
104
public boolean isEJB20() {
105         return !isEJB11();
106     }
107     
108     /**
109      * True if EJB version is 1.x.
110      */

111     public boolean isEJB11() {
112         return getSpecVersion().startsWith("1");
113     }
114
115     /**
116      * @return the default version of the deployment descriptor
117      * loaded by this descriptor
118      */

119     public String JavaDoc getDefaultSpecVersion() {
120         return EjbBundleNode.SPEC_VERSION;
121     }
122
123     /**
124     * Return the emptry String or the entry name of the ejb client JAR
125     * in my archive if I have one.
126     */

127     public String JavaDoc getEjbClientJarUri() {
128     if (this.ejbClientJarUri == null) {
129         this.ejbClientJarUri = "";
130     }
131     return this.ejbClientJarUri;
132     }
133     
134     /**
135     * Sets the ejb client JAR entry name.
136     */

137     
138     public void setEjbClientJarUri(String JavaDoc ejbClientJarUri) {
139     this.ejbClientJarUri = ejbClientJarUri;
140     this.changed();
141     }
142
143     public void addApplicationException(EjbApplicationExceptionInfo appExc) {
144         applicationExceptions.add(appExc);
145     }
146
147     public Set<EjbApplicationExceptionInfo> getApplicationExceptions() {
148         return new HashSet<EjbApplicationExceptionInfo>(applicationExceptions);
149     }
150     
151     public void addEjbBundleDescriptor(EjbBundleDescriptor ejbBundleDescriptor) {
152     super.addBundleDescriptor(ejbBundleDescriptor);
153
154     // mdf - #4400074 ejb added to existing ejb-jar in wizard has wrong bundle
155
//this.getEjbs().addAll(ejbBundleDescriptor.getEjbs());
156
for (Iterator ejbs = ejbBundleDescriptor.getEjbs().iterator(); ejbs.hasNext();) {
157             EjbDescriptor ejbDescriptor = (EjbDescriptor)ejbs.next();
158         ejbDescriptor.setEjbBundleDescriptor(this);
159         this.getEjbs().add(ejbDescriptor);
160     }
161
162     // WebServices
163
WebServicesDescriptor thisWebServices = this.getWebServices();
164     WebServicesDescriptor otherWebServices = ejbBundleDescriptor.getWebServices();
165     for (Iterator i = otherWebServices.getWebServices().iterator(); i.hasNext();) {
166         WebService ws = (WebService)i.next();
167         thisWebServices.addWebService(new WebService(ws));
168     }
169
170     this.changed();
171     }
172      
173     /**
174     * Return the set of NamedDescriptors that I have.
175     */

176     public Collection getNamedDescriptors() {
177     Collection namedDescriptors = new Vector();
178     for (Iterator ejbs = this.getEjbs().iterator(); ejbs.hasNext();) {
179         EjbDescriptor ejbDescriptor = (EjbDescriptor) ejbs.next();
180         namedDescriptors.add(ejbDescriptor);
181         namedDescriptors.addAll(super.getNamedDescriptorsFrom(ejbDescriptor));
182     }
183     return namedDescriptors;
184     }
185     
186     /**
187     * Return all the named descriptors I have together with the descriptor
188     * that references each one in a Vector of NameReferencePairs.
189     */

190     
191     public Vector getNamedReferencePairs() {
192     Vector pairs = new Vector();
193     for (Iterator ejbs = this.getEjbs().iterator(); ejbs.hasNext();) {
194         EjbDescriptor ejbDescriptor = (EjbDescriptor) ejbs.next();
195         pairs.add(NamedReferencePair.createEjbPair(ejbDescriptor,
196                                                        ejbDescriptor));
197         pairs.addAll(super.getNamedReferencePairsFrom(ejbDescriptor));
198     }
199     return pairs;
200     }
201     
202     /**
203     * Return the set of references to resources that I have.
204     */

205     public Set getResourceReferenceDescriptors() {
206     Set resourceReferences = new HashSet();
207     for (Iterator itr = this.getEjbs().iterator(); itr.hasNext();) {
208         EjbDescriptor ejbDescriptor = (EjbDescriptor) itr.next();
209         resourceReferences.addAll(ejbDescriptor.getResourceReferenceDescriptors());
210     }
211     return resourceReferences;
212     }
213     
214     /**
215     * Return true if I reference other ejbs, false else.
216     */

217     public boolean hasEjbReferences() {
218     for (Iterator itr = this.getEjbs().iterator(); itr.hasNext();) {
219         EjbDescriptor nextEjbDescriptor = (EjbDescriptor) itr.next();
220         if (!nextEjbDescriptor.getEjbReferenceDescriptors().isEmpty()) {
221         return true;
222         }
223     }
224     return false;
225     }
226
227     /**
228     * Return the Set of ejb descriptors that I have.
229     */

230     public Set getEjbs() {
231     return this.ejbs;
232     }
233     
234     /**
235     * Returns true if I have an ejb descriptor by that name.
236     */

237     public boolean hasEjbByName(String JavaDoc name) {
238     for (Iterator itr = this.getEjbs().iterator(); itr.hasNext();) {
239         Descriptor next = (Descriptor) itr.next();
240         if (next.getName().equals(name)) {
241         return true;
242         }
243     }
244     return false;
245     }
246     
247     /**
248     * Returns an ejb descriptor that I have by the same name, otherwise
249     * throws an IllegalArgumentException
250     */

251     public EjbDescriptor getEjbByName(String JavaDoc name) {
252     for (Iterator itr = this.getEjbs().iterator(); itr.hasNext();) {
253         Descriptor next = (Descriptor) itr.next();
254         if (next.getName().equals(name)) {
255         return (EjbDescriptor) next;
256         }
257     }
258     throw new IllegalArgumentException JavaDoc(localStrings.getLocalString(
259        "enterprise.deployment.exceptionbeanbundle",
260        "Referencing error: this bundle has no bean of name: {0}",
261            new Object JavaDoc[] {name}));
262     }
263
264     /**
265      * Returns all ejb descriptors that has a give Class name.
266      * It returns an empty array if no ejb is found.
267      */

268     public EjbDescriptor[] getEjbByClassName(String JavaDoc className) {
269         ArrayList<EjbDescriptor> ejbList = new ArrayList<EjbDescriptor>();
270     for (Object JavaDoc ejb : this.getEjbs()) {
271             if (ejb instanceof EjbDescriptor) {
272                 EjbDescriptor ejbDesc = (EjbDescriptor)ejb;
273                 if (className.equals(ejbDesc.getEjbClassName())) {
274                     ejbList.add(ejbDesc);
275                 }
276             }
277     }
278         return ejbList.toArray(new EjbDescriptor[ejbList.size()]);
279     }
280     
281     /**
282     * Add an ejb to me.
283     */

284     public void addEjb(EjbDescriptor ejbDescriptor) {
285     ejbDescriptor.setEjbBundleDescriptor(this);
286     this.getEjbs().add(ejbDescriptor);
287     super.changed();
288     }
289     
290     /**
291     * Remove the given ejb descriptor from my (by equality).
292     */

293     
294     public void removeEjb(EjbDescriptor ejbDescriptor) {
295     ejbDescriptor.setEjbBundleDescriptor(null);
296     this.getEjbs().remove(ejbDescriptor);
297     super.changed();
298     }
299      
300
301     /**
302      * Called only from EjbDescriptor.replaceEjbDescriptor, in wizard mode.
303      */

304     void replaceEjb(EjbDescriptor oldEjbDescriptor, EjbDescriptor newEjbDescriptor) {
305     oldEjbDescriptor.setEjbBundleDescriptor(null);
306     this.getEjbs().remove(oldEjbDescriptor);
307     newEjbDescriptor.setEjbBundleDescriptor(this);
308     this.getEjbs().add(newEjbDescriptor);
309     //super.changed(); no need to notify listeners in wizard mode ??
310
}
311     
312     /**
313      * @return true if this bundle descriptor contains at least one CMP
314      * EntityBean
315      */

316     public boolean containsCMPEntity() {
317         
318         Set ejbs = getEjbs();
319         if (ejbs==null)
320             return false;
321         for (Iterator ejbsItr = ejbs.iterator();ejbsItr.hasNext();) {
322             if (ejbsItr.next() instanceof EjbCMPEntityDescriptor) {
323                 return true;
324             }
325         }
326         return false;
327     }
328
329     public void addInterceptor(EjbInterceptor interceptor) {
330         EjbInterceptor ic =
331             getInterceptorByClassName(interceptor.getInterceptorClassName());
332         if (ic == null) {
333             interceptor.setEjbBundleDescriptor(this);
334             interceptors.put(interceptor.getInterceptorClassName(), interceptor);
335         }
336     }
337     
338     public EjbInterceptor getInterceptorByClassName(String JavaDoc className) {
339
340         return interceptors.get(className);
341
342     }
343
344     public boolean hasInterceptors() {
345
346         return (interceptors.size() > 0);
347
348     }
349
350     public Set<EjbInterceptor> getInterceptors() {
351
352         return new HashSet<EjbInterceptor>(interceptors.values());
353
354     }
355
356     public void prependInterceptorBinding(InterceptorBindingDescriptor binding)
357     {
358         interceptorBindings.addFirst(binding);
359     }
360
361     public void appendInterceptorBinding(InterceptorBindingDescriptor binding)
362     {
363         interceptorBindings.addLast(binding);
364     }
365
366     public List<InterceptorBindingDescriptor> getInterceptorBindings() {
367         return new LinkedList<InterceptorBindingDescriptor>
368             (interceptorBindings);
369     }
370
371     public void setInterceptorBindings(List<InterceptorBindingDescriptor>
372                                        bindings) {
373         interceptorBindings = new LinkedList<InterceptorBindingDescriptor>();
374         interceptorBindings.addAll(bindings);
375     }
376
377     /**
378     * Checks whether the role references my ejbs have reference roles that I have.
379     */

380     
381     public boolean areResourceReferencesValid() {
382     // run through each of the ejb's role references, checking that the roles exist in this bundle
383
for (Iterator itr = this.getEjbs().iterator(); itr.hasNext();) {
384         EjbDescriptor ejbDescriptor = (EjbDescriptor) itr.next();
385         for (Iterator roleRefs = ejbDescriptor.getRoleReferences().iterator(); roleRefs.hasNext();) {
386         RoleReference roleReference = (RoleReference) roleRefs.next();
387         Role referredRole = roleReference.getRole();
388         if (!referredRole.getName().equals("")
389             && !super.getRoles().contains(referredRole) ) {
390             
391             _logger.log(Level.FINE,localStrings.getLocalString(
392                "enterprise.deployment.badrolereference",
393                "Warning: Bad role reference to {0}", new Object JavaDoc[] {referredRole}));
394             _logger.log(Level.FINE,"Roles: "+ this.getRoles());
395             return false;
396         }
397         }
398     }
399     return true;
400     }
401     
402     /**
403     * Removes the given com.sun.enterprise.deployment.Role object from me.
404     */

405     public void removeRole(Role role) {
406     if (super.getRoles().contains(role)) {
407         for (Iterator itr = this.getEjbs().iterator(); itr.hasNext();) {
408         EjbDescriptor ejbDescriptor = (EjbDescriptor) itr.next();
409         ejbDescriptor.removeRole(role);
410         }
411         super.removeRole(role);
412     }
413     }
414     
415     /**
416     * Returns true if I have Roles to which method permissions have been assigned.
417     */

418     public boolean hasPermissionedRoles() {
419     for (Iterator itr = this.getEjbs().iterator(); itr.hasNext();) {
420         EjbDescriptor nextEjbDescriptor = (EjbDescriptor) itr.next();
421         if (!nextEjbDescriptor.getPermissionedMethodsByPermission().isEmpty()) {
422         return true;
423         }
424     }
425     return false;
426     }
427     
428     /**
429     * Return true if any of my ejb's methods have been assigned transaction attributes.
430     */

431     public boolean hasContainerTransactions() {
432     for (Iterator itr = this.getEjbs().iterator(); itr.hasNext();) {
433         EjbDescriptor nextEjbDescriptor = (EjbDescriptor) itr.next();
434         if (!nextEjbDescriptor.getMethodContainerTransactions().isEmpty()) {
435         return true;
436         }
437     }
438     return false;
439     }
440     
441     /**
442     * Return true if I have roles, permissioned roles or container transactions.
443     */

444     public boolean hasAssemblyInformation() {
445     return (!this.getRoles().isEmpty())
446         || this.hasPermissionedRoles()
447             || this.hasContainerTransactions();
448     
449     }
450     
451     /**
452      * Add a RelationshipDescriptor which describes a CMR field
453      * between a bean/DO/entityRef in this ejb-jar.
454      */

455     public void addRelationship(RelationshipDescriptor relDesc)
456     {
457         relationships.add(relDesc);
458         super.changed();
459     }
460
461     /**
462      * Add a RelationshipDescriptor which describes a CMR field
463      * between a bean/DO/entityRef in this ejb-jar.
464      */

465     public void removeRelationship(RelationshipDescriptor relDesc)
466     {
467         relationships.remove(relDesc);
468         super.changed();
469     }
470
471  
472     /**
473      * EJB2.0: get description for <relationships> element.
474      */

475     public String JavaDoc getRelationshipsDescription() {
476     if ( relationshipsDescription == null )
477         relationshipsDescription = "";
478     return relationshipsDescription;
479     }
480  
481     /**
482      * EJB2.0: set description for <relationships> element.
483      */

484     public void setRelationshipsDescription(String JavaDoc relationshipsDescription) {
485     this.relationshipsDescription = relationshipsDescription;
486     }
487     
488
489     /**
490      * Get all relationships in this ejb-jar.
491      * @return a Set of RelationshipDescriptors.
492      */

493     public Set getRelationships()
494     {
495         return relationships;
496     }
497
498     public boolean hasRelationships()
499     {
500     return (relationships.size() > 0);
501     }
502
503     /**
504      * Returns true if given relationship is already part of this
505      * ejb-jar.
506      */

507     public boolean hasRelationship(RelationshipDescriptor rd) {
508         return relationships.contains(rd);
509     }
510
511     /**
512      * Return the Resource I use for CMP.
513      */

514     public ResourceReferenceDescriptor getCMPResourceReference() {
515     return this.cmpResourceReference;
516     }
517     
518     /**
519      * Sets the resource reference I use for CMP.
520      */

521     public void setCMPResourceReference(ResourceReferenceDescriptor resourceReference) {
522     this.cmpResourceReference = resourceReference;
523     this.changed();
524     }
525     
526
527
528     public Descriptor getDescriptorByName(String JavaDoc name)
529     {
530         try {
531             return getEjbByName(name);
532         } catch(IllegalArgumentException JavaDoc iae) {
533             // Bundle doesn't contain ejb with the given name.
534
return null;
535         }
536     }
537
538     /**
539     * Returns my name.
540     */

541
542     public String JavaDoc getName() {
543     if ("".equals(super.getName())) {
544         super.setName("Ejb1");
545     }
546     return super.getName();
547     }
548     
549     private void doMethodDescriptorConversions() throws Exception JavaDoc {
550     for (Iterator itr = this.getEjbs().iterator(); itr.hasNext();) {
551         EjbDescriptor ejbDescriptor = (EjbDescriptor) itr.next();
552         ejbDescriptor.doMethodDescriptorConversions();
553     }
554     }
555     
556         // START OF IASRI 4645310
557
/**
558      * Sets the unique id for a stand alone ejb module. It traverses through
559      * all the ejbs in this stand alone module and sets the unique id for
560      * each of them. The traversal order is done in ascending element order.
561      *
562      * <p> Note: This method will not be called for application.
563      *
564      * @param id unique id for stand alone module
565      */

566     public void setUniqueId(long id)
567     {
568         this.uniqueId = id;
569
570         // First sort the beans in alphabetical order.
571
EjbDescriptor[] descs = (EjbDescriptor[])ejbs.toArray(
572                                     new EjbDescriptor[ejbs.size()]);
573
574
575         // The sorting algorithm used by this api is a modified mergesort.
576
// This algorithm offers guaranteed n*log(n) performance, and
577
// can approach linear performance on nearly sorted lists.
578
Arrays.sort(descs,
579             new Comparator() {
580                 public int compare(Object JavaDoc o1, Object JavaDoc o2) {
581                     return (((EjbDescriptor)o1).getName()).compareTo(
582                                             ((EjbDescriptor)o2).getName());
583                 }
584             }
585         );
586
587         for (int i=0; i<descs.length; i++)
588         {
589             // 2^16 beans max per stand alone module
590
descs[i].setUniqueId( (id | i) );
591         }
592     }
593
594     /**
595      * Returns the unique id used in a stand alone ejb module.
596      * For application, this will return zero.
597      *
598      * @return the unique if used in stand alone ejb module
599      */

600     public long getUniqueId()
601     {
602         return uniqueId;
603     }
604
605     public static int getIdFromEjbId(long ejbId)
606     {
607     long id = ejbId >> 32;
608     return (int)id;
609     }
610     
611     /**
612      * @return true if this bundle descriptor defines web service clients
613      */

614     public boolean hasWebServiceClients() {
615         for(Iterator ejbs = getEjbs().iterator();ejbs.hasNext();) {
616             EjbDescriptor next = (EjbDescriptor) ejbs.next();
617             Collection serviceRefs = next.getServiceReferenceDescriptors();
618             if( !(serviceRefs.isEmpty()) ) {
619                return true;
620             }
621         }
622         return false;
623     }
624     
625     /**
626      * @return a set of service-ref from this bundle or null
627      * if none
628      */

629     public Set getServiceReferenceDescriptors() {
630         Set serviceRefs = new OrderedSet();
631         for(Iterator ejbs = getEjbs().iterator();ejbs.hasNext();) {
632             EjbDescriptor next = (EjbDescriptor) ejbs.next();
633             serviceRefs.addAll(next.getServiceReferenceDescriptors());
634         }
635         return serviceRefs;
636     }
637     
638     /**
639     * Returns a formatted String representing my state.
640     */

641     public void print(StringBuffer JavaDoc toStringBuffer) {
642     toStringBuffer.append("EjbBundleDescriptor\n");
643         super.print(toStringBuffer);
644         if (cmpResourceReference!=null) {
645             toStringBuffer.append("\ncmp resource ");
646             ((Descriptor)cmpResourceReference).print(toStringBuffer);
647         }
648     toStringBuffer.append("\nclient JAR ").append(this.getEjbClientJarUri());
649     for (Iterator itr = this.getEjbs().iterator(); itr.hasNext();) {
650         toStringBuffer.append("\n------------\n");
651         ((Descriptor)itr.next()).print(toStringBuffer);
652         toStringBuffer.append("\n------------") ;
653     }
654     }
655     
656     /**
657      * visit the descriptor and all sub descriptors with a DOL visitor implementation
658      *
659      * @param a visitor to traverse the descriptors
660      */

661     public void visit(DescriptorVisitor aVisitor) {
662         if (aVisitor instanceof EjbBundleVisitor) {
663             visit((EjbBundleVisitor) aVisitor);
664         } else {
665             super.visit(aVisitor);
666         }
667     }
668
669     /**
670      * visit the descriptor and all sub descriptors with a DOL visitor implementation
671      *
672      * @param a visitor to traverse the descriptors
673      */

674     public void visit(EjbBundleVisitor aVisitor) {
675         aVisitor.accept(this);
676         EjbVisitor ejbVisitor = aVisitor.getEjbVisitor();
677         if (ejbVisitor != null) {
678             for (Iterator itr = this.getEjbs().iterator(); itr.hasNext();) {
679                 EjbDescriptor anEjb = (EjbDescriptor) itr.next();
680                 anEjb.visit(ejbVisitor);
681             }
682         }
683         if (hasRelationships()) {
684             for (Iterator itr = getRelationships().iterator();itr.hasNext();) {
685                 RelationshipDescriptor rd = (RelationshipDescriptor) itr.next();
686                 aVisitor.accept(rd);
687             }
688         }
689         for (Iterator itr=getWebServices().getWebServices().iterator();
690              itr.hasNext(); ) {
691             WebService aWebService = (WebService) itr.next();
692             aVisitor.accept(aWebService);
693         }
694         for (Iterator itr = getMessageDestinations().iterator();
695                 itr.hasNext();) {
696             MessageDestinationDescriptor msgDestDescriptor =
697                 (MessageDestinationDescriptor)itr.next();
698             aVisitor.accept(msgDestDescriptor);
699         }
700     }
701  
702     /**
703      * @return the module type for this bundle descriptor
704      */

705     public ModuleType JavaDoc getModuleType() {
706         return ModuleType.EJB;
707     }
708     
709     public void setPersistenceManagerInuse(String JavaDoc id,String JavaDoc ver)
710     {
711     pm_inuse=new PersistenceManagerInUse(id, ver);
712         if (_logger.isLoggable(Level.FINE))
713         _logger.fine("***IASEjbBundleDescriptor"
714                 + ".setPersistenceManagerInUse done -#- ");
715     }
716     
717     public void setPersistenceManagerInUse(PersistenceManagerInUse inuse) {
718     pm_inuse = inuse;
719     }
720         
721     public PersistenceManagerInUse getPersistenceManagerInUse()
722     {
723         return pm_inuse;
724     }
725                 
726     public void addPersistenceManager(IASPersistenceManagerDescriptor pmDesc)
727     {
728         if (configured_pms==null) {
729             configured_pms=new Vector();
730         }
731         configured_pms.add(pmDesc);
732         if (_logger.isLoggable(Level.FINE))
733             _logger.fine("***IASEjbBundleDescriptor"
734                + ".addPersistenceManager done -#- ");
735     }
736         
737     public IASPersistenceManagerDescriptor getPreferredPersistenceManager()
738     {
739         boolean debug = _logger.isLoggable(Level.FINE);
740
741         if (configured_pms == null || configured_pms.size() == 0) {
742             // return the default persistence manager descriptor
743
return null;
744         }
745
746         String JavaDoc pminuse_id = pm_inuse.get_pm_identifier().trim();
747         String JavaDoc pminuse_ver = pm_inuse.get_pm_version().trim();
748         if (debug) {
749              _logger.fine("IASPersistenceManagerDescriptor.getPreferred - inid*" +
750                 pminuse_id.trim() + "*");
751              _logger.fine("IASPersistenceManagerDescriptor.getPreferred - inver*" +
752                 pminuse_ver.trim() + "*");
753         }
754
755         int size = configured_pms.size();
756         for(int i = 0; i < size; i++) {
757             IASPersistenceManagerDescriptor pmdesc=(IASPersistenceManagerDescriptor)configured_pms.elementAt(i);
758         String JavaDoc pmdesc_id = pmdesc.getPersistenceManagerIdentifier();
759         String JavaDoc pmdesc_ver = pmdesc.getPersistenceManagerVersion();
760
761             if (debug) {
762             _logger.fine("IASPersistenceManagerDescriptor.getPreferred - pmid*" +
763                     pmdesc_id.trim() + "*");
764             _logger.fine("IASPersistenceManagerDescriptor.getPreferred - pmver*" +
765                     pmdesc_ver.trim() + "*");
766             }
767
768
769             if( ((pmdesc_id.trim()).equals(pminuse_id)) &&
770                 ((pmdesc_ver.trim()).equals(pminuse_ver)) ) {
771
772                 if (debug)
773             _logger.fine("***IASEjbBundleDescriptor.getPreferredPersistenceManager done -#- ");
774
775                 return (IASPersistenceManagerDescriptor)pmdesc;
776         }
777     }
778     throw new IllegalArgumentException JavaDoc(localStrings.getLocalString(
779        "enterprise.deployment.nomatchingpminusefound",
780        "No PersistenceManager found that matches specified PersistenceManager in use."));
781     }
782
783     public Vector getPersistenceManagers()
784     {
785         if (_logger.isLoggable(Level.FINE))
786         _logger.fine("***IASEjbBundleDescriptor.getPersistenceManagers done -#- ");
787     return configured_pms;
788     }
789     
790     public void addSecurityRoleMapping(SecurityRoleMapping roleMapping) {
791         roleMaps.add(roleMapping);
792     }
793
794     public List<SecurityRoleMapping> getSecurityRoleMappings() {
795         return roleMaps;
796     }
797 }
798
Popular Tags