Source Code Cross Referenced for NamingResources.java in  » Sevlet-Container » tomcat-catalina » org » apache » catalina » deploy » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Sevlet Container » tomcat catalina » org.apache.catalina.deploy 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 1999,2004 The Apache Software Foundation.
003:         * 
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         * 
008:         *      http://www.apache.org/licenses/LICENSE-2.0
009:         * 
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:
017:        package org.apache.catalina.deploy;
018:
019:        import java.beans.PropertyChangeListener;
020:        import java.beans.PropertyChangeSupport;
021:        import java.util.HashMap;
022:        import java.util.Hashtable;
023:        import java.io.Serializable;
024:
025:        /**
026:         * Holds and manages the naming resources defined in the J2EE Enterprise 
027:         * Naming Context and their associated JNDI context.
028:         *
029:         * @author Remy Maucherat
030:         * @version $Revision: 1.6 $ $Date: 2004/05/26 15:46:22 $
031:         */
032:
033:        public class NamingResources implements  Serializable {
034:
035:            // ----------------------------------------------------------- Constructors
036:
037:            /**
038:             * Create a new NamingResources instance.
039:             */
040:            public NamingResources() {
041:            }
042:
043:            // ----------------------------------------------------- Instance Variables
044:
045:            /**
046:             * Associated container object.
047:             */
048:            private Object container = null;
049:
050:            /**
051:             * List of naming entries, keyed by name. The value is the entry type, as
052:             * declared by the user.
053:             */
054:            private Hashtable entries = new Hashtable();
055:
056:            /**
057:             * The EJB resource references for this web application, keyed by name.
058:             */
059:            private HashMap ejbs = new HashMap();
060:
061:            /**
062:             * The environment entries for this web application, keyed by name.
063:             */
064:            private HashMap envs = new HashMap();
065:
066:            /**
067:             * The local  EJB resource references for this web application, keyed by
068:             * name.
069:             */
070:            private HashMap localEjbs = new HashMap();
071:
072:            /**
073:             * The message destination referencess for this web application,
074:             * keyed by name.
075:             */
076:            private HashMap mdrs = new HashMap();
077:
078:            /**
079:             * The resource environment references for this web application,
080:             * keyed by name.
081:             */
082:            private HashMap resourceEnvRefs = new HashMap();
083:
084:            /**
085:             * The resource references for this web application, keyed by name.
086:             */
087:            private HashMap resources = new HashMap();
088:
089:            /**
090:             * The resource links for this web application, keyed by name.
091:             */
092:            private HashMap resourceLinks = new HashMap();
093:
094:            /**
095:             * The resource parameters for this web application, keyed by name.
096:             */
097:            private HashMap resourceParams = new HashMap();
098:
099:            /**
100:             * The property change support for this component.
101:             */
102:            protected PropertyChangeSupport support = new PropertyChangeSupport(
103:                    this );
104:
105:            // ------------------------------------------------------------- Properties
106:
107:            /**
108:             * Get the container with which the naming resources are associated.
109:             */
110:            public Object getContainer() {
111:                return container;
112:            }
113:
114:            /**
115:             * Set the container with which the naming resources are associated.
116:             */
117:            public void setContainer(Object container) {
118:                this .container = container;
119:            }
120:
121:            /**
122:             * Add an EJB resource reference for this web application.
123:             *
124:             * @param ejb New EJB resource reference
125:             */
126:            public void addEjb(ContextEjb ejb) {
127:
128:                if (entries.containsKey(ejb.getName())) {
129:                    return;
130:                } else {
131:                    entries.put(ejb.getName(), ejb.getType());
132:                }
133:
134:                synchronized (ejbs) {
135:                    ejb.setNamingResources(this );
136:                    ejbs.put(ejb.getName(), ejb);
137:                }
138:                support.firePropertyChange("ejb", null, ejb);
139:
140:            }
141:
142:            /**
143:             * Add an environment entry for this web application.
144:             *
145:             * @param environment New environment entry
146:             */
147:            public void addEnvironment(ContextEnvironment environment) {
148:
149:                if (entries.containsKey(environment.getName())) {
150:                    return;
151:                } else {
152:                    entries.put(environment.getName(), environment.getType());
153:                }
154:
155:                synchronized (envs) {
156:                    environment.setNamingResources(this );
157:                    envs.put(environment.getName(), environment);
158:                }
159:                support.firePropertyChange("environment", null, environment);
160:
161:            }
162:
163:            /**
164:             * Add resource parameters for this web application.
165:             *
166:             * @param resourceParameters New resource parameters
167:             */
168:            public void addResourceParams(ResourceParams resourceParameters) {
169:
170:                synchronized (resourceParams) {
171:                    if (resourceParams
172:                            .containsKey(resourceParameters.getName())) {
173:                        return;
174:                    }
175:                    resourceParameters.setNamingResources(this );
176:                    resourceParams.put(resourceParameters.getName(),
177:                            resourceParameters);
178:                }
179:                support.firePropertyChange("resourceParams", null,
180:                        resourceParameters);
181:
182:            }
183:
184:            /**
185:             * Add a local EJB resource reference for this web application.
186:             *
187:             * @param ejb New EJB resource reference
188:             */
189:            public void addLocalEjb(ContextLocalEjb ejb) {
190:
191:                if (entries.containsKey(ejb.getName())) {
192:                    return;
193:                } else {
194:                    entries.put(ejb.getName(), ejb.getType());
195:                }
196:
197:                synchronized (localEjbs) {
198:                    ejb.setNamingResources(this );
199:                    localEjbs.put(ejb.getName(), ejb);
200:                }
201:                support.firePropertyChange("localEjb", null, ejb);
202:
203:            }
204:
205:            /**
206:             * Add a message destination reference for this web application.
207:             *
208:             * @param mdr New message destination reference
209:             */
210:            public void addMessageDestinationRef(MessageDestinationRef mdr) {
211:
212:                if (entries.containsKey(mdr.getName())) {
213:                    return;
214:                } else {
215:                    entries.put(mdr.getName(), mdr.getType());
216:                }
217:
218:                synchronized (mdrs) {
219:                    mdr.setNamingResources(this );
220:                    mdrs.put(mdr.getName(), mdr);
221:                }
222:                support.firePropertyChange("messageDestinationRef", null, mdr);
223:
224:            }
225:
226:            /**
227:             * Add a property change listener to this component.
228:             *
229:             * @param listener The listener to add
230:             */
231:            public void addPropertyChangeListener(
232:                    PropertyChangeListener listener) {
233:
234:                support.addPropertyChangeListener(listener);
235:
236:            }
237:
238:            /**
239:             * Add a resource reference for this web application.
240:             *
241:             * @param resource New resource reference
242:             */
243:            public void addResource(ContextResource resource) {
244:
245:                if (entries.containsKey(resource.getName())) {
246:                    return;
247:                } else {
248:                    entries.put(resource.getName(), resource.getType());
249:                }
250:
251:                synchronized (resources) {
252:                    resource.setNamingResources(this );
253:                    resources.put(resource.getName(), resource);
254:                }
255:                support.firePropertyChange("resource", null, resource);
256:
257:            }
258:
259:            /**
260:             * Add a resource environment reference for this web application.
261:             *
262:             * @param name The resource environment reference name
263:             * @param type The resource environment reference type
264:             */
265:            public void addResourceEnvRef(String name, String type) {
266:
267:                if (entries.containsKey(name)) {
268:                    return;
269:                } else {
270:                    entries.put(name, type);
271:                }
272:
273:                synchronized (resourceEnvRefs) {
274:                    resourceEnvRefs.put(name, type);
275:                }
276:                support.firePropertyChange("resourceEnvRef", null, name + ":"
277:                        + type);
278:
279:            }
280:
281:            /**
282:             * Add a resource link for this web application.
283:             *
284:             * @param resourceLink New resource link
285:             */
286:            public void addResourceLink(ContextResourceLink resourceLink) {
287:
288:                if (entries.containsKey(resourceLink.getName())) {
289:                    return;
290:                } else {
291:                    Object value = resourceLink.getType();
292:                    if (value == null) {
293:                        value = "";
294:                    }
295:                    entries.put(resourceLink.getName(), value);
296:                }
297:
298:                synchronized (resourceLinks) {
299:                    resourceLink.setNamingResources(this );
300:                    resourceLinks.put(resourceLink.getName(), resourceLink);
301:                }
302:                support.firePropertyChange("resourceLink", null, resourceLink);
303:
304:            }
305:
306:            /**
307:             * Return the EJB resource reference with the specified name, if any;
308:             * otherwise, return <code>null</code>.
309:             *
310:             * @param name Name of the desired EJB resource reference
311:             */
312:            public ContextEjb findEjb(String name) {
313:
314:                synchronized (ejbs) {
315:                    return ((ContextEjb) ejbs.get(name));
316:                }
317:
318:            }
319:
320:            /**
321:             * Return the defined EJB resource references for this application.
322:             * If there are none, a zero-length array is returned.
323:             */
324:            public ContextEjb[] findEjbs() {
325:
326:                synchronized (ejbs) {
327:                    ContextEjb results[] = new ContextEjb[ejbs.size()];
328:                    return ((ContextEjb[]) ejbs.values().toArray(results));
329:                }
330:
331:            }
332:
333:            /**
334:             * Return the environment entry with the specified name, if any;
335:             * otherwise, return <code>null</code>.
336:             *
337:             * @param name Name of the desired environment entry
338:             */
339:            public ContextEnvironment findEnvironment(String name) {
340:
341:                synchronized (envs) {
342:                    return ((ContextEnvironment) envs.get(name));
343:                }
344:
345:            }
346:
347:            /**
348:             * Return the set of defined environment entries for this web
349:             * application.  If none have been defined, a zero-length array
350:             * is returned.
351:             */
352:            public ContextEnvironment[] findEnvironments() {
353:
354:                synchronized (envs) {
355:                    ContextEnvironment results[] = new ContextEnvironment[envs
356:                            .size()];
357:                    return ((ContextEnvironment[]) envs.values().toArray(
358:                            results));
359:                }
360:
361:            }
362:
363:            /**
364:             * Return the local EJB resource reference with the specified name, if any;
365:             * otherwise, return <code>null</code>.
366:             *
367:             * @param name Name of the desired EJB resource reference
368:             */
369:            public ContextLocalEjb findLocalEjb(String name) {
370:
371:                synchronized (localEjbs) {
372:                    return ((ContextLocalEjb) localEjbs.get(name));
373:                }
374:
375:            }
376:
377:            /**
378:             * Return the defined local EJB resource references for this application.
379:             * If there are none, a zero-length array is returned.
380:             */
381:            public ContextLocalEjb[] findLocalEjbs() {
382:
383:                synchronized (localEjbs) {
384:                    ContextLocalEjb results[] = new ContextLocalEjb[localEjbs
385:                            .size()];
386:                    return ((ContextLocalEjb[]) localEjbs.values().toArray(
387:                            results));
388:                }
389:
390:            }
391:
392:            /**
393:             * Return the message destination reference with the specified name,
394:             * if any; otherwise, return <code>null</code>.
395:             *
396:             * @param name Name of the desired message destination reference
397:             */
398:            public MessageDestinationRef findMessageDestinationRef(String name) {
399:
400:                synchronized (mdrs) {
401:                    return ((MessageDestinationRef) mdrs.get(name));
402:                }
403:
404:            }
405:
406:            /**
407:             * Return the defined message destination references for this application.
408:             * If there are none, a zero-length array is returned.
409:             */
410:            public MessageDestinationRef[] findMessageDestinationRefs() {
411:
412:                synchronized (mdrs) {
413:                    MessageDestinationRef results[] = new MessageDestinationRef[mdrs
414:                            .size()];
415:                    return ((MessageDestinationRef[]) mdrs.values().toArray(
416:                            results));
417:                }
418:
419:            }
420:
421:            /**
422:             * Return the resource reference with the specified name, if any;
423:             * otherwise return <code>null</code>.
424:             *
425:             * @param name Name of the desired resource reference
426:             */
427:            public ContextResource findResource(String name) {
428:
429:                synchronized (resources) {
430:                    return ((ContextResource) resources.get(name));
431:                }
432:
433:            }
434:
435:            /**
436:             * Return the resource link with the specified name, if any;
437:             * otherwise return <code>null</code>.
438:             *
439:             * @param name Name of the desired resource link
440:             */
441:            public ContextResourceLink findResourceLink(String name) {
442:
443:                synchronized (resourceLinks) {
444:                    return ((ContextResourceLink) resourceLinks.get(name));
445:                }
446:
447:            }
448:
449:            /**
450:             * Return the defined resource links for this application.  If
451:             * none have been defined, a zero-length array is returned.
452:             */
453:            public ContextResourceLink[] findResourceLinks() {
454:
455:                synchronized (resourceLinks) {
456:                    ContextResourceLink results[] = new ContextResourceLink[resourceLinks
457:                            .size()];
458:                    return ((ContextResourceLink[]) resourceLinks.values()
459:                            .toArray(results));
460:                }
461:
462:            }
463:
464:            /**
465:             * Return the defined resource references for this application.  If
466:             * none have been defined, a zero-length array is returned.
467:             */
468:            public ContextResource[] findResources() {
469:
470:                synchronized (resources) {
471:                    ContextResource results[] = new ContextResource[resources
472:                            .size()];
473:                    return ((ContextResource[]) resources.values().toArray(
474:                            results));
475:                }
476:
477:            }
478:
479:            /**
480:             * Return the resource environment reference type for the specified
481:             * name, if any; otherwise return <code>null</code>.
482:             *
483:             * @param name Name of the desired resource environment reference
484:             */
485:            public String findResourceEnvRef(String name) {
486:
487:                synchronized (resourceEnvRefs) {
488:                    return ((String) resourceEnvRefs.get(name));
489:                }
490:
491:            }
492:
493:            /**
494:             * Return the set of resource environment reference names for this
495:             * web application.  If none have been specified, a zero-length
496:             * array is returned.
497:             */
498:            public String[] findResourceEnvRefs() {
499:
500:                synchronized (resourceEnvRefs) {
501:                    String results[] = new String[resourceEnvRefs.size()];
502:                    return ((String[]) resourceEnvRefs.keySet()
503:                            .toArray(results));
504:                }
505:
506:            }
507:
508:            /**
509:             * Return the resource parameters with the specified name, if any;
510:             * otherwise return <code>null</code>.
511:             */
512:            public ResourceParams findResourceParams(String name) {
513:
514:                synchronized (resourceParams) {
515:                    return ((ResourceParams) resourceParams.get(name));
516:                }
517:
518:            }
519:
520:            /**
521:             * Return the resource parameters with the specified name, if any;
522:             * otherwise return <code>null</code>.
523:             *
524:             * @param name Name of the desired resource parameters
525:             */
526:            public ResourceParams[] findResourceParams() {
527:
528:                synchronized (resourceParams) {
529:                    ResourceParams results[] = new ResourceParams[resourceParams
530:                            .size()];
531:                    return ((ResourceParams[]) resourceParams.values().toArray(
532:                            results));
533:                }
534:
535:            }
536:
537:            /**
538:             * Return true if the name specified already exists.
539:             */
540:            public boolean exists(String name) {
541:
542:                return (entries.containsKey(name));
543:
544:            }
545:
546:            /**
547:             * Remove any EJB resource reference with the specified name.
548:             *
549:             * @param name Name of the EJB resource reference to remove
550:             */
551:            public void removeEjb(String name) {
552:
553:                entries.remove(name);
554:
555:                ContextEjb ejb = null;
556:                synchronized (ejbs) {
557:                    ejb = (ContextEjb) ejbs.remove(name);
558:                }
559:                if (ejb != null) {
560:                    support.firePropertyChange("ejb", ejb, null);
561:                    ejb.setNamingResources(null);
562:                }
563:
564:            }
565:
566:            /**
567:             * Remove any environment entry with the specified name.
568:             *
569:             * @param name Name of the environment entry to remove
570:             */
571:            public void removeEnvironment(String name) {
572:
573:                entries.remove(name);
574:
575:                ContextEnvironment environment = null;
576:                synchronized (envs) {
577:                    environment = (ContextEnvironment) envs.remove(name);
578:                }
579:                if (environment != null) {
580:                    support
581:                            .firePropertyChange("environment", environment,
582:                                    null);
583:                    environment.setNamingResources(null);
584:                }
585:
586:            }
587:
588:            /**
589:             * Remove any local EJB resource reference with the specified name.
590:             *
591:             * @param name Name of the EJB resource reference to remove
592:             */
593:            public void removeLocalEjb(String name) {
594:
595:                entries.remove(name);
596:
597:                ContextLocalEjb localEjb = null;
598:                synchronized (localEjbs) {
599:                    localEjb = (ContextLocalEjb) ejbs.remove(name);
600:                }
601:                if (localEjb != null) {
602:                    support.firePropertyChange("localEjb", localEjb, null);
603:                    localEjb.setNamingResources(null);
604:                }
605:
606:            }
607:
608:            /**
609:             * Remove any message destination reference with the specified name.
610:             *
611:             * @param name Name of the message destination resource reference to remove
612:             */
613:            public void removeMessageDestinationRef(String name) {
614:
615:                entries.remove(name);
616:
617:                MessageDestinationRef mdr = null;
618:                synchronized (mdrs) {
619:                    mdr = (MessageDestinationRef) mdrs.remove(name);
620:                }
621:                if (mdr != null) {
622:                    support.firePropertyChange("messageDestinationRef", mdr,
623:                            null);
624:                    mdr.setNamingResources(null);
625:                }
626:
627:            }
628:
629:            /**
630:             * Remove a property change listener from this component.
631:             *
632:             * @param listener The listener to remove
633:             */
634:            public void removePropertyChangeListener(
635:                    PropertyChangeListener listener) {
636:
637:                support.removePropertyChangeListener(listener);
638:
639:            }
640:
641:            /**
642:             * Remove any resource reference with the specified name.
643:             *
644:             * @param name Name of the resource reference to remove
645:             */
646:            public void removeResource(String name) {
647:
648:                entries.remove(name);
649:
650:                ContextResource resource = null;
651:                synchronized (resources) {
652:                    resource = (ContextResource) resources.remove(name);
653:                }
654:                if (resource != null) {
655:                    support.firePropertyChange("resource", resource, null);
656:                    resource.setNamingResources(null);
657:                }
658:
659:            }
660:
661:            /**
662:             * Remove any resource environment reference with the specified name.
663:             *
664:             * @param name Name of the resource environment reference to remove
665:             */
666:            public void removeResourceEnvRef(String name) {
667:
668:                entries.remove(name);
669:
670:                String type = null;
671:                synchronized (resourceEnvRefs) {
672:                    type = (String) resourceEnvRefs.remove(name);
673:                }
674:                if (type != null) {
675:                    support.firePropertyChange("resourceEnvRef", name + ":"
676:                            + type, null);
677:                }
678:
679:            }
680:
681:            /**
682:             * Remove any resource link with the specified name.
683:             *
684:             * @param name Name of the resource link to remove
685:             */
686:            public void removeResourceLink(String name) {
687:
688:                entries.remove(name);
689:
690:                ContextResourceLink resourceLink = null;
691:                synchronized (resourceLinks) {
692:                    resourceLink = (ContextResourceLink) resourceLinks
693:                            .remove(name);
694:                }
695:                if (resourceLink != null) {
696:                    support.firePropertyChange("resourceLink", resourceLink,
697:                            null);
698:                    resourceLink.setNamingResources(null);
699:                }
700:
701:            }
702:
703:            /**
704:             * Remove any resource parameters with the specified name.
705:             *
706:             * @param name Name of the resource parameters to remove
707:             */
708:            public void removeResourceParams(String name) {
709:
710:                ResourceParams resourceParameters = null;
711:                synchronized (resourceParams) {
712:                    resourceParameters = (ResourceParams) resourceParams
713:                            .remove(name);
714:                }
715:                if (resourceParameters != null) {
716:                    support.firePropertyChange("resourceParams",
717:                            resourceParameters, null);
718:                    resourceParameters.setNamingResources(null);
719:                }
720:
721:            }
722:
723:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.