org.sapia.regis
Class RegistryContext

java.lang.Object
  extended by org.sapia.regis.RegistryContext

public class RegistryContext
extends Object

An instance of this class internally uses a given RegistryFactory class to instantiate a Registry; it expects the org.sapia.regis.factory property to correspond to the name of the RegistryFactory implementation to use.

Additionally, an instance of this class allows setting a property indicating one or multiple Java property resources to load within this instance's given properties (which are passed at instantiation time). That property is: org.sapia.regis.boostrap, and allows setting a comma-delimited list of resources are to be exclusively loaded. Each resource is interpreted as being either (whichever matches first):

The first resource that can be loaded will stop the loading process (i.e.: the Java properties in that resource will be loaded, but attempting to load the other resources will abort).

Note that specified resource names can contain variables of the form ${var_name}. These variables are resolved using the properties passed to the instance of this class at construction time, or using system properties.

The properties in the resource that was found will be added to the ones passed to the instance of this class at contruction time, prior to the actual registry factory being instantiated.

This feature was introduced to allow connecting to different registries, depending on the environment. For example, imagine that a registry.properties file is kept in the user home directory on developer workstations. That file contains the properties necessary to connect to a LocalRegistry (in order to avoid dealing with remote connections when developing). But let's say that when in other environments (dev, QA, prod...), the registry.properties file to use is stored by convention in the classpath, under the path regis/conf/registry.properties, and holds properties used to connect to a remote registry, shared by distributed applications (see RemoteRegistry).

In order to load the appropriate registry.properties, we could set a property (in the Properties passed to the constructor of this class) :

 org.sapia.regis.bootstrap=${user.home}/regis/registry.properties, regis/conf/registry.properties
 

Then, upon its connect() method being called, the instance of this class resolves the boostrap properties (according to the above-described algorithm), which add themselves to the properties that were passed in at construction time. Thus, the boostrap properties are additive, and are used just as the others when instantiation registry factory.

Author:
yduchesne
See Also:
RegistryFactory

Field Summary
static String BOOTSTRAP
          This constant corresponds to the property that indicates which Java propertis (file, URL, classpath resource) to use to initialiase an instance of this class.
static String FACTORY_CLASS
          This constant corresponds to the property that indicates which RegistryFactory to use to instantiate a Registry.
 
Constructor Summary
RegistryContext(Properties props)
           
 
Method Summary
 Registry connect()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FACTORY_CLASS

public static final String FACTORY_CLASS
This constant corresponds to the property that indicates which RegistryFactory to use to instantiate a Registry.

See Also:
Constant Field Values

BOOTSTRAP

public static final String BOOTSTRAP
This constant corresponds to the property that indicates which Java propertis (file, URL, classpath resource) to use to initialiase an instance of this class.

See Also:
Constant Field Values
Constructor Detail

RegistryContext

public RegistryContext(Properties props)
Parameters:
props - the Properties to used to connect to the desired Registry.
Method Detail

connect

public Registry connect()
                 throws Exception
Returns:
a Registry.
Throws:
Exception - if a problem occurs while attempting to connect.


Copyright © 2006 Sapia Open Community, Inc. All Rights Reserved.