Mercurial > repos > ganjoo > webservice_toolsuite
view 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 |
line wrap: on
line source
/* * (c) Copyright IBM Corp 2001, 2005 */ package edu.uga.cs.lsdis.meteors.wadls.util; import java.util.*; /** * The <em>ObjectRegistry</em> is used to do name-to-object reference lookups. * If an <em>ObjectRegistry</em> is passed as a constructor argument, then this * <em>ObjectRegistry</em> will be a cascading registry: when a lookup is * invoked, it will first look in its own table for a name, and if it's not * there, it will cascade to the parent <em>ObjectRegistry</em>. * All registration is always local. [??] * * @author Sanjiva Weerawarana * @author Matthew J. Duftler */ public class ObjectRegistry { Hashtable reg = new Hashtable (); ObjectRegistry parent = null; public ObjectRegistry () { } public ObjectRegistry (ObjectRegistry parent) { this.parent = parent; } // register an object public void register (String name, Object obj) { reg.put (name, obj); } // unregister an object (silent if unknown name) public void unregister (String name) { reg.remove (name); } // lookup an object: cascade up if needed public Object lookup (String name) throws IllegalArgumentException { Object obj = reg.get (name); if (obj == null && parent != null) { obj = parent.lookup (name); } if (obj == null) { throw new IllegalArgumentException ("object '" + name + "' not in registry"); } return obj; } }