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

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

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

Define a factory to construct policies.

Author:
The new CMI team

Constructor Summary
PolicyFactory(org.ow2.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.cmi.lb.policy.IPolicy> policyClass, java.lang.String propertyName, 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.cmi.lb.policy.IPolicy> policyClass, java.lang.String propertyName, java.util.List<java.lang.String> slist)
           
 org.ow2.cmi.lb.policy.IPolicy<T> createPolicy(java.lang.Class<? extends org.ow2.cmi.lb.policy.IPolicy> policyClass)
          Returns a pure policy for a given class.
 org.ow2.cmi.lb.policy.IPolicy<T> getPolicy(java.lang.Class<? extends org.ow2.cmi.lb.policy.IPolicy> policyClass, java.lang.Class<? extends org.ow2.cmi.lb.strategy.IStrategy> strategyClass, java.util.Map<java.lang.String,?> properties)
          Returns a policy for the given classes of policy, strategy and properties.
 org.ow2.cmi.lb.policy.IPolicy<T> getPolicy(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.cmi.lb.policy.IPolicy<?> policy)
           
static java.lang.Object getProperty(org.ow2.cmi.lb.policy.IPolicy<?> policy, java.lang.String propertyName)
           
static java.util.Map<java.lang.String,PropertyData> getPropertyData(java.lang.Class<? extends org.ow2.cmi.lb.policy.IPolicy> policyClass)
           
static java.lang.reflect.Type getPropertyRawType(java.lang.Class<? extends org.ow2.cmi.lb.policy.IPolicy> policyClass, java.lang.String propertyName)
           
static java.lang.reflect.Type getPropertyType(java.lang.Class<? extends org.ow2.cmi.lb.policy.IPolicy> policyClass, java.lang.String propertyName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PolicyFactory

public PolicyFactory(org.ow2.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

getPolicy

public org.ow2.cmi.lb.policy.IPolicy<T> getPolicy(java.lang.String objectName)
                                                                                  throws PolicyFactoryException,
                                                                                         org.ow2.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:
PolicyFactoryException - if the policy cannot be constructed
org.ow2.cmi.reference.ObjectNotFoundException - if none object has the given name

getPolicy

public org.ow2.cmi.lb.policy.IPolicy<T> getPolicy(java.lang.Class<? extends org.ow2.cmi.lb.policy.IPolicy> policyClass,
                                                  java.lang.Class<? extends org.ow2.cmi.lb.strategy.IStrategy> strategyClass,
                                                  java.util.Map<java.lang.String,?> properties)
                                                                                  throws PolicyFactoryException
Returns a policy for the given classes of policy, strategy and properties.

Parameters:
policyClass -
strategyClass -
properties -
Returns:
a policy to access to the object with the given name
Throws:
PolicyFactoryException - if the policy cannot be constructed

createPolicy

public org.ow2.cmi.lb.policy.IPolicy<T> createPolicy(java.lang.Class<? extends org.ow2.cmi.lb.policy.IPolicy> policyClass)
                                                                                     throws PolicyFactoryException
Returns a pure policy for a given class.

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

getProperties

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

getProperty

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

getPropertyRawType

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

getPropertyType

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

getPropertyData

public static java.util.Map<java.lang.String,PropertyData> getPropertyData(java.lang.Class<? extends org.ow2.cmi.lb.policy.IPolicy> policyClass)
                                                                    throws org.ow2.cmi.lb.PropertyConfigurationException
Throws:
org.ow2.cmi.lb.PropertyConfigurationException

convertString

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

Parameters:
propertyName - the property name
svalue - a value
Returns:
an object that has the same that the given field
Throws:
org.ow2.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.cmi.lb.PropertyConfigurationException
Throws:
org.ow2.cmi.lb.PropertyConfigurationException

convertStrings

public static java.util.List<?> convertStrings(java.lang.Class<? extends org.ow2.cmi.lb.policy.IPolicy> policyClass,
                                               java.lang.String propertyName,
                                               java.util.List<java.lang.String> slist)
                                        throws org.ow2.cmi.lb.PropertyConfigurationException
Throws:
org.ow2.cmi.lb.PropertyConfigurationException


Copyright © 2009 OW2 Consortium. All Rights Reserved.