raccoon.core.utils
Class CoreHelper

java.lang.Object
  extended by raccoon.api.PsfRaccoonServices
      extended by raccoon.core.utils.CoreHelper

public class CoreHelper
extends PsfRaccoonServices

A utility component to retrieve pre-configured services.

Since:
Raccoon v0.8
Version:
$Id: CoreHelper.java,v 1.1 2004/08/08 20:19:20 crouvrais Exp $
Author:
Cedric ROUVRAIS

Field Summary
static java.lang.String RACCOON_CONFIG_FILE
          The default properties file used to configure the Raccoon Core Framework.
 
Fields inherited from class raccoon.api.PsfRaccoonServices
FACTORY, NUCLEUS, RACCOON_NAME, RACCOON_SYS_PROPS, RACCOON_VERSION, RACCOON_VERSION_ID, RACCOON_VERSION_MAJOR, RACCOON_VERSION_MINOR, REPO_GENERATOR, SERVICE_BEAN_ANALYZER, SERVICE_BRIDGE_NAME, SERVICE_CONFIG, SERVICE_JAVA_PARSER, SERVICE_LOGGER, SERVICE_MANAGER, SERVICE_NUCLEUS_NAME, SERVICE_XML_PARSER, UNIT_TESTER, UTILS
 
Constructor Summary
protected CoreHelper()
          Utility classes should not have a public or default constructor.
 
Method Summary
static IConfig getConfig()
          Retrieves a configuration session based upon it's logical session name.
static IConfig getConfig(java.lang.String pConfigInstance)
          Retrieves a none default configuration session, useful when multiple configuration files are used within a projet.
static INucleus getDefaultNucleus()
          Loads and returns the primary/default implementation of INucleus
static IBeanAnalyzer getIntrospector()
          Loads the Bean Introspection service.
static ILogger getLog()
          Retrieves a logging session based upon it's logical session name.
static ILogger getLog(java.lang.String pLogCategory)
          Retrieves a logging session based upon it's logical session name.
static INucleus getNucleus(java.lang.String pNucleusName)
          Loads and returns the nucleus instance.
static IServiceManager getServiceManager(java.lang.String pXmlResourceFile)
          Retrieves a service manager instance based upon the specified resource manager.
static IBaseComponent lookup(java.lang.String pComponentName)
          Retrieves a component that has been loaded and initialised based upon it's logical name.
static IBaseComponent lookup(java.lang.String pComponentName, java.lang.String pComponentId, java.util.Hashtable pConfigParams)
          Loads a specific component with custom load time configuration.
static void reload()
          Unloads all loaded components and reinits the Service Manager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RACCOON_CONFIG_FILE

public static final java.lang.String RACCOON_CONFIG_FILE
The default properties file used to configure the Raccoon Core Framework. This value can be redefined via the system property: raccoon.config.file

See Also:
Constant Field Values
Constructor Detail

CoreHelper

protected CoreHelper()
Utility classes should not have a public or default constructor.

Method Detail

getLog

public static ILogger getLog(java.lang.String pLogCategory)
                      throws RaccoonException
Retrieves a logging session based upon it's logical session name. This method presupposes that a component log be defined in service manager configuration file.

The category name that is to be returned is automatically determined based upon the stack trace (refer to user documentation for more information).

Parameters:
pLogCategory - the category name of the log component (usually linked to the class name).
Returns:
the ILogger that correspond to the provided session.
Throws:
RaccoonException - if the Service Manager couldn't located the service component labeled 'log'.

getLog

public static ILogger getLog()
Retrieves a logging session based upon it's logical session name. This method presumes that a component log is defined in service manager configuration file.

The category name that is to be returned is automatically determined based upon the stack trace (refer to user documentation for more information).

Returns:
the ILogger that correspond to the provided session.

getConfig

public static IConfig getConfig()
                         throws RaccoonException
Retrieves a configuration session based upon it's logical session name. This method presumes that a component config is defined in the service manager configuration file.

The default file used is usually raccoon.properties

Returns:
a IConfig instance that corresponds to the config component.
Throws:
RaccoonException - if the Service Manager couldn't locate the component named 'config'.

getConfig

public static IConfig getConfig(java.lang.String pConfigInstance)
                         throws RaccoonException
Retrieves a none default configuration session, useful when multiple configuration files are used within a projet.

Parameters:
pConfigInstance - the name of the component, should be an instance of IConfig
Returns:
the config base instance.
Throws:
RaccoonException - if the service manager couldn't find the component or if the component isn't an instance of IConfig

lookup

public static IBaseComponent lookup(java.lang.String pComponentName)
                             throws RaccoonException
Retrieves a component that has been loaded and initialised based upon it's logical name.

Parameters:
pComponentName - the name of the component that was given in the configuration file.
Returns:
the IBaseComponent instance loaded and initialised if necessary.
Throws:
RaccoonException - if the component couldn't be loaded or found.

lookup

public static IBaseComponent lookup(java.lang.String pComponentName,
                                    java.lang.String pComponentId,
                                    java.util.Hashtable pConfigParams)
                             throws RaccoonException
Loads a specific component with custom load time configuration. This is a convenience when a specific component is to be used without specifically adding a configuration line in the file core_components.xml

Parameters:
pComponentName - the logical of the component (config, log, ...)
pComponentId - the unique id of the component (primary key for the service manager)
pConfigParams - the custom load time configuration (each key must correspond to java bean property)
Returns:
the associated component loaded and initialised.
Throws:
RaccoonException - if something goes wrong (invalid component, ...)

getIntrospector

public static IBeanAnalyzer getIntrospector()
                                     throws RaccoonException
Loads the Bean Introspection service.

Returns:
the bean introspection service.
Throws:
RaccoonException - if the service couldn't be loaded or if the configuration file of the Service Manager is corrupted.

getDefaultNucleus

public static INucleus getDefaultNucleus()
                                  throws RaccoonException
Loads and returns the primary/default implementation of INucleus

Returns:
the nucleus component manager.
Throws:
RaccoonException - if the default nucleus implementation couldn't be found.

getNucleus

public static INucleus getNucleus(java.lang.String pNucleusName)
                           throws RaccoonException
Loads and returns the nucleus instance.

Parameters:
pNucleusName - the name of the nucleus instance.
Returns:
the implementation of INucleus
Throws:
RaccoonException - if the specified nucleus isn't defined in the current repository.

getServiceManager

public static IServiceManager getServiceManager(java.lang.String pXmlResourceFile)
                                         throws RaccoonException
Retrieves a service manager instance based upon the specified resource manager.

Don't forget to invoke IServiceManager.shutdown(boolean) when finished with this manager.

Parameters:
pXmlResourceFile - the name of the XML configuration file to use.
Returns:
the appropraite service manager that will use the given XML resource file.
Throws:
RaccoonException - if the creation fails.

reload

public static void reload()
                   throws RaccoonException
Unloads all loaded components and reinits the Service Manager. Useful in the unit testing arena.

Throws:
RaccoonException - if the reload sequence failed.


Copyright null null. All Rights Reserved.