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.Class<? extends org.ow2.carol.cmi.lb.policy.ILBPolicy> lbPolicyClass)
          Returns a pure policy for a given class.
 org.ow2.carol.cmi.lb.policy.ILBPolicy<T> getLBPolicy(java.lang.Class<? extends org.ow2.carol.cmi.lb.policy.ILBPolicy> lbPolicyClass, java.lang.Class<? extends org.ow2.carol.cmi.lb.strategy.ILBStrategy> lbStrategyClass, java.util.Map<java.lang.String,?> properties)
          Returns a policy for the given classes of LB policy, strategy and properties.
 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.Class<? extends org.ow2.carol.cmi.lb.policy.ILBPolicy> lbPolicyClass)
           
static java.lang.reflect.Type getPropertyRawType(java.lang.Class<? extends org.ow2.carol.cmi.lb.policy.ILBPolicy> lbPolicyClass, java.lang.String propertyName)
           
static java.lang.reflect.Type getPropertyType(java.lang.Class<? extends org.ow2.carol.cmi.lb.policy.ILBPolicy> lbPolicyClass, java.lang.String propertyName)
           
 
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

getLBPolicy

public org.ow2.carol.cmi.lb.policy.ILBPolicy<T> getLBPolicy(java.lang.Class<? extends org.ow2.carol.cmi.lb.policy.ILBPolicy> lbPolicyClass,
                                                            java.lang.Class<? extends org.ow2.carol.cmi.lb.strategy.ILBStrategy> lbStrategyClass,
                                                            java.util.Map<java.lang.String,?> properties)
                                                                                                  throws LBPolicyFactoryException
Returns a policy for the given classes of LB policy, strategy and properties.

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.Class<? extends org.ow2.carol.cmi.lb.policy.ILBPolicy> lbPolicyClass)
                                                                                                     throws LBPolicyFactoryException
Returns a pure policy for a given class.

Parameters:
lbPolicyClass - a class defining a LB policy
Returns:
a pure policy to access to the object with the given name
Throws:
LBPolicyFactoryException - if the policy cannot be constructed

getProperties

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

getProperty

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

getPropertyRawType

public static java.lang.reflect.Type getPropertyRawType(java.lang.Class<? extends org.ow2.carol.cmi.lb.policy.ILBPolicy> lbPolicyClass,
                                                        java.lang.String propertyName)
                                                 throws org.ow2.carol.cmi.lb.PropertyConfigurationException
Throws:
org.ow2.carol.cmi.lb.PropertyConfigurationException

getPropertyType

public static java.lang.reflect.Type getPropertyType(java.lang.Class<? extends org.ow2.carol.cmi.lb.policy.ILBPolicy> lbPolicyClass,
                                                     java.lang.String propertyName)
                                              throws org.ow2.carol.cmi.lb.PropertyConfigurationException
Throws:
org.ow2.carol.cmi.lb.PropertyConfigurationException

getPropertyData

public static java.util.Map<java.lang.String,LBPropertyData> getPropertyData(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

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


Copyright © 2008 OW2 Consortium. All Rights Reserved.