comparison WebServiceToolWorkflow/lib/SAWADLParser/src/edu/uga/cs/lsdis/meteors/wadls/util/ObjectRegistry.java @ 0:d5cd409b8a18 default tip

Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
author ganjoo
date Tue, 07 Jun 2011 18:00:50 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:d5cd409b8a18
1 /*
2 * (c) Copyright IBM Corp 2001, 2005
3 */
4
5 package edu.uga.cs.lsdis.meteors.wadls.util;
6
7 import java.util.*;
8
9 /**
10 * The <em>ObjectRegistry</em> is used to do name-to-object reference lookups.
11 * If an <em>ObjectRegistry</em> is passed as a constructor argument, then this
12 * <em>ObjectRegistry</em> will be a cascading registry: when a lookup is
13 * invoked, it will first look in its own table for a name, and if it's not
14 * there, it will cascade to the parent <em>ObjectRegistry</em>.
15 * All registration is always local. [??]
16 *
17 * @author Sanjiva Weerawarana
18 * @author Matthew J. Duftler
19 */
20 public class ObjectRegistry {
21 Hashtable reg = new Hashtable ();
22 ObjectRegistry parent = null;
23
24 public ObjectRegistry () {
25 }
26
27 public ObjectRegistry (ObjectRegistry parent) {
28 this.parent = parent;
29 }
30
31 // register an object
32 public void register (String name, Object obj) {
33 reg.put (name, obj);
34 }
35
36 // unregister an object (silent if unknown name)
37 public void unregister (String name) {
38 reg.remove (name);
39 }
40
41 // lookup an object: cascade up if needed
42 public Object lookup (String name) throws IllegalArgumentException {
43 Object obj = reg.get (name);
44
45 if (obj == null && parent != null) {
46 obj = parent.lookup (name);
47 }
48
49 if (obj == null) {
50 throw new IllegalArgumentException ("object '" + name + "' not in registry");
51 }
52
53 return obj;
54 }
55 }