org.apache.jetspeed.services.resources
Class VariableResourcesService

java.lang.Object
  extended byorg.apache.turbine.services.BaseInitable
      extended byorg.apache.turbine.services.BaseService
          extended byorg.apache.turbine.services.TurbineBaseService
              extended byorg.apache.turbine.services.resources.TurbineResourceService
                  extended byorg.apache.jetspeed.services.resources.VariableResourcesService
All Implemented Interfaces:
org.apache.turbine.services.Initable, org.apache.turbine.services.resources.ResourceService, org.apache.turbine.services.Service

public class VariableResourcesService
extends 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");

This implementation allows the use of several pre-defined variables within the configuration file. The variables are identified by the following sequence of tokens: ${}. Varname is always folded to lowercase.

The predefined variables are:

The init parameters of the servlet are also imported as default variables. They may override the previously defined default variables

Version:
$Id: VariableResourcesService.java,v 1.16 2005/03/21 18:21:44 sgala Exp $
Author:
Raphaël Luta

Field Summary
static java.lang.String END_TOKEN
           
static java.lang.String JVM_DIR
           
static java.lang.String START_TOKEN
           
static java.lang.String WEB_DIR
           
static java.lang.String WEBAPP_DIR
           
 
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
VariableResourcesService()
           
 
Method Summary
 org.apache.turbine.services.resources.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.
 void init()
          Late init.
 void init(javax.servlet.ServletConfig config)
          This method is called when the Service is initialized
protected  void setVariables(java.util.Hashtable vars)
           
protected  java.lang.String substituteString(java.lang.String base)
           
 
Methods inherited from class org.apache.turbine.services.resources.TurbineResourceService
getBoolean, getBoolean, getConfiguration, getConfiguration, getDouble, getDouble, getFloat, getFloat, getInt, getInt, getKeys, getKeys, getLong, getLong, init, interpolate, setProperties, setPropertiesFileName, setProperty
 
Methods inherited from class org.apache.turbine.services.TurbineBaseService
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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.turbine.services.Service
getName, getProperties, setName, setServiceBroker
 
Methods inherited from interface org.apache.turbine.services.Initable
getInit, setInitableBroker, shutdown
 

Field Detail

WEBAPP_DIR

public static final java.lang.String WEBAPP_DIR
See Also:
Constant Field Values

WEB_DIR

public static final java.lang.String WEB_DIR
See Also:
Constant Field Values

JVM_DIR

public static final java.lang.String JVM_DIR
See Also:
Constant Field Values

START_TOKEN

public static final java.lang.String START_TOKEN
See Also:
Constant Field Values

END_TOKEN

public static final java.lang.String END_TOKEN
See Also:
Constant Field Values
Constructor Detail

VariableResourcesService

public VariableResourcesService()
Method Detail

init

public void init()
Late init. Don't return control until early init says we're done.


init

public void init(javax.servlet.ServletConfig config)
          throws org.apache.turbine.services.InitializationException
This method is called when the Service is initialized

Parameters:
config - a ServletConfig object
Throws:
org.apache.turbine.services.InitializationException

setVariables

protected void setVariables(java.util.Hashtable vars)

substituteString

protected java.lang.String substituteString(java.lang.String base)

getString

public 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.

Parameters:
name - The resource name.
Returns:
The value of the resource as a string.

getString

public 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.

Parameters:
name - The resource name.
def - The default value of the resource.
Returns:
The value of the resource as a string.

getStringArray

public 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.

Parameters:
name - The resource name.
Returns:
The value of the resource as a string array.

getVector

public 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.

Parameters:
name - The resource name.
Returns:
The value of the resource as a vector.

getVector

public 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.

Parameters:
name - The resource name.
def - The default value of the resource.
Returns:
The value of the resource as a vector.

getResources

public org.apache.turbine.services.resources.ResourceService getResources(java.lang.String prefix)
The purpose of this method is to extract a subset of configuraton resources sharing a common name prefix. The prefix is stripped from the names of the resulting resources.

Parameters:
prefix - the common name prefix
Returns:
A ResourceService providing the subset of configuration.


Copyright © 2000-2005 Apache Software Foundation. All Rights Reserved.