Source Code Cross Referenced for NamingResources.java in  » Web-Server » Rimfaxe-Web-Server » 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 » Web Server » Rimfaxe Web Server » org.apache.catalina.deploy 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/deploy/NamingResources.java,v 1.10 2002/06/19 21:17:19 amyroh Exp $
003:         * $Revision: 1.10 $
004:         * $Date: 2002/06/19 21:17:19 $
005:         *
006:         * ====================================================================
007:         *
008:         * The Apache Software License, Version 1.1
009:         *
010:         * Copyright (c) 1999 The Apache Software Foundation.  All rights
011:         * reserved.
012:         *
013:         * Redistribution and use in source and binary forms, with or without
014:         * modification, are permitted provided that the following conditions
015:         * are met:
016:         *
017:         * 1. Redistributions of source code must retain the above copyright
018:         *    notice, this list of conditions and the following disclaimer.
019:         *
020:         * 2. Redistributions in binary form must reproduce the above copyright
021:         *    notice, this list of conditions and the following disclaimer in
022:         *    the documentation and/or other materials provided with the
023:         *    distribution.
024:         *
025:         * 3. The end-user documentation included with the redistribution, if
026:         *    any, must include the following acknowlegement:
027:         *       "This product includes software developed by the
028:         *        Apache Software Foundation (http://www.apache.org/)."
029:         *    Alternately, this acknowlegement may appear in the software itself,
030:         *    if and wherever such third-party acknowlegements normally appear.
031:         *
032:         * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
033:         *    Foundation" must not be used to endorse or promote products derived
034:         *    from this software without prior written permission. For written
035:         *    permission, please contact apache@apache.org.
036:         *
037:         * 5. Products derived from this software may not be called "Apache"
038:         *    nor may "Apache" appear in their names without prior written
039:         *    permission of the Apache Group.
040:         *
041:         * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
042:         * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
043:         * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
044:         * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
045:         * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
046:         * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
047:         * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
048:         * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
049:         * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
050:         * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
051:         * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
052:         * SUCH DAMAGE.
053:         * ====================================================================
054:         *
055:         * This software consists of voluntary contributions made by many
056:         * individuals on behalf of the Apache Software Foundation.  For more
057:         * information on the Apache Software Foundation, please see
058:         * <http://www.apache.org/>.
059:         *
060:         * [Additional notices, if required by prior licensing conditions]
061:         *
062:         */
063:
064:        package org.apache.catalina.deploy;
065:
066:        import java.beans.PropertyChangeListener;
067:        import java.beans.PropertyChangeSupport;
068:        import java.util.HashMap;
069:        import java.util.Hashtable;
070:
071:        /**
072:         * Holds and manages the naming resources defined in the J2EE Enterprise 
073:         * Naming Context and their associated JNDI context.
074:         *
075:         * @author Remy Maucherat
076:         * @version $Revision: 1.10 $ $Date: 2002/06/19 21:17:19 $
077:         */
078:
079:        public final class NamingResources {
080:
081:            // ----------------------------------------------------------- Constructors
082:
083:            /**
084:             * Create a new NamingResources instance.
085:             */
086:            public NamingResources() {
087:            }
088:
089:            // ----------------------------------------------------- Instance Variables
090:
091:            /**
092:             * Associated container object.
093:             */
094:            private Object container = null;
095:
096:            /**
097:             * List of naming entries, keyed by name. The value is the entry type, as
098:             * declared by the user.
099:             */
100:            private Hashtable entries = new Hashtable();
101:
102:            /**
103:             * The EJB resource references for this web application, keyed by name.
104:             */
105:            private HashMap ejbs = new HashMap();
106:
107:            /**
108:             * The environment entries for this web application, keyed by name.
109:             */
110:            private HashMap envs = new HashMap();
111:
112:            /**
113:             * The local  EJB resource references for this web application, keyed by
114:             * name.
115:             */
116:            private HashMap localEjbs = new HashMap();
117:
118:            /**
119:             * The resource environment references for this web application,
120:             * keyed by name.
121:             */
122:            private HashMap resourceEnvRefs = new HashMap();
123:
124:            /**
125:             * The resource references for this web application, keyed by name.
126:             */
127:            private HashMap resources = new HashMap();
128:
129:            /**
130:             * The resource links for this web application, keyed by name.
131:             */
132:            private HashMap resourceLinks = new HashMap();
133:
134:            /**
135:             * The resource parameters for this web application, keyed by name.
136:             */
137:            private HashMap resourceParams = new HashMap();
138:
139:            /**
140:             * The property change support for this component.
141:             */
142:            protected PropertyChangeSupport support = new PropertyChangeSupport(
143:                    this );
144:
145:            // ------------------------------------------------------------- Properties
146:
147:            /**
148:             * Get the container with which the naming resources are associated.
149:             */
150:            public Object getContainer() {
151:                return container;
152:            }
153:
154:            /**
155:             * Set the container with which the naming resources are associated.
156:             */
157:            public void setContainer(Object container) {
158:                this .container = container;
159:            }
160:
161:            /**
162:             * Add an EJB resource reference for this web application.
163:             *
164:             * @param ejb New EJB resource reference
165:             */
166:            public void addEjb(ContextEjb ejb) {
167:
168:                if (entries.containsKey(ejb.getName())) {
169:                    return;
170:                } else {
171:                    entries.put(ejb.getName(), ejb.getType());
172:                }
173:
174:                synchronized (ejbs) {
175:                    ejb.setNamingResources(this );
176:                    ejbs.put(ejb.getName(), ejb);
177:                }
178:                support.firePropertyChange("ejb", null, ejb);
179:
180:            }
181:
182:            /**
183:             * Add an environment entry for this web application.
184:             *
185:             * @param environment New environment entry
186:             */
187:            public void addEnvironment(ContextEnvironment environment) {
188:
189:                if (entries.containsKey(environment.getName())) {
190:                    return;
191:                } else {
192:                    entries.put(environment.getName(), environment.getType());
193:                }
194:
195:                synchronized (envs) {
196:                    environment.setNamingResources(this );
197:                    envs.put(environment.getName(), environment);
198:                }
199:                support.firePropertyChange("environment", null, environment);
200:
201:            }
202:
203:            /**
204:             * Add resource parameters for this web application.
205:             *
206:             * @param resourceParameters New resource parameters
207:             */
208:            public void addResourceParams(ResourceParams resourceParameters) {
209:
210:                synchronized (resourceParams) {
211:                    if (resourceParams
212:                            .containsKey(resourceParameters.getName())) {
213:                        return;
214:                    }
215:                    resourceParameters.setNamingResources(this );
216:                    resourceParams.put(resourceParameters.getName(),
217:                            resourceParameters);
218:                }
219:                support.firePropertyChange("resourceParams", null,
220:                        resourceParameters);
221:
222:            }
223:
224:            /**
225:             * Add a local EJB resource reference for this web application.
226:             *
227:             * @param ejb New EJB resource reference
228:             */
229:            public void addLocalEjb(ContextLocalEjb ejb) {
230:
231:                if (entries.containsKey(ejb.getName())) {
232:                    return;
233:                } else {
234:                    entries.put(ejb.getName(), ejb.getType());
235:                }
236:
237:                synchronized (localEjbs) {
238:                    ejb.setNamingResources(this );
239:                    localEjbs.put(ejb.getName(), ejb);
240:                }
241:                support.firePropertyChange("localEjb", null, ejb);
242:
243:            }
244:
245:            /**
246:             * Add a property change listener to this component.
247:             *
248:             * @param listener The listener to add
249:             */
250:            public void addPropertyChangeListener(
251:                    PropertyChangeListener listener) {
252:
253:                support.addPropertyChangeListener(listener);
254:
255:            }
256:
257:            /**
258:             * Add a resource reference for this web application.
259:             *
260:             * @param resource New resource reference
261:             */
262:            public void addResource(ContextResource resource) {
263:
264:                if (entries.containsKey(resource.getName())) {
265:                    return;
266:                } else {
267:                    entries.put(resource.getName(), resource.getType());
268:                }
269:
270:                synchronized (resources) {
271:                    resource.setNamingResources(this );
272:                    resources.put(resource.getName(), resource);
273:                }
274:                support.firePropertyChange("resource", null, resource);
275:
276:            }
277:
278:            /**
279:             * Add a resource environment reference for this web application.
280:             *
281:             * @param name The resource environment reference name
282:             * @param type The resource environment reference type
283:             */
284:            public void addResourceEnvRef(String name, String type) {
285:
286:                if (entries.containsKey(name)) {
287:                    return;
288:                } else {
289:                    entries.put(name, type);
290:                }
291:
292:                synchronized (resourceEnvRefs) {
293:                    resourceEnvRefs.put(name, type);
294:                }
295:                support.firePropertyChange("resourceEnvRef", null, name + ":"
296:                        + type);
297:
298:            }
299:
300:            /**
301:             * Add a resource link for this web application.
302:             *
303:             * @param resource New resource link
304:             */
305:            public void addResourceLink(ContextResourceLink resourceLink) {
306:
307:                if (entries.containsKey(resourceLink.getName())) {
308:                    return;
309:                } else {
310:                    Object value = resourceLink.getType();
311:                    if (value == null) {
312:                        value = "";
313:                    }
314:                    entries.put(resourceLink.getName(), value);
315:                }
316:
317:                synchronized (resourceLinks) {
318:                    resourceLink.setNamingResources(this );
319:                    resourceLinks.put(resourceLink.getName(), resourceLink);
320:                }
321:                support.firePropertyChange("resourceLink", null, resourceLink);
322:
323:            }
324:
325:            /**
326:             * Return the EJB resource reference with the specified name, if any;
327:             * otherwise, return <code>null</code>.
328:             *
329:             * @param name Name of the desired EJB resource reference
330:             */
331:            public ContextEjb findEjb(String name) {
332:
333:                synchronized (ejbs) {
334:                    return ((ContextEjb) ejbs.get(name));
335:                }
336:
337:            }
338:
339:            /**
340:             * Return the defined EJB resource references for this application.
341:             * If there are none, a zero-length array is returned.
342:             */
343:            public ContextEjb[] findEjbs() {
344:
345:                synchronized (ejbs) {
346:                    ContextEjb results[] = new ContextEjb[ejbs.size()];
347:                    return ((ContextEjb[]) ejbs.values().toArray(results));
348:                }
349:
350:            }
351:
352:            /**
353:             * Return the environment entry with the specified name, if any;
354:             * otherwise, return <code>null</code>.
355:             *
356:             * @param name Name of the desired environment entry
357:             */
358:            public ContextEnvironment findEnvironment(String name) {
359:
360:                synchronized (envs) {
361:                    return ((ContextEnvironment) envs.get(name));
362:                }
363:
364:            }
365:
366:            /**
367:             * Return the set of defined environment entries for this web
368:             * application.  If none have been defined, a zero-length array
369:             * is returned.
370:             */
371:            public ContextEnvironment[] findEnvironments() {
372:
373:                synchronized (envs) {
374:                    ContextEnvironment results[] = new ContextEnvironment[envs
375:                            .size()];
376:                    return ((ContextEnvironment[]) envs.values().toArray(
377:                            results));
378:                }
379:
380:            }
381:
382:            /**
383:             * Return the local EJB resource reference with the specified name, if any;
384:             * otherwise, return <code>null</code>.
385:             *
386:             * @param name Name of the desired EJB resource reference
387:             */
388:            public ContextLocalEjb findLocalEjb(String name) {
389:
390:                synchronized (localEjbs) {
391:                    return ((ContextLocalEjb) localEjbs.get(name));
392:                }
393:
394:            }
395:
396:            /**
397:             * Return the defined local EJB resource references for this application.
398:             * If there are none, a zero-length array is returned.
399:             */
400:            public ContextLocalEjb[] findLocalEjbs() {
401:
402:                synchronized (localEjbs) {
403:                    ContextLocalEjb results[] = new ContextLocalEjb[localEjbs
404:                            .size()];
405:                    return ((ContextLocalEjb[]) localEjbs.values().toArray(
406:                            results));
407:                }
408:
409:            }
410:
411:            /**
412:             * Return the resource reference with the specified name, if any;
413:             * otherwise return <code>null</code>.
414:             *
415:             * @param name Name of the desired resource reference
416:             */
417:            public ContextResource findResource(String name) {
418:
419:                synchronized (resources) {
420:                    return ((ContextResource) resources.get(name));
421:                }
422:
423:            }
424:
425:            /**
426:             * Return the resource link with the specified name, if any;
427:             * otherwise return <code>null</code>.
428:             *
429:             * @param name Name of the desired resource link
430:             */
431:            public ContextResourceLink findResourceLink(String name) {
432:
433:                synchronized (resourceLinks) {
434:                    return ((ContextResourceLink) resourceLinks.get(name));
435:                }
436:
437:            }
438:
439:            /**
440:             * Return the defined resource links for this application.  If
441:             * none have been defined, a zero-length array is returned.
442:             */
443:            public ContextResourceLink[] findResourceLinks() {
444:
445:                synchronized (resourceLinks) {
446:                    ContextResourceLink results[] = new ContextResourceLink[resourceLinks
447:                            .size()];
448:                    return ((ContextResourceLink[]) resourceLinks.values()
449:                            .toArray(results));
450:                }
451:
452:            }
453:
454:            /**
455:             * Return the defined resource references for this application.  If
456:             * none have been defined, a zero-length array is returned.
457:             */
458:            public ContextResource[] findResources() {
459:
460:                synchronized (resources) {
461:                    ContextResource results[] = new ContextResource[resources
462:                            .size()];
463:                    return ((ContextResource[]) resources.values().toArray(
464:                            results));
465:                }
466:
467:            }
468:
469:            /**
470:             * Return the resource environment reference type for the specified
471:             * name, if any; otherwise return <code>null</code>.
472:             *
473:             * @param name Name of the desired resource environment reference
474:             */
475:            public String findResourceEnvRef(String name) {
476:
477:                synchronized (resourceEnvRefs) {
478:                    return ((String) resourceEnvRefs.get(name));
479:                }
480:
481:            }
482:
483:            /**
484:             * Return the set of resource environment reference names for this
485:             * web application.  If none have been specified, a zero-length
486:             * array is returned.
487:             */
488:            public String[] findResourceEnvRefs() {
489:
490:                synchronized (resourceEnvRefs) {
491:                    String results[] = new String[resourceEnvRefs.size()];
492:                    return ((String[]) resourceEnvRefs.keySet()
493:                            .toArray(results));
494:                }
495:
496:            }
497:
498:            /**
499:             * Return the resource parameters with the specified name, if any;
500:             * otherwise return <code>null</code>.
501:             *
502:             * @param name Name of the desired resource parameters
503:             */
504:            public ResourceParams findResourceParams(String name) {
505:
506:                synchronized (resourceParams) {
507:                    return ((ResourceParams) resourceParams.get(name));
508:                }
509:
510:            }
511:
512:            /**
513:             * Return the resource parameters with the specified name, if any;
514:             * otherwise return <code>null</code>.
515:             *
516:             * @param name Name of the desired resource parameters
517:             */
518:            public ResourceParams[] findResourceParams() {
519:
520:                synchronized (resourceParams) {
521:                    ResourceParams results[] = new ResourceParams[resourceParams
522:                            .size()];
523:                    return ((ResourceParams[]) resourceParams.values().toArray(
524:                            results));
525:                }
526:
527:            }
528:
529:            /**
530:             * Return true if the name specified already exists.
531:             */
532:            public boolean exists(String name) {
533:
534:                return (entries.containsKey(name));
535:
536:            }
537:
538:            /**
539:             * Remove any EJB resource reference with the specified name.
540:             *
541:             * @param name Name of the EJB resource reference to remove
542:             */
543:            public void removeEjb(String name) {
544:
545:                entries.remove(name);
546:
547:                ContextEjb ejb = null;
548:                synchronized (ejbs) {
549:                    ejb = (ContextEjb) ejbs.remove(name);
550:                }
551:                if (ejb != null) {
552:                    support.firePropertyChange("ejb", ejb, null);
553:                    ejb.setNamingResources(null);
554:                }
555:
556:            }
557:
558:            /**
559:             * Remove any environment entry with the specified name.
560:             *
561:             * @param name Name of the environment entry to remove
562:             */
563:            public void removeEnvironment(String name) {
564:
565:                entries.remove(name);
566:
567:                ContextEnvironment environment = null;
568:                synchronized (envs) {
569:                    environment = (ContextEnvironment) envs.remove(name);
570:                }
571:                if (environment != null) {
572:                    support
573:                            .firePropertyChange("environment", environment,
574:                                    null);
575:                    environment.setNamingResources(null);
576:                }
577:
578:            }
579:
580:            /**
581:             * Remove any local EJB resource reference with the specified name.
582:             *
583:             * @param name Name of the EJB resource reference to remove
584:             */
585:            public void removeLocalEjb(String name) {
586:
587:                entries.remove(name);
588:
589:                ContextLocalEjb localEjb = null;
590:                synchronized (localEjbs) {
591:                    localEjb = (ContextLocalEjb) ejbs.remove(name);
592:                }
593:                if (localEjb != null) {
594:                    support.firePropertyChange("localEjb", localEjb, null);
595:                    localEjb.setNamingResources(null);
596:                }
597:
598:            }
599:
600:            /**
601:             * Remove a property change listener from this component.
602:             *
603:             * @param listener The listener to remove
604:             */
605:            public void removePropertyChangeListener(
606:                    PropertyChangeListener listener) {
607:
608:                support.removePropertyChangeListener(listener);
609:
610:            }
611:
612:            /**
613:             * Remove any resource reference with the specified name.
614:             *
615:             * @param name Name of the resource reference to remove
616:             */
617:            public void removeResource(String name) {
618:
619:                entries.remove(name);
620:
621:                ContextResource resource = null;
622:                synchronized (resources) {
623:                    resource = (ContextResource) resources.remove(name);
624:                }
625:                if (resource != null) {
626:                    support.firePropertyChange("resource", resource, null);
627:                    resource.setNamingResources(null);
628:                }
629:
630:            }
631:
632:            /**
633:             * Remove any resource environment reference with the specified name.
634:             *
635:             * @param name Name of the resource environment reference to remove
636:             */
637:            public void removeResourceEnvRef(String name) {
638:
639:                entries.remove(name);
640:
641:                String type = null;
642:                synchronized (resourceEnvRefs) {
643:                    type = (String) resourceEnvRefs.remove(name);
644:                }
645:                if (type != null) {
646:                    support.firePropertyChange("resourceEnvRef", name + ":"
647:                            + type, null);
648:                }
649:
650:            }
651:
652:            /**
653:             * Remove any resource link with the specified name.
654:             *
655:             * @param name Name of the resource link to remove
656:             */
657:            public void removeResourceLink(String name) {
658:
659:                entries.remove(name);
660:
661:                ContextResourceLink resourceLink = null;
662:                synchronized (resourceLinks) {
663:                    resourceLink = (ContextResourceLink) resourceLinks
664:                            .remove(name);
665:                }
666:                if (resourceLink != null) {
667:                    support.firePropertyChange("resourceLink", resourceLink,
668:                            null);
669:                    resourceLink.setNamingResources(null);
670:                }
671:
672:            }
673:
674:            /**
675:             * Remove any resource parameters with the specified name.
676:             *
677:             * @param name Name of the resource parameters to remove
678:             */
679:            public void removeResourceParams(String name) {
680:
681:                ResourceParams resourceParameters = null;
682:                synchronized (resourceParams) {
683:                    resourceParameters = (ResourceParams) resourceParams
684:                            .remove(name);
685:                }
686:                if (resourceParameters != null) {
687:                    support.firePropertyChange("resourceParams",
688:                            resourceParameters, null);
689:                    resourceParameters.setNamingResources(null);
690:                }
691:
692:            }
693:
694:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.