KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > joseki > server > DispatcherRegistry


1 /*
2  * (c) Copyright 2003, 2004 Hewlett-Packard Development Company, LP
3  * [See end of file]
4  */

5
6 package org.joseki.server;
7
8 import java.util.* ;
9
10 /** The dispatcher registry exists so that connectors can dynamically find the appropiate
11  * dispatcher. For example, servlets can find the dispatcher during initialization, before
12  * they are first called; when embedded, adding a servlet also creates and starts it
13  * making it inconvenient to bind the servlet to a dispatcher (e.g. the servlet may regsiter
14  * operation hamdlers descirbed in it configuration file).
15  *
16  * @author Andy Seaborne
17  * @version $Id: DispatcherRegistry.java,v 1.3 2004/04/30 14:13:13 andy_seaborne Exp $
18  */

19 public class DispatcherRegistry
20 {
21     // Singleton
22
private DispatcherRegistry() {}
23     
24     static DispatcherRegistry instance = new DispatcherRegistry() ;
25     static public DispatcherRegistry getInstance() { return instance ; }
26     
27     Map registry = new HashMap() ;
28     
29     public void add(String JavaDoc name, Dispatcher dispatcher)
30     {
31         registry.put(name, dispatcher) ;
32     }
33
34     public void remove(String JavaDoc name)
35     {
36         registry.remove(name) ;
37     }
38
39     public Dispatcher find(String JavaDoc name)
40     {
41         return (Dispatcher)registry.get(name) ;
42     }
43
44     public boolean contains(String JavaDoc name)
45     {
46         return registry.containsKey(name) ;
47     }
48
49     public Iterator registeredNames()
50     {
51         return registry.keySet().iterator() ;
52     }
53
54     public Iterator registeredDispatchers()
55     {
56         return registry.values().iterator() ;
57     }
58 }
59
60 /*
61  * (c) Copyright 2003, 2004 Hewlett-Packard Development Company, LP
62  * All rights reserved.
63  *
64  * Redistribution and use in source and binary forms, with or without
65  * modification, are permitted provided that the following conditions
66  * are met:
67  * 1. Redistributions of source code must retain the above copyright
68  * notice, this list of conditions and the following disclaimer.
69  * 2. Redistributions in binary form must reproduce the above copyright
70  * notice, this list of conditions and the following disclaimer in the
71  * documentation and/or other materials provided with the distribution.
72  * 3. The name of the author may not be used to endorse or promote products
73  * derived from this software without specific prior written permission.
74  *
75  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
76  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
77  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
78  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
79  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
80  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
81  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
82  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
83  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
84  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
85  */

86  
87
Popular Tags