|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.turbine.services.BaseInitable | +--org.apache.turbine.services.BaseService | +--org.apache.turbine.services.TurbineBaseService | +--org.apache.turbine.services.resources.TurbineResourceService
This implementation of the resourcesService
relies
on an external properties file for storing the configuration keys
and values.
In order to be compatible with legacy applications, this implementation kept a static method for initializing the service, so it's still possible to write the following code:
TurbineResourceService.setPropertiesName("d:/conf/Turbine.properties");
Vector myVar = TurbineResources.getVector("myvar");
The new way to do things is to look at the org.apache.turbine.util.TurbineConfig class.
Field Summary | |
private org.apache.stratum.configuration.Configuration |
configuration
The container for the generic resources. |
private static java.lang.String |
END_TOKEN
|
private static java.lang.String |
START_TOKEN
|
Fields inherited from class org.apache.turbine.services.BaseService |
name, properties, serviceBroker |
Fields inherited from class org.apache.turbine.services.BaseInitable |
initableBroker, isInitialized |
Fields inherited from interface org.apache.turbine.services.resources.ResourceService |
SERVICE_NAME |
Constructor Summary | |
TurbineResourceService()
|
Method Summary | |
boolean |
getBoolean(java.lang.String name)
The purpose of this method is to get the configuration resource with the given name as a boolean value. |
boolean |
getBoolean(java.lang.String name,
boolean def)
The purppose of this method is to get the configuration resource with the given name as a boolean value, or a default value. |
org.apache.stratum.configuration.Configuration |
getConfiguration()
Wrapper around the configuration resources. |
org.apache.stratum.configuration.Configuration |
getConfiguration(java.lang.String prefix)
The purpose of this method is to extract a subset of configuraton resources sharing a common name prefix. |
double |
getDouble(java.lang.String name)
The purpose of this method is to get the configuration resource with the given name as a double. |
double |
getDouble(java.lang.String name,
double def)
The purpose of this method is to get the configuration resource with the given name as a double, or a default value. |
float |
getFloat(java.lang.String name)
The purpose of this method is to get the configuration resource with the given name as a float. |
float |
getFloat(java.lang.String name,
float def)
The purpose of this method is to get the configuration resource with the given name as a float, or a default value. |
int |
getInt(java.lang.String name)
The purpose of this method is to get the configuration resource with the given name as an integer. |
int |
getInt(java.lang.String name,
int def)
The purpose of this method is to get the configuration resource with the given name as an integer, or a default value. |
java.util.Iterator |
getKeys()
Get the list of the keys contained in the configuration repository. |
java.util.Iterator |
getKeys(java.lang.String prefix)
Get the list of the keys contained in the configuration repository that match the specified prefix. |
long |
getLong(java.lang.String name)
The purpose of this method is to get the configuration resource with the given name as a long. |
long |
getLong(java.lang.String name,
long def)
The purpose of this method is to get the configuration resource with the given name as a long, or a default value. |
ResourceService |
getResources(java.lang.String prefix)
The purpose of this method is to extract a subset of configuraton resources sharing a common name prefix. |
java.lang.String |
getString(java.lang.String name)
The purpose of this method is to get the configuration resource with the given name as a string. |
java.lang.String |
getString(java.lang.String name,
java.lang.String def)
The purpose of this method is to get the configuration resource with the given name as a string, or a default value. |
java.lang.String[] |
getStringArray(java.lang.String name)
The purpose of this method is to get the configuration resource with the given name as a string array. |
java.util.Vector |
getVector(java.lang.String name)
The purpose of this method is to get the configuration resource with the given name as a vector. |
java.util.Vector |
getVector(java.lang.String name,
java.util.Vector def)
The purpose of this method is to get the configuration resource with the given name as a vector, or a default value. |
private void |
init(org.apache.stratum.configuration.Configuration configuration)
Initializer method that sets up the configuration resources. |
void |
init(java.lang.Object data)
Performs early initialization. |
private void |
init(java.util.Properties props)
The purpose of this method is to init the configuration resource with a Properties object sent from a different system. |
void |
init(javax.servlet.ServletConfig config)
This method is called when the Service is initialized |
protected java.lang.String |
interpolate(java.lang.String base)
|
static void |
setProperties(java.util.Properties properties)
Init the service with the given properties object. |
static void |
setPropertiesFileName(java.lang.String propertiesFileName)
Deprecated. |
void |
setProperty(java.lang.String key,
java.lang.String value)
Set a property in with a key=value pair. |
Methods inherited from class org.apache.turbine.services.TurbineBaseService |
init, init, shutdown |
Methods inherited from class org.apache.turbine.services.BaseService |
getName, getProperties, getServiceBroker, setName, setServiceBroker |
Methods inherited from class org.apache.turbine.services.BaseInitable |
getInit, getInitableBroker, setInit, setInitableBroker |
Methods inherited from class java.lang.Object |
|
Methods inherited from interface org.apache.turbine.services.Service |
getName, getProperties, setName, setServiceBroker |
Methods inherited from interface org.apache.turbine.services.Initable |
getInit, init, setInitableBroker, shutdown |
Field Detail |
private org.apache.stratum.configuration.Configuration configuration
private static final java.lang.String START_TOKEN
private static final java.lang.String END_TOKEN
Constructor Detail |
public TurbineResourceService()
Method Detail |
public void init(java.lang.Object data) throws InitializationException
init
in interface Initable
init
in class TurbineBaseService
data
- An Object to use for initialization activities.InitializationException,
- if initialization of this
class was not successful.public void init(javax.servlet.ServletConfig config) throws InitializationException
init
in class TurbineBaseService
config
- a ServletConfig objectpublic static void setPropertiesFileName(java.lang.String propertiesFileName) throws TurbineException
propertiesFileName
- The file name.IOException,
- if there was an I/O problem.public static void setProperties(java.util.Properties properties) throws TurbineException
properties
- The java.util.Properties object sent from another process such as
Cocoon. This Properties object contains all of the necessary properties
found in the TurbineResources.properties file.TurbineException,
- if there was an I/O problem.public void setProperty(java.lang.String key, java.lang.String value)
setProperty
in interface ResourceService
String
- keyString
- valueprotected java.lang.String interpolate(java.lang.String base)
public org.apache.stratum.configuration.Configuration getConfiguration()
getConfiguration
in interface Service
getConfiguration
in class BaseService
private void init(org.apache.stratum.configuration.Configuration configuration)
confs
- A Configurations object.private void init(java.util.Properties props)
props
- A Properties object.public boolean getBoolean(java.lang.String name)
getBoolean
in interface ResourceService
name
- The resource name.public boolean getBoolean(java.lang.String name, boolean def)
getBoolean
in interface ResourceService
name
- The resource name.def
- The default value of the resource.public double getDouble(java.lang.String name)
getDouble
in interface ResourceService
name
- The resoource name.public double getDouble(java.lang.String name, double def)
getDouble
in interface ResourceService
name
- The resource name.def
- The default value of the resource.public float getFloat(java.lang.String name)
getFloat
in interface ResourceService
name
- The resource name.public float getFloat(java.lang.String name, float def)
getFloat
in interface ResourceService
name
- The resource name.def
- The default value of the resource.public int getInt(java.lang.String name)
getInt
in interface ResourceService
name
- The resource name.public int getInt(java.lang.String name, int def)
getInt
in interface ResourceService
name
- The resource name.def
- The default value of the resource.public java.util.Iterator getKeys()
getKeys
in interface ResourceService
public java.util.Iterator getKeys(java.lang.String prefix)
getKeys
in interface ResourceService
prefix
- A String prefix to test against.public long getLong(java.lang.String name)
getLong
in interface ResourceService
name
- The resource name.public long getLong(java.lang.String name, long def)
getLong
in interface ResourceService
name
- The resource name.def
- The default value of the resource.public java.lang.String getString(java.lang.String name)
getString
in interface ResourceService
name
- The resource name.public java.lang.String getString(java.lang.String name, java.lang.String def)
getString
in interface ResourceService
name
- The resource name.def
- The default value of the resource.public java.lang.String[] getStringArray(java.lang.String name)
getStringArray
in interface ResourceService
name
- The resource name.public java.util.Vector getVector(java.lang.String name)
getVector
in interface ResourceService
name
- The resource name.public java.util.Vector getVector(java.lang.String name, java.util.Vector def)
getVector
in interface ResourceService
name
- The resource name.def
- The default value of the resource.public ResourceService getResources(java.lang.String prefix)
getResources
in interface ResourceService
prefix
- the common name prefixpublic org.apache.stratum.configuration.Configuration getConfiguration(java.lang.String prefix)
getConfiguration
in interface ResourceService
prefix
- the common name prefix
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |