com.arsdigita.runtime
Class AbstractConfig

java.lang.Object
  extended bycom.arsdigita.util.parameter.AbstractParameterContext
      extended bycom.arsdigita.runtime.AbstractConfig
All Implemented Interfaces:
ParameterContext
Direct Known Subclasses:
BebopConfig, DispatcherConfig, FormBuilderConfig, KernelConfig, LuceneConfig, MailConfig, RegistryConfig, RuntimeConfig, SearchConfig, SecurityConfig, TemplatingConfig, WebConfig, WorkflowConfig, XMLConfig

public abstract class AbstractConfig
extends AbstractParameterContext

AbstractConfig is a base class for groups of customizable configuration parameters. A CCM Developer wishing to add a new group of configuration parameters to his application will extend this class and provide a public noargs constructer that registers his parameters with the superclass. For example:

 package com.arsdigita.exampleApp;

 public final class ExampleConfig extends AbstractConfig {

     private Parameter m_string = new StringParameter
         ("example.string", Parameter.OPTIONAL, "default");
     private Parameter m_integer = new IntegerParameter
         ("example.integer", Parameter.OPTIONAL, new Integer(0));
     private Parameter m_boolean = new BooleanParameter
         ("example.boolean", Parameter.OPTIONAL, Boolean.TRUE);

     public ExampleConfig() {
         register(m_string);
         register(m_integer);
         register(m_boolean);
         loadInfo();
     }

     public String getString() {
         return (String) get(m_string);
     }

     public int getInteger() {
         return ((Integer) get(m_integer)).intValue();
     }

     public boolean getBoolean() {
         return Boolean.TRUE.equals(get(m_boolean));
     }

 }
 
When this pattern is followed, the resulting subclass of abstract config may be used by developers writing java code to access the values of customizable configuration parameters in a convenient and type safe manner. In addition, the very same class is also usable by the ccm configuration tools to allow customization and validation of the new parameters.

Version:
$Id: //core-platform/dev/src/com/arsdigita/runtime/AbstractConfig.java#7 $
Author:
Justin Ross <jross@redhat.com>

Field Summary
static String versionId
           
 
Constructor Summary
protected AbstractConfig()
          Default constructor for subclasses.
 
Method Summary
 ErrorList load()
          Invokes the load(ErrorList) method with a new and empty ErrorList for accumulating errors, and returns that ErrorList.
 void load(ErrorList errors)
          Loads this AbstractConfig object with values from the default configuration registry.
 ErrorList load(String resource)
          Deprecated. Use @{link #load()} instead.
 ErrorList require(String resource)
          Deprecated. Use @{link #load()} instead.
 
Methods inherited from class com.arsdigita.util.parameter.AbstractParameterContext
get, get, getParameters, load, load, loadInfo, register, save, set, validate, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values
Constructor Detail

AbstractConfig

protected AbstractConfig()
Default constructor for subclasses.

Method Detail

load

public final void load(ErrorList errors)
Loads this AbstractConfig object with values from the default configuration registry. Any errors encountered during unmarshaling and loading of configuration values are added to the errors ErrorList. This method should not be called from the constructor of a config object since the ccm configuration tools need to be able to construct empty config objects.

Parameters:
errors - The ErrorList used to record errors during unmarshaling and loading.
See Also:
ConfigRegistry

load

public final ErrorList load()
Invokes the load(ErrorList) method with a new and empty ErrorList for accumulating errors, and returns that ErrorList. This method can be used in combination with the ErrorList.check() method to load and assert that this configuration object is valid in one simple idiom. For example:
     ExampleConfig conf = new ExampleConfig();
     conf.load().check();
     ...
 

Returns:
Errors that may have been encountered during configuration loading.
See Also:
load(ErrorList)

load

public final ErrorList load(String resource)
Deprecated. Use @{link #load()} instead.


require

public final ErrorList require(String resource)
Deprecated. Use @{link #load()} instead.



Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 20 2004:2337 UTC