public final class UWSConfiguration
extends java.lang.Object
Utility class gathering tool functions and properties' names useful to deal with a UWS configuration file.
This class implements the Design Pattern "Utility": no instance of this class can be created, it can not be extended, and it must be used only thanks to its static classes and attributes.
Modifier and Type | Field and Description |
---|---|
static boolean |
DEFAULT_BACKUP_BY_USER
Default value of the property
KEY_BACKUP_BY_USER : false. |
static long |
DEFAULT_BACKUP_FREQUENCY
Default value of the property
KEY_BACKUP_FREQUENCY : DEFAULT_BACKUP_FREQUENCY . |
static boolean |
DEFAULT_DIRECTORY_PER_USER
Default value of the property
KEY_DIRECTORY_PER_USER : false. |
static int |
DEFAULT_EXECUTION_DURATION
Default value of the property
KEY_DEFAULT_EXECUTION_DURATION and KEY_MAX_EXECUTION_DURATION : 0. |
static java.lang.String |
DEFAULT_FILE_MANAGER
Default value of the property
KEY_FILE_MANAGER : "local". |
static boolean |
DEFAULT_GROUP_USER_DIRECTORIES
Default value of the property
KEY_GROUP_USER_DIRECTORIES : false. |
static java.lang.String |
DEFAULT_LOGGER
Default value of the property
KEY_LOGGER :
"default". |
static java.lang.String |
DEFAULT_UWS_CONF_FILE
Default UWS configuration file.
|
static java.lang.String |
KEY_ADD_SERIALIZERS
Name/Key of the property specifying a list of UWS serializers to add to the UWS service.
|
static java.lang.String |
KEY_ADD_UWS_ACTIONS
Name/Key of the property specifying a list of actions to add to the UWS service.
|
static java.lang.String |
KEY_BACKUP_BY_USER
Name/Key of the property indicating whether there should be one backup file per user or one file for all.
|
static java.lang.String |
KEY_BACKUP_FREQUENCY
Name/Key of the property specifying the frequency (in milliseconds) of jobs backup.
|
static java.lang.String |
KEY_DEFAULT_DESTRUCTION_INTERVAL
Name/Key of the property specifying the default destruction interval (actually a duration between the creation and the destruction
of the job) set automatically to a job if none has been specified by the user.
|
static java.lang.String |
KEY_DEFAULT_EXECUTION_DURATION
Name/Key of the property specifying the default execution duration (in milliseconds) set automatically to a job
if none has been specified by the user.
|
static java.lang.String |
KEY_DESTRUCTION_MANAGER
Name/Key of the property specifying the
DestructionManager instance that a specific job list must use. |
static java.lang.String |
KEY_DIRECTORY_PER_USER
Name/Key of the property indicating whether the jobs must be saved by user or not.
|
static java.lang.String |
KEY_ERROR_WRITER
Name/Key of the property specifying the error writer the UWS service must use.
|
static java.lang.String |
KEY_EXECUTION_MANAGER
Name/Key of the property specifying the
ExecutionManager instance that a specific job list must use. |
static java.lang.String |
KEY_FILE_MANAGER
Name/Key of the property setting the file manager to use in the UWS service.
|
static java.lang.String |
KEY_FILE_ROOT_PATH
Name/Key of the property setting the local root directory where all UWS files must be stored.
|
static java.lang.String |
KEY_GROUP_USER_DIRECTORIES
Name/Key of the property indicating whether the user directories (in which jobs of the user are backuped)
must be gathered in less directories.
|
static java.lang.String |
KEY_HOME_PAGE
Name/Key of the property specifying the UWS home page to use.
|
static java.lang.String |
KEY_HOME_PAGE_MIME_TYPE
Name/Key of the property specifying the MIME type of the set home page.
|
static java.lang.String |
KEY_JOB_LISTS
Name/Key of the property listing all the job lists to have in the UWS service.
|
static java.lang.String |
KEY_JOB_THREAD
Name/Key of the property specifying the
JobThread instance to use for a specific job list. |
static java.lang.String |
KEY_LOG_ROTATION
Name/Key of the property specifying the frequency of the log file
rotation to set in the default logger.
|
static java.lang.String |
KEY_LOGGER
Name/Key of the property specifying the logger to use.
|
static java.lang.String |
KEY_MAX_DESTRUCTION_INTERVAL
Name/Key of the property specifying the maximum destruction interval (actually a duration between the creation and the destruction
of the job) set automatically to a job if none has been specified by the user.
|
static java.lang.String |
KEY_MAX_EXECUTION_DURATION
Name/Key of the property specifying the maximum execution duration (in milliseconds) that can be set on a job.
|
static java.lang.String |
KEY_MAX_RUNNING_JOBS
Name/Key of the property specifying the maximum number of jobs that can run in parallel inside a specific job list.
|
static java.lang.String |
KEY_MIN_LOG_LEVEL
Name/Key of the property specifying the minimum type of messages
(i.e.
|
static java.lang.String |
KEY_PARAMETERS
Name/Key of the property listing all input parameters of jobs of a specific job list.
|
static java.lang.String |
KEY_REGEXP_MAX_DESTRUCTION_INTERVAL
Regular Expression of the name/key of the property specifying the maximum destruction interval for jobs of a given job list.
|
static java.lang.String |
KEY_REQUEST_PARSER
Name/Key of the property specifying the
RequestParser class to use instead of the default UWSRequestParser . |
static java.lang.String |
KEY_SERVICE_DESCRIPTION
Name/Key of the property specifying the description of the UWS service.
|
static java.lang.String |
KEY_SERVICE_NAME
Name/Key of the property specifying the name of this UWS service.
|
static java.lang.String |
KEY_USER_IDENTIFIER
Name/Key of the property specifying the user identification method to use.
|
static java.lang.String |
KEY_UWS_FACTORY
Name/Key of the property specifying the
UWSFactory class to use instead of the default ConfigurableUWSFactory . |
static java.lang.String |
KEY_XSLT_STYLESHEET
Name/Key of the property specifying the XSLT stylesheet to use when job are serialized in XML.
|
static java.lang.String |
REGEXP_DEFAULT_DESTRUCTION_INTERVAL
Regular Expression of the name/key of the property specifying the default destruction interval for jobs of a given job list.
|
static java.lang.String |
REGEXP_DEFAULT_EXEC_DURATION
Regular Expression of the name/key of the property specifying the default execution duration for jobs of a given job list.
|
static java.lang.String |
REGEXP_DESTRUCTION_MANAGER
Regular Expression of the name/key of the property specifying the
DestructionManager instance that a given job list must use. |
static java.lang.String |
REGEXP_EXECUTION_MANAGER
Regular Expression of the name/key of the property specifying the
ExecutionManager instance that a given job list must use. |
static java.lang.String |
REGEXP_JOB_LIST_NAME
Regular Expression of a job list name supposed to represent a job list name.
|
static java.lang.String |
REGEXP_JOB_THREAD
Regular Expression of the name/key of the property specifying the
JobThread instance to use for a given job list. |
static java.lang.String |
REGEXP_MAX_EXEC_DURATION
Regular Expression of the name/key of the property specifying the maximum execution duration for jobs of a given job list.
|
static java.lang.String |
REGEXP_MAX_RUNNING_JOBS
Regular Expression of the name/key of the property specifying maximum number of jobs that can run in parallel inside
the specified job list.
|
static java.lang.String |
REGEXP_PARAMETERS
Regular Expression of the name/key of the property listing all parameters expected for jobs of a given job list.
|
static java.lang.String |
SLF4J_LOGGER
SLF4J logger value: "slf4j".
|
static java.lang.String |
UWS_CONF_PARAMETER
Name of the initial parameter to set in the WEB-INF/web.xml file
in order to specify the location and the name of the UWS configuration file to load.
|
static java.lang.String |
VALUE_LOCAL
Value of the property
KEY_FILE_MANAGER specifying a local file manager. |
static java.lang.String |
VALUE_NEVER
Value of the property
KEY_BACKUP_FREQUENCY indicating that jobs should never be backuped. |
static java.lang.String |
VALUE_USER_ACTION
Value of the property
KEY_BACKUP_FREQUENCY indicating that job backup should occur only when the user
creates or modifies one of his jobs. |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
extractJobListName(java.lang.String compoundPropertyName)
Extract the job list name prefixing the given property name.
|
static <C> java.lang.Class<? extends C> |
fetchClass(java.lang.String value,
java.lang.String propertyName,
java.lang.Class<C> expectedType)
Fetch the class object corresponding to the class name provided between brackets in the given value.
|
static <C> java.lang.reflect.Constructor<? extends C> |
fetchConstructor(java.lang.String propValue,
java.lang.String propName,
java.lang.Class<C> expectedType,
java.lang.Class<?>[] pTypes)
Fetch the specified constructor of the class corresponding to the class name provided between brackets in the given value.
|
static java.lang.String |
getProperty(java.util.Properties prop,
java.lang.String key)
Read the asked property from the given Properties object.
|
static <C> boolean |
hasConstructor(java.lang.String propValue,
java.lang.String propName,
java.lang.Class<C> expectedType,
java.lang.Class<?>[] pTypes)
Test whether the specified class has a constructor with the specified parameters.
|
static boolean |
isClassName(java.lang.String value)
Test whether a property value is a class name.
|
static <C> C |
newInstance(java.lang.String propValue,
java.lang.String propName,
java.lang.Class<C> expectedType)
Create an instance of the specified class.
|
static <C> C |
newInstance(java.lang.String propValue,
java.lang.String propName,
java.lang.Class<C> expectedType,
java.lang.Class<?>[] pTypes,
java.lang.Object[] parameters)
Create an instance of the specified class.
|
static long |
parseLimit(java.lang.String value,
java.lang.String propertyName)
Lets parsing a limit (for upload, ...) with its numeric value and its unit.
|
public static final java.lang.String UWS_CONF_PARAMETER
public static final java.lang.String DEFAULT_UWS_CONF_FILE
public static final java.lang.String KEY_HOME_PAGE
public static final java.lang.String KEY_HOME_PAGE_MIME_TYPE
public static final java.lang.String KEY_SERVICE_NAME
public static final java.lang.String KEY_SERVICE_DESCRIPTION
public static final java.lang.String KEY_JOB_LISTS
public static final java.lang.String REGEXP_JOB_LIST_NAME
public static final java.lang.String KEY_JOB_THREAD
JobThread
instance to use for a specific job list.public static final java.lang.String REGEXP_JOB_THREAD
JobThread
instance to use for a given job list.
The first part of this regular expression (REGEXP_JOB_LIST_NAME
) is supposed to be the job list name.
Then a point is appended and finally KEY_JOB_THREAD
ends the regular expression.
public static final java.lang.String KEY_PARAMETERS
public static final java.lang.String REGEXP_PARAMETERS
The first part of this regular expression (REGEXP_JOB_LIST_NAME
) is supposed to be the job list name.
Then a point is appended and finally KEY_PARAMETERS
ends the regular expression.
public static final java.lang.String KEY_DEFAULT_EXECUTION_DURATION
public static final java.lang.String REGEXP_DEFAULT_EXEC_DURATION
The first part of this regular expression (REGEXP_JOB_LIST_NAME
) is supposed to be the job list name.
Then a point is appended and finally KEY_DEFAULT_EXECUTION_DURATION
ends the regular expression.
public static final java.lang.String KEY_MAX_EXECUTION_DURATION
public static final java.lang.String REGEXP_MAX_EXEC_DURATION
The first part of this regular expression (REGEXP_JOB_LIST_NAME
) is supposed to be the job list name.
Then a point is appended and finally KEY_MAX_EXECUTION_DURATION
ends the regular expression.
public static final int DEFAULT_EXECUTION_DURATION
KEY_DEFAULT_EXECUTION_DURATION
and KEY_MAX_EXECUTION_DURATION
: 0.public static final java.lang.String KEY_MAX_RUNNING_JOBS
public static final java.lang.String REGEXP_MAX_RUNNING_JOBS
The first part of this regular expression (REGEXP_JOB_LIST_NAME
) is supposed to be the job list name.
Then a point is appended and finally KEY_MAX_RUNNING_JOBS
ends the regular expression.
public static final java.lang.String KEY_EXECUTION_MANAGER
ExecutionManager
instance that a specific job list must use.public static final java.lang.String REGEXP_EXECUTION_MANAGER
ExecutionManager
instance that a given job list must use.
The first part of this regular expression (REGEXP_JOB_LIST_NAME
) is supposed to be the job list name.
Then a point is appended and finally KEY_EXECUTION_MANAGER
ends the regular expression.
public static final java.lang.String KEY_DEFAULT_DESTRUCTION_INTERVAL
public static final java.lang.String REGEXP_DEFAULT_DESTRUCTION_INTERVAL
The first part of this regular expression (REGEXP_JOB_LIST_NAME
) is supposed to be the job list name.
Then a point is appended and finally KEY_DEFAULT_DESTRUCTION_INTERVAL
ends the regular expression.
public static final java.lang.String KEY_MAX_DESTRUCTION_INTERVAL
public static final java.lang.String KEY_REGEXP_MAX_DESTRUCTION_INTERVAL
The first part of this regular expression (REGEXP_JOB_LIST_NAME
) is supposed to be the job list name.
public static final java.lang.String KEY_DESTRUCTION_MANAGER
DestructionManager
instance that a specific job list must use.public static final java.lang.String REGEXP_DESTRUCTION_MANAGER
DestructionManager
instance that a given job list must use.
The first part of this regular expression (REGEXP_JOB_LIST_NAME
) is supposed to be the job list name.
Then a point is appended and finally KEY_DESTRUCTION_MANAGER
ends the regular expression.
public static final java.lang.String KEY_FILE_MANAGER
public static final java.lang.String VALUE_LOCAL
KEY_FILE_MANAGER
specifying a local file manager.public static final java.lang.String DEFAULT_FILE_MANAGER
KEY_FILE_MANAGER
: "local".public static final java.lang.String KEY_FILE_ROOT_PATH
KEY_FILE_MANAGER
is set to VALUE_LOCAL
.public static final java.lang.String KEY_DIRECTORY_PER_USER
KEY_FILE_ROOT_PATH
).public static final boolean DEFAULT_DIRECTORY_PER_USER
KEY_DIRECTORY_PER_USER
: false.public static final java.lang.String KEY_GROUP_USER_DIRECTORIES
public static final boolean DEFAULT_GROUP_USER_DIRECTORIES
KEY_GROUP_USER_DIRECTORIES
: false.public static final java.lang.String KEY_LOGGER
DefaultUWSLog
is used.public static final java.lang.String DEFAULT_LOGGER
KEY_LOGGER
:
"default".public static final java.lang.String KEY_MIN_LOG_LEVEL
By default all messages are logged...which is equivalent to set this property to "DEBUG".
Note: If KEY_LOGGER
is set to a value different
from "default", this property is ignored.
public static final java.lang.String KEY_LOG_ROTATION
By default the log rotation occurs every day at midnight.
Note: If KEY_LOGGER
is set to a value different
from "default", this property is ignored.
public static final java.lang.String SLF4J_LOGGER
public static final java.lang.String KEY_BACKUP_FREQUENCY
public static final java.lang.String VALUE_NEVER
KEY_BACKUP_FREQUENCY
indicating that jobs should never be backuped.public static final java.lang.String VALUE_USER_ACTION
KEY_BACKUP_FREQUENCY
indicating that job backup should occur only when the user
creates or modifies one of his jobs. This value can be used ONLY IF KEY_BACKUP_BY_USER
is "true".public static final long DEFAULT_BACKUP_FREQUENCY
KEY_BACKUP_FREQUENCY
: DEFAULT_BACKUP_FREQUENCY
.public static final java.lang.String KEY_BACKUP_BY_USER
public static final boolean DEFAULT_BACKUP_BY_USER
KEY_BACKUP_BY_USER
: false.
This property can be enabled only if a user identification method is provided.public static final java.lang.String KEY_USER_IDENTIFIER
public static final java.lang.String KEY_REQUEST_PARSER
RequestParser
class to use instead of the default UWSRequestParser
.public static final java.lang.String KEY_ADD_SERIALIZERS
public static final java.lang.String KEY_XSLT_STYLESHEET
public static final java.lang.String KEY_ERROR_WRITER
public static final java.lang.String KEY_ADD_UWS_ACTIONS
public static final java.lang.String KEY_UWS_FACTORY
UWSFactory
class to use instead of the default ConfigurableUWSFactory
.
Setting a value to this property could disable several properties of the UWS configuration file.public static final java.lang.String getProperty(java.util.Properties prop, java.lang.String key)
Read the asked property from the given Properties object.
prop
- List of propertykey
- Property whose the value is requested.public static final java.lang.String extractJobListName(java.lang.String compoundPropertyName)
Important:
This function aims to be used for properties prefixed by a job list name such as
REGEXP_JOB_THREAD
, REGEXP_PARAMETERS
, ...
compoundPropertyName
- Property name prefixed by a job list name.null
if the given name is null
or if it is not prefixed by a valid job list name.public static final boolean isClassName(java.lang.String value)
value
- Property value.public static final <C> java.lang.Class<? extends C> fetchClass(java.lang.String value, java.lang.String propertyName, java.lang.Class<C> expectedType) throws UWSException
value
- Value which is supposed to contain the class name between brackets (see isClassName(String)
for more details)propertyName
- Name of the property associated with the parameter "value".expectedType
- Type of the class expected to be returned ; it is also the type which parameterizes this function: C.UWSException
- If the class name is incorrect
or if its type is not compatible with the parameterized type C (represented by the parameter "expectedType").isClassName(String)
public static final <C> boolean hasConstructor(java.lang.String propValue, java.lang.String propName, java.lang.Class<C> expectedType, java.lang.Class<?>[] pTypes) throws UWSException
propValue
- Value which is supposed to contain the class name between brackets (see isClassName(String)
for more details)propName
- Name of the property associated with the parameter "propValue".expectedType
- Type of the class expected to be returned ; it is also the type which parameterizes this function: C.pTypes
- List of each constructor parameter type. Each type MUST be exactly the type declared in the class constructor to select. NULL or empty array if no parameter.true
if the specified class has a constructor with the specified parameters,
false
otherwise.UWSException
- If the class name is incorrect
or if its type is not compatible with the parameterized type C (represented by the parameter "expectedType").public static final <C> java.lang.reflect.Constructor<? extends C> fetchConstructor(java.lang.String propValue, java.lang.String propName, java.lang.Class<C> expectedType, java.lang.Class<?>[] pTypes) throws UWSException
IMPORTANT: The number and types of given parameters MUST match exactly to the list of parameter types.
propValue
- Value which is supposed to contain the class name between brackets (see isClassName(String)
for more details)propName
- Name of the property associated with the parameter "propValue".expectedType
- Type of the class expected to be returned ; it is also the type which parameterizes this function: C.pTypes
- List of each constructor parameter type. Each type MUST be exactly the type declared in the class constructor to select. NULL or empty array if no parameter.UWSException
- If the class name is incorrect
or if its type is not compatible with the parameterized type C (represented by the parameter "expectedType")
or if the constructor with the specified parameters can not be found.public static final <C> C newInstance(java.lang.String propValue, java.lang.String propName, java.lang.Class<C> expectedType) throws UWSException
Create an instance of the specified class. The class name is expected to be surrounded by {} in the given value.
The instance is created using the empty constructor of the specified class.
propValue
- Value which is supposed to contain the class name between brackets (see isClassName(String)
for more details)propName
- Name of the property associated with the parameter "propValue".expectedType
- Type of the class expected to be returned ; it is also the type which parameterizes this function: C.UWSException
- If the class name is incorrect
or if its type is not compatible with the parameterized type C (represented by the parameter "expectedType")
or if the specified class has no empty constructor
or if an error occurred while calling this constructor.isClassName(String)
,
fetchClass(String, String, Class)
public static final <C> C newInstance(java.lang.String propValue, java.lang.String propName, java.lang.Class<C> expectedType, java.lang.Class<?>[] pTypes, java.lang.Object[] parameters) throws UWSException
Create an instance of the specified class. The class name is expected to be surrounded by {} in the given value.
IMPORTANT: The instance is created using the constructor whose the declaration matches exactly with the given list of parameter types. The number and types of given parameters MUST match exactly to the list of parameter types.
propValue
- Value which is supposed to contain the class name between brackets (see isClassName(String)
for more details)propName
- Name of the property associated with the parameter "propValue".expectedType
- Type of the class expected to be returned ; it is also the type which parameterizes this function: C.pTypes
- List of each constructor parameter type. Each type MUST be exactly the type declared in the class constructor to select. NULL or empty array if no parameter.parameters
- List of all constructor parameters. The number of object MUST match exactly the number of classes provided in the parameter pTypes. NULL or empty array if no parameter.UWSException
- If the class name is incorrect
or if its type is not compatible with the parameterized type C (represented by the parameter "expectedType")
or if the constructor with the specified parameters can not be found
or if an error occurred while calling this constructor.isClassName(String)
,
fetchClass(String, String, Class)
public static final long parseLimit(java.lang.String value, java.lang.String propertyName) throws UWSException
Lets parsing a limit (for upload, ...) with its numeric value and its unit.
Here is the expected syntax: num_val[unit]. Where unit is optional and should be one of the following values: B, kB, MB or GB. If the unit is not specified, it is set by default to BYTES.
Note: If the value is strictly less than 0 (whatever is the unit), the returned value will be -1.
value
- Property value (must follow the limit syntax: num_val[unit] ; ex: 20kB or 2000 (for 2000 bytes)).propertyName
- Name of the property which specify the limit.UWSException
- If the syntax is incorrect or if a not allowed unit has been used.