ome.util.tasks
Class Configuration

java.lang.Object
  extended by ome.util.tasks.Configuration
Direct Known Subclasses:
Config

public class Configuration
extends Object

Helper for creating any task from String properties, and can even instantiate ServiceFactory and Task objects if given the proper arguments. Understands the parameters:

To login as a root, for example, Properties of the form: {task=mytask, user=root, group=system, type=Task, pass=SECRET}

Since:
3.0-Beta1
Version:
$Revision: 1282 $, $Date: 2007-02-15 17:13:20 +0000 (Thu, 15 Feb 2007) $
Author:
Josh Moore, josh.moore at gmx.de
See Also:
Configuration, Task

Nested Class Summary
static class Configuration.Keys
          Enumeration of the string values which will be used directly by Configuration.
 
Field Summary
static String DEFAULTPKG
          Default package in which Task lookups will be performed.
 
Constructor Summary
Configuration(Properties props)
          Sole constructor.
 
Method Summary
 ServiceFactory createServiceFactory()
          Creates a ServiceFactory instance based on the values of #getServer() and #getLogin() (such that a subclass could override these methods to influence the ServiceFactory).
 Task createTask()
          Creates a new Task based on the values of getProperties(), getTaskClass(), and createServiceFactory().
 Properties getProperties()
          Returns the Properties instance provided during constuction.
 Class<Task> getTaskClass()
          Returns the Class found in the Properties
protected  String p(Configuration.Keys key)
          Returns the property for the Enum.toString() value of the argument.
protected  Class<Task> parseTask(String task, String pkg)
          Adds the package to the task name, and returns the class if found.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULTPKG

public static final String DEFAULTPKG
Default package in which Task lookups will be performed.

See Also:
Constant Field Values
Constructor Detail

Configuration

public Configuration(Properties props)
Sole constructor. Performs the necessary parsing of the Properties values.

Parameters:
props - Not null.
Method Detail

getProperties

public Properties getProperties()
Returns the Properties instance provided during constuction.


getTaskClass

public Class<Task> getTaskClass()
Returns the Class found in the Properties


createServiceFactory

public ServiceFactory createServiceFactory()
Creates a ServiceFactory instance based on the values of #getServer() and #getLogin() (such that a subclass could override these methods to influence the ServiceFactory).

Returns:
a non-null ServiceFactory instance.

createTask

public Task createTask()
Creates a new Task based on the values of getProperties(), getTaskClass(), and createServiceFactory().

Returns:
a non-null Task instance, ready for execution.
Throws:
RuntimeException - if anything happens during the reflection-based creation of the Task

p

protected String p(Configuration.Keys key)
Returns the property for the Enum.toString() value of the argument.


parseTask

protected Class<Task> parseTask(String task,
                                String pkg)
Adds the package to the task name, and returns the class if found. Otherwise, null.



OmeroJava Api

Version: Beta-4.1.1-r5927-b91

Copyright © 2009 The University of Dundee. All Rights Reserved.