org.ow2.carol.cmi.lb.util
Class LBPolicyFactory<T extends org.ow2.carol.cmi.lb.LoadBalanceable>

java.lang.Object
  extended by org.ow2.carol.cmi.lb.util.LBPolicyFactory<T>
Type Parameters:
T - the type parameter of the constructed policies

@ThreadSafe
public final class LBPolicyFactory<T extends org.ow2.carol.cmi.lb.LoadBalanceable>
extends java.lang.Object

Define a factory to construct policies.

Author:
The new CMI team

Constructor Summary
LBPolicyFactory(org.ow2.carol.cmi.controller.common.ClusterViewManager clusterViewManager)
          Constructs a new factory for policies with a given manager of cluster view.
 
Method Summary
static java.lang.Object convertString(java.lang.Class<? extends org.ow2.carol.cmi.lb.policy.ILBPolicy> lbPolicyClass, java.lang.String lbPropertyName, java.lang.String svalue)
          Converts the given value from String to the given type.
static java.lang.Object convertString(java.lang.reflect.Type propertyType, java.lang.String svalue)
           
static java.util.List<?> convertStrings(java.lang.Class<? extends org.ow2.carol.cmi.lb.policy.ILBPolicy> lbPolicyClass, java.lang.String lbPropertyName, java.util.List<java.lang.String> slist)
           
 org.ow2.carol.cmi.lb.policy.ILBPolicy<T> createLBPolicy(java.lang.String objectName)
          Returns a pure policy to access to the object with the given name.
static void findProperties(java.lang.Class<? extends org.ow2.carol.cmi.lb.policy.ILBPolicy> lbPolicyClass)
           
 org.ow2.carol.cmi.lb.policy.ILBPolicy<T> getLBPolicy(java.lang.String objectName)
          Returns a policy to access to the object with the given name.
static java.util.Map<java.lang.String,java.lang.Object> getProperties(org.ow2.carol.cmi.lb.policy.ILBPolicy<?> lbPolicy)
           
static java.lang.Object getProperty(org.ow2.carol.cmi.lb.policy.ILBPolicy<?> lbPolicy, java.lang.String propertyName)
           
static java.util.Map<java.lang.String,LBPropertyData> getPropertyData(java.lang.String lbPolicyClassname)
           
static java.lang.reflect.Type getPropertyRawType(java.lang.String lbPolicyClassname, java.lang.String propertyName)
           
static java.lang.reflect.Type getPropertyType(java.lang.String lbPolicyClassname, java.lang.String propertyName)
           
static void setProperties(org.ow2.carol.cmi.lb.policy.ILBPolicy<?> lbPolicy, java.util.Map<java.lang.String,java.lang.Object> properties)
          Sets properties for a given policy.
static void setProperty(org.ow2.carol.cmi.lb.policy.ILBPolicy<?> lbPolicy, java.lang.String propertyName, java.lang.Object propertyValue)
          Set a property for a given policy.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LBPolicyFactory

public LBPolicyFactory(org.ow2.carol.cmi.controller.common.ClusterViewManager clusterViewManager)
Constructs a new factory for policies with a given manager of cluster view.

Parameters:
clusterViewManager - a manager to retrieve the cluster view
Method Detail

getLBPolicy

public org.ow2.carol.cmi.lb.policy.ILBPolicy<T> getLBPolicy(java.lang.String objectName)
                                                                                                  throws LBPolicyFactoryException,
                                                                                                         org.ow2.carol.cmi.reference.ObjectNotFoundException
Returns a policy to access to the object with the given name.

Parameters:
objectName - a name of object
Returns:
a policy to access to the object with the given name
Throws:
LBPolicyFactoryException - if the policy cannot be constructed
org.ow2.carol.cmi.reference.ObjectNotFoundException - if none object has the given name

createLBPolicy

public org.ow2.carol.cmi.lb.policy.ILBPolicy<T> createLBPolicy(java.lang.String objectName)
                                                                                                     throws LBPolicyFactoryException,
                                                                                                            org.ow2.carol.cmi.reference.ObjectNotFoundException
Returns a pure policy to access to the object with the given name.

Parameters:
objectName - a name of object
Returns:
a pure policy to access to the object with the given name
Throws:
LBPolicyFactoryException - if the policy cannot be constructed
org.ow2.carol.cmi.reference.ObjectNotFoundException - if none object has the given name

setProperties

public static void setProperties(org.ow2.carol.cmi.lb.policy.ILBPolicy<?> lbPolicy,
                                 java.util.Map<java.lang.String,java.lang.Object> properties)
                          throws org.ow2.carol.cmi.lb.PropertyConfigurationException
Sets properties for a given policy.

Parameters:
lbPolicy - a policy
properties - properties of the policy
Throws:
org.ow2.carol.cmi.lb.PropertyConfigurationException - if a property cannot be set

setProperty

public static void setProperty(org.ow2.carol.cmi.lb.policy.ILBPolicy<?> lbPolicy,
                               java.lang.String propertyName,
                               java.lang.Object propertyValue)
                        throws org.ow2.carol.cmi.lb.PropertyConfigurationException
Set a property for a given policy.

Parameters:
lbPolicy - a policy
propertyName - a name of property
propertyValue - a value of property
Throws:
org.ow2.carol.cmi.lb.PropertyConfigurationException

getProperties

public static java.util.Map<java.lang.String,java.lang.Object> getProperties(org.ow2.carol.cmi.lb.policy.ILBPolicy<?> lbPolicy)

getProperty

public static java.lang.Object getProperty(org.ow2.carol.cmi.lb.policy.ILBPolicy<?> lbPolicy,
                                           java.lang.String propertyName)

getPropertyRawType

public static java.lang.reflect.Type getPropertyRawType(java.lang.String lbPolicyClassname,
                                                        java.lang.String propertyName)

getPropertyType

public static java.lang.reflect.Type getPropertyType(java.lang.String lbPolicyClassname,
                                                     java.lang.String propertyName)

getPropertyData

public static java.util.Map<java.lang.String,LBPropertyData> getPropertyData(java.lang.String lbPolicyClassname)

convertString

public static java.lang.Object convertString(java.lang.Class<? extends org.ow2.carol.cmi.lb.policy.ILBPolicy> lbPolicyClass,
                                             java.lang.String lbPropertyName,
                                             java.lang.String svalue)
                                      throws org.ow2.carol.cmi.lb.PropertyConfigurationException
Converts the given value from String to the given type.

Parameters:
lbPropertyName -
svalue - a value
Returns:
an object that has the same that the given field
Throws:
org.ow2.carol.cmi.lb.PropertyConfigurationException - if the conversion is not possible

convertString

public static java.lang.Object convertString(java.lang.reflect.Type propertyType,
                                             java.lang.String svalue)
                                      throws org.ow2.carol.cmi.lb.PropertyConfigurationException
Throws:
org.ow2.carol.cmi.lb.PropertyConfigurationException

convertStrings

public static java.util.List<?> convertStrings(java.lang.Class<? extends org.ow2.carol.cmi.lb.policy.ILBPolicy> lbPolicyClass,
                                               java.lang.String lbPropertyName,
                                               java.util.List<java.lang.String> slist)
                                        throws org.ow2.carol.cmi.lb.PropertyConfigurationException
Throws:
org.ow2.carol.cmi.lb.PropertyConfigurationException

findProperties

public static void findProperties(java.lang.Class<? extends org.ow2.carol.cmi.lb.policy.ILBPolicy> lbPolicyClass)
                           throws org.ow2.carol.cmi.lb.PropertyConfigurationException
Throws:
org.ow2.carol.cmi.lb.PropertyConfigurationException


Copyright © 2007 OW2 Consortium. All Rights Reserved.