org.norther.tammi.core.config
Interface Configurable

All Known Subinterfaces:
ChartGenerator, ConfigurableConverter<T>, ConfigurableFactory<T>, ForwardEngine, FreemarkerEngine, HibernateFactory, HttpRelayFilter, IpMaskFilter, JasperReports, JFreeCharts, JFreeReports, JndiRealm, JSPEngine, Logger, Mailer, Manager, MemoryRealm, NamingContextFactory, NativeRealm, OJBFactory, PersisterFactory, Realm, ReportEngine, RepositoryRealm, SessionManager, Startup, TemplateEngine, ThreadedLogger, VelocityEngine
All Known Implementing Classes:
AbstractChartGenerator, AbstractLogger, AbstractPersisterFactory, AbstractRealm, AbstractReportEngine, AbstractTemplateEngine, AbstractThreadedLogger, DefaultConfigurable, DefaultConfigurableConverter, DefaultConfigurableFactory, DefaultForwardEngine, DefaultFreemarkerEngine, DefaultHibernateFactory, DefaultHttpRelayFilter, DefaultIpMaskFilter, DefaultJasperReports, DefaultJFreeCharts, DefaultJFreeReports, DefaultJndiRealm, DefaultJSPEngine, DefaultMailer, DefaultMemoryRealm, DefaultNamingContextFactory, DefaultNativeRealm, DefaultOJBFactory, DefaultRepositoryRealm, DefaultSessionFactory, DefaultSessionManager, DefaultStartup, DefaultVelocityEngine, JDK4Logger, Log4JLogger

public interface Configurable

An interface to configurable objects defining properties for configuring their behaviour.

Version:
$Id: Configurable.java,v 1.25 2009/09/28 15:08:45 cvsimp Exp $
Author:
Ilkka Priha

Method Summary
 void addProperty(int index, String key, String value)
          Inserts a multivalued property at the specified index.
 void addProperty(String key, String value)
          Adds a multivalued property.
 void addPropertyFilePath(String path)
          Adds a property file path.
 void addPropertyFilePath(String path, String encoding)
          Adds a property file path with an encoding.
 void clearProperties()
          Clears all properties.
 boolean containsProperty(String key)
          Checks whether a property is defined.
 String getConfigKey()
          Gets the path finder key for resolving configuration paths.
 String[] getProperties(String key)
          Gets a multivalued property.
 String getProperty(String key)
          Gets a property.
 String getPropertyFilePath()
          Gets the property file path.
 String[] getPropertyFilePaths()
          Gets the property file paths.
 int indexOfProperty(String key, String value)
          Returns the index of a multivalued property value.
 OrderedMap<String,Object> propertyMap()
          Returns a map of properties.
 OrderedMap<String,Object> propertyMap(String prefix)
          Returns a map of prefixed properties.
 Object removeProperty(String key)
          Removes a property.
 boolean removeProperty(String key, String value)
          Removes a multivalued property.
 void removePropertyFilePath(String path)
          Removes a property file path.
 void setConfigKey(String key)
          Sets the path finder key for resolving configuration paths.
 Object setProperties(String key, String[] values)
          Sets a multivalued property.
 Object setProperty(String key, String value)
          Sets a property.
 void setPropertyFilePath(String path)
          Sets the property file path.
 void setPropertyFilePath(String path, String encoding)
          Sets the property file path with an encoding.
 void setPropertyFilePaths(String[] paths)
          Sets the property file paths.
 void setPropertyFilePaths(String[] paths, String... encoding)
          Sets the property file paths with encodings.
 void storeProperties()
          Stores properties to the property file.
 

Method Detail

getConfigKey

String getConfigKey()
Gets the path finder key for resolving configuration paths.

Returns:
the path finder key.

setConfigKey

void setConfigKey(String key)
Sets the path finder key for resolving configuration paths. The default key is PathFinderMBean.CONFIG.

Parameters:
key - the path finder key.

getPropertyFilePath

String getPropertyFilePath()
Gets the property file path. The first one is returned if more than one is defined.

Returns:
the property file path or null.

setPropertyFilePath

void setPropertyFilePath(String path)
Sets the property file path. The path may be an absolute file path, a file path relative to the specified config key folder or a URL. The properties will be loaded before the next get/set property operation.

Note that all previously defined property file paths and properties are cleared.

Parameters:
path - a property file path.

setPropertyFilePath

void setPropertyFilePath(String path,
                         String encoding)
Sets the property file path with an encoding.

Parameters:
path - a property file path.
encoding - an encoding to use.

getPropertyFilePaths

String[] getPropertyFilePaths()
Gets the property file paths.

Returns:
the property file paths.

setPropertyFilePaths

void setPropertyFilePaths(String[] paths)
Sets the property file paths. The path may be an absolute file path, a file path relative to the specified config key folder or a URL. The properties will be loaded before the next get/set property operation. New paths are added after existing ones.

Parameters:
paths - property file paths.

setPropertyFilePaths

void setPropertyFilePaths(String[] paths,
                          String... encoding)
Sets the property file paths with encodings.

Parameters:
paths - property file paths.
encoding - encodings to use.

addPropertyFilePath

void addPropertyFilePath(String path)
Adds a property file path.

Parameters:
path - a property file path.

addPropertyFilePath

void addPropertyFilePath(String path,
                         String encoding)
Adds a property file path with an encoding.

Parameters:
path - a property file path.
encoding - an encoding to use.

removePropertyFilePath

void removePropertyFilePath(String path)
Removes a property file path.

Parameters:
path - the property file path.

containsProperty

boolean containsProperty(String key)
Checks whether a property is defined.

Parameters:
key - the key.
Returns:
true for a defined property, false otherwise.

getProperty

String getProperty(String key)
Gets a property.

Parameters:
key - the key.
Returns:
the value or null.

setProperty

Object setProperty(String key,
                   String value)
Sets a property.

Parameters:
key - the key.
value - the value.
Returns:
the previous value.

getProperties

String[] getProperties(String key)
Gets a multivalued property.

Parameters:
key - the key.
Returns:
the values or null.

setProperties

Object setProperties(String key,
                     String[] values)
Sets a multivalued property.

Parameters:
key - the key.
values - the values.
Returns:
the previous value.

removeProperty

Object removeProperty(String key)
Removes a property.

Parameters:
key - the key.
Returns:
the removed value or null.

indexOfProperty

int indexOfProperty(String key,
                    String value)
Returns the index of a multivalued property value.

Parameters:
key - the key.
value - the value.
Returns:
the index of the value or -1.

addProperty

void addProperty(String key,
                 String value)
Adds a multivalued property.

Parameters:
key - the key.
value - the property.

addProperty

void addProperty(int index,
                 String key,
                 String value)
Inserts a multivalued property at the specified index.

Parameters:
index - the index.
key - the key.
value - the value.

removeProperty

boolean removeProperty(String key,
                       String value)
Removes a multivalued property.

Parameters:
key - the key.
value - the value.
Returns:
true if removed, false otherwise.

clearProperties

void clearProperties()
Clears all properties.


propertyMap

OrderedMap<String,Object> propertyMap()
Returns a map of properties. Multivalued properties are presented as string arrays.

Returns:
a map of properties.

propertyMap

OrderedMap<String,Object> propertyMap(String prefix)
Returns a map of prefixed properties. The prefix is removed from the keys of the returned map. Multivalued properties are presented as string arrays.

Parameters:
prefix - the prefix.
Returns:
a map of properties.

storeProperties

void storeProperties()
                     throws IOException
Stores properties to the property file. The first defined property file is applied to all properties.

Throws:
IOException - on I/O errors.


Copyright © 2004 The Norther Organization. All rights reserved.