jfun.yan.etc
Class Beans

java.lang.Object
  extended by jfun.yan.etc.Beans

public class Beans
extends java.lang.Object

Helper functions for bean component including customizations of bean property resolution strategy. The default strategy is byType. byName, byDisplayName and byQualifiedName are provided in this class directly. More flexible policies can be implemented by using the resolveBy(jfun.yan.Component, FromProperty) method.

Codehaus.org.

Author:
Michelle Lei

Constructor Summary
Beans()
           
 
Method Summary
static Component beanComponent(Component cc, java.lang.String[] mandatory_params)
          Create a Component that makes the parameters mandatory properties and all java bean setters optional.
static Component byDisplayName(Component cc)
          resolve java bean properties by display name instead of the default "byType" policy.
static Component byName(Component cc)
          resolve java bean properties by name instead of the default "byType" policy.
static Component byQualifiedName(Component cc)
          resolve java bean properties by fully qualified name (class_name.property_name) instead of the default "byType" policy.
static Component byType(Component cc)
          resolve java bean properties by type.
static Component resolveBy(Component cc, java.lang.Class type, FromProperty pn)
          Customize the resolution mechanism for java bean properties using the result from a FromProperty object.
static Component resolveBy(Component cc, FromProperty pn)
          Customize the resolution mechanism for java bean properties using the result from a FromProperty object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Beans

public Beans()
Method Detail

resolveBy

public static Component resolveBy(Component cc,
                                  java.lang.Class type,
                                  FromProperty pn)
Customize the resolution mechanism for java bean properties using the result from a FromProperty object.

Parameters:
cc - the component.
type - the type of the java bean.
pn - the FromProperty object.
Returns:
the new Component.

resolveBy

public static Component resolveBy(Component cc,
                                  FromProperty pn)
Customize the resolution mechanism for java bean properties using the result from a FromProperty object.

Parameters:
cc - the component.
pn - the FromProperty object.
Returns:
the new Component.

byName

public static Component byName(Component cc)
resolve java bean properties by name instead of the default "byType" policy.

Parameters:
cc - the component.
Returns:
the new Component.

byType

public static Component byType(Component cc)
resolve java bean properties by type.

Parameters:
cc - the component.
Returns:
the new Component.

byDisplayName

public static Component byDisplayName(Component cc)
resolve java bean properties by display name instead of the default "byType" policy.

Parameters:
cc - the component.
Returns:
the new Component.

byQualifiedName

public static Component byQualifiedName(Component cc)
resolve java bean properties by fully qualified name (class_name.property_name) instead of the default "byType" policy.

Parameters:
cc - the component.
Returns:
the new Component.

beanComponent

public static Component beanComponent(Component cc,
                                      java.lang.String[] mandatory_params)
                               throws java.beans.IntrospectionException
Create a Component that makes the parameters mandatory properties and all java bean setters optional.
For a class whose constructor has two parameters, the two parameters will be made two mandatory properties under the provided property names; all the java bean setters will be made optional properties.
This way, mandatory properties can be expressed as parameters and optional properties can be represented as bean properties. Yet, configuration consistently uses named properties, avoiding confusion caused by position based parameters.

Parameters:
cc - the component that expects some mandatory parameters (such as a constructor or a static factory method)
mandatory_params - the property names to name the parameters.
Returns:
the new Component object that expects mandatory properties for the parameters and optioinal properties for the java bean properties.
Throws:
java.beans.IntrospectionException - When Java Bean Introspection fails.