gldapo
Class Gldapo

java.lang.Object
  extended by gldapo.Gldapo

public class Gldapo
extends Object

The singleton instance of this class provides access to the various registries and settings at runtime. It is also the entry point for initializing Gldapo.


Constructor Summary
Gldapo()
          Create a Gldapo instance with only defaults.
Gldapo(Map config)
          Create a Gldapo instance with a config
 
Method Summary
 void consumeConfig(Map config)
          Uses the extract* methods to interpret the config, then iteratively add's the items to the respective registry.
static List extractDirectoriesFromConfig(Map config)
          Creates a List of GldapoDirectory objects from the given config.
static Collection extractSchemasFromConfig(Map config)
          Fetches the schema classes indictated by the config.
static Collection extractTypeMappingsFromConfig(Map config)
          Fetches the type mapping classes indictated by the config.
static Object getCONFIG_KEY_DEFAULT_DIRECTORY()
           
static Object getCONFIG_KEY_DIRECTORIES()
           
static Object getCONFIG_KEY_SCHEMAS()
           
static Object getCONFIG_KEY_TYPEMAPPINGS()
           
static Object getDEFAULT_CONFIG_FILENAME()
           
 GldapoDirectoryRegistry getDirectories()
           
static Gldapo getInstance()
           
 MetaClass getMetaClass()
           
 Object getProperty(String name)
           
 GldapoSchemaRegistry getSchemas()
           
 GldapoTypeMappingRegistry getTypemappings()
           
static Object initialize()
          Calls initialize(String) with a null string.
static Object initialize(Map config)
          Calls resetWithConfig(Map) on the gldapo instance
static Object initialize(String environment)
          Tries to find the default config file and passes it's URL along with environment to initialize(URL,String)
static Object initialize(URL configUrl)
          Calls initialize(URL,String), passing configUrl and a null environment
static Object initialize(URL configUrl, String environment)
          Initializes using the config script configUrl and parses it for environment
 Object invokeMethod(String name, Object args)
           
 void resetWithConfig(Map config)
          Calls clear() on the directory, schema and type mapping registries before passing the config to consumeConfig(Map)
 void setDirectories(GldapoDirectoryRegistry value)
           
static void setInstance(Gldapo value)
           
 void setMetaClass(MetaClass metaClass)
           
 void setProperty(String name, Object value)
           
 void setSchemas(GldapoSchemaRegistry value)
           
 void setTypemappings(GldapoTypeMappingRegistry value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Gldapo

public Gldapo()
Create a Gldapo instance with only defaults.


Gldapo

public Gldapo(Map config)
Create a Gldapo instance with a config

See Also:
resetWithConfig(Map)
Method Detail

getDEFAULT_CONFIG_FILENAME

public static final Object getDEFAULT_CONFIG_FILENAME()

getCONFIG_KEY_TYPEMAPPINGS

public static final Object getCONFIG_KEY_TYPEMAPPINGS()

getCONFIG_KEY_DIRECTORIES

public static final Object getCONFIG_KEY_DIRECTORIES()

getCONFIG_KEY_DEFAULT_DIRECTORY

public static final Object getCONFIG_KEY_DEFAULT_DIRECTORY()

getCONFIG_KEY_SCHEMAS

public static final Object getCONFIG_KEY_SCHEMAS()

getInstance

public static Gldapo getInstance()

setInstance

public static void setInstance(Gldapo value)

getDirectories

public GldapoDirectoryRegistry getDirectories()

setDirectories

public void setDirectories(GldapoDirectoryRegistry value)

getSchemas

public GldapoSchemaRegistry getSchemas()

setSchemas

public void setSchemas(GldapoSchemaRegistry value)

getTypemappings

public GldapoTypeMappingRegistry getTypemappings()

setTypemappings

public void setTypemappings(GldapoTypeMappingRegistry value)

resetWithConfig

public void resetWithConfig(Map config)
Calls clear() on the directory, schema and type mapping registries before passing the config to consumeConfig(Map)


consumeConfig

public void consumeConfig(Map config)
Uses the extract* methods to interpret the config, then iteratively add's the items to the respective registry.

See Also:
extractDirectoriesFromConfig(Map), extractTypeMappingsFromConfig(Map), extractSchemasFromConfig(Map)

initialize

public static Object initialize()
Calls initialize(String) with a null string.


initialize

public static Object initialize(String environment)
                         throws GldapoInitializationException
Tries to find the default config file and passes it's URL along with environment to initialize(URL,String)

Parameters:
environment - the environment to parse the default config file with
Throws:
GldapoInitializationException - If no default config file can be found

initialize

public static Object initialize(URL configUrl)
Calls initialize(URL,String), passing configUrl and a null environment


initialize

public static Object initialize(URL configUrl,
                                String environment)
                         throws GldapoInitializationException
Initializes using the config script configUrl and parses it for environment

Creates a ConfigSlurper with the context of environment and uses it to parse configUrl into a ConfigObject. The config object is then passed to initialize(Map).

Parameters:
configUrl - The location of the config script (must not be null)
environment - The environment context to parse configUrl with (can be null)
Throws:
GldapoInitializationException - If configUrl is null

initialize

public static Object initialize(Map config)
                         throws GldapoInitializationException
Calls resetWithConfig(Map) on the gldapo instance

Throws:
GldapoInitializationException

extractSchemasFromConfig

public static Collection extractSchemasFromConfig(Map config)
                                           throws GldapoInvalidConfigException
Fetches the schema classes indictated by the config.

Looks in the config for a Collection under the key indicated by CONFIG_KEY_SCHEMAS

Returns:
The schema classes
Throws:
GldapoInvalidConfigException - if the relevant item in the config is not a Collection

extractTypeMappingsFromConfig

public static Collection extractTypeMappingsFromConfig(Map config)
                                                throws GldapoInvalidConfigException
Fetches the type mapping classes indictated by the config.

Looks in the config for a Collection under the key indicated by CONFIG_KEY_TYPEMAPPINGS

Returns:
The type mapping classes
Throws:
GldapoInvalidConfigException - if the relevant item in the config is not a Collection

extractDirectoriesFromConfig

public static List extractDirectoriesFromConfig(Map config)
                                         throws GldapoInvalidConfigException
Creates a List of GldapoDirectory objects from the given config.

Looks in the config for a Map under the key indicated by CONFIG_KEY_DIRECTORIES.

Each key/value pair in the directories config is turned into an instance of GldapoDirectory by using the GldapoDirectory.GldapoDirectory(String,Map) constructor where the key is the String and the value is the Map.

An example config map for this method might look like this ...

 [
 directories: [
 d1: [
 url: "ldap://example.com"
 ],
 d2: [
 url: "ldap://example.com"
 ]
 ]
 ]
 
See GldapoDirectory.GldapoDirectory(String,Map) for the format of the directory map.

Returns:
A list of GldapoDirectory objects
Throws:
GldapoInvalidConfigException - if the relevant item in the config is not a Map

getMetaClass

public MetaClass getMetaClass()

setMetaClass

public void setMetaClass(MetaClass metaClass)

invokeMethod

public Object invokeMethod(String name,
                           Object args)

getProperty

public Object getProperty(String name)

setProperty

public void setProperty(String name,
                        Object value)


Copyright © 2007-2010 Codehaus. All Rights Reserved.