org.xins.common.service
Class DescriptorBuilder

java.lang.Object
  extended byorg.xins.common.service.DescriptorBuilder

public final class DescriptorBuilder
extends Object

Builder that can build a Descriptor object based on a set of properties.

Examples

The following example is the definition of a single back-end at http://somehost/, identified by the property name "s1", the time-out is set to 20 seconds:

s1=service, http://somehost/, 20000

The next example is the definition of 4 back-ends, of which one will be chosen randomly. This setting is identified by the property name "capi.sso":

# The root definition "capi.sso"
capi.sso=group, random, target1, target2, target3, target4

# Total time-out is 12.5 seconds, no connection time-out and no socket
# time-out
capi.sso.target1=service, http://somehost/, 12500

# Total time-out is 12.5 seconds, connection time-out is 4 seconds and
# no socket time-out
capi.sso.target2=service, http://othrhost/, 12500, 4000

# Total time-out is 12.5 seconds, connection time-out is 4 seconds,
# socket time-out is 2 seconds
capi.sso.target3=service, http://othrhost:2001/, 12500, 4000, 2000

# Total time-out is not set, connection time-out is not set and socket
# time-out is 2 seconds
capi.sso.target4=service, http://othrhost:2002/, 0, 0, 2000

The last example defines 2 back-ends at a more preferred location and 1 at a less-preferred location. Normally one of the 2 back-ends at the preferred location will be chosen randomly, but if none is available, then the back-end at the less preferred location will be tried. The time-out for all back-ends in 8 seconds. The name of the property is "ldap":

ldap=group, ordered, loc1, host2a
ldap.loc1=group, random, host1a, host1b
ldap.host1a=service, ldap://host1a/, 8000
ldap.host1b=service, ldap://host1b/, 8000
ldap.host2a=service, ldap://host2a/, 8000

Since:
XINS 1.0.0
Version:
$Revision: 1.22 $ $Date: 2006/08/28 09:12:34 $
Author:
Ernst de Haan

Field Summary
static char DELIMITER
          Delimiter between tokens within a property value.
static String GROUP_DESCRIPTOR_TYPE
          Name identifying a group of descriptors.
static char LINE_DELIMITER
          Delimiter between property lines.
static String TARGET_DESCRIPTOR_TYPE
          Name identifying an actual target descriptor.
 
Method Summary
static Descriptor build(PropertyReader properties, String propertyName)
          Builds a Descriptor based on the specified set of properties.
static Descriptor build(ServiceCaller caller, PropertyReader properties, String propertyName)
          Builds a Descriptor based on the specified set of properties, for the specified service caller.
static Descriptor build(String descriptorValue)
          Builds a Descriptor based on the specified value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DELIMITER

public static final char DELIMITER
Delimiter between tokens within a property value. This is the comma character ','.

See Also:
Constant Field Values

LINE_DELIMITER

public static final char LINE_DELIMITER
Delimiter between property lines. This is the carraige return character '\n'.

See Also:
Constant Field Values

TARGET_DESCRIPTOR_TYPE

public static final String TARGET_DESCRIPTOR_TYPE
Name identifying an actual target descriptor.

See Also:
Constant Field Values

GROUP_DESCRIPTOR_TYPE

public static final String GROUP_DESCRIPTOR_TYPE
Name identifying a group of descriptors.

See Also:
Constant Field Values
Method Detail

build

public static Descriptor build(ServiceCaller caller,
                               PropertyReader properties,
                               String propertyName)
                        throws IllegalArgumentException,
                               MissingRequiredPropertyException,
                               InvalidPropertyValueException
Builds a Descriptor based on the specified set of properties, for the specified service caller.

Parameters:
caller - the caller to create a Descriptor for, can be null if unknown.
properties - the properties to read from, cannot be null.
propertyName - the base for the property names, cannot be null.
Returns:
the Descriptor that was built, never null.
Throws:
IllegalArgumentException - if properties == null || propertyName == null.
MissingRequiredPropertyException - if the property named propertyName cannot be found in properties, or if a referenced property cannot be found.
InvalidPropertyValueException - if the property named propertyName is found in properties, but the format of this property or the format of a referenced property is invalid.
Since:
XINS 1.2.0

build

public static Descriptor build(PropertyReader properties,
                               String propertyName)
                        throws IllegalArgumentException,
                               MissingRequiredPropertyException,
                               InvalidPropertyValueException
Builds a Descriptor based on the specified set of properties.

Parameters:
properties - the properties to read from, cannot be null.
propertyName - the base for the property names, cannot be null.
Returns:
the Descriptor that was built, never null.
Throws:
IllegalArgumentException - if properties == null || propertyName == null.
MissingRequiredPropertyException - if the property named propertyName cannot be found in properties, or if a referenced property cannot be found.
InvalidPropertyValueException - if the property named propertyName is found in properties, but the format of this property or the format of a referenced property is invalid.

build

public static Descriptor build(String descriptorValue)
                        throws IllegalArgumentException,
                               MissingRequiredPropertyException,
                               InvalidPropertyValueException
Builds a Descriptor based on the specified value.

Parameters:
descriptorValue - the value of the descriptor, cannot be null. the value must have the same value as specified at the top, the lines should be separated with '\n' and the first line must start with the name of the property followed by the sign '='.
Returns:
the Descriptor that was built, never null.
Throws:
IllegalArgumentException - if descriptorValue == null or the property name cannot be found in the value.
MissingRequiredPropertyException - if the property named propertyName cannot be found in properties, or if a referenced property cannot be found.
InvalidPropertyValueException - if the property named propertyName is found in properties, but the format of this property or the format of a referenced property is invalid.


See http://www.xins.org/.