com.ca.commons.jndi.beans
Interface JNDIBeanPropertyHandler

All Known Implementing Classes:
BooleanPropertyHandler, ByteDataPropertyHandler, CharacterPropertyHandler, DataModelBinaryPropertyHandler, EmailAddressPropertyHandler, EnumPropertyHandler, LdapNamePropertyHandler, MultiValuedAttribHandler, NumberPropertyHandler, StringPropertyHandler, URIPropertyHandler

public interface JNDIBeanPropertyHandler

A handler to translate JNDI attributes into Java Bean property values and vice versa. The behviour of some handlers can be altered by specifying "initialization properties" that specify parameters relevant to the handler. All classes implementing this interface should provide a no argument constructor.

A handler implementation is generally written to convert a set of JNDI attribute values to a single bean property value and vice versa. The size of the Attribute array passed to getPropertyValue and the size of the list returned by getAttributeValues should be the same. The size and order is determined by the attributes listed in the <property> mapping in the XML configuration.

For example, if a mapping like this is being used:

 <property>
    <name>foo</name>
    <attr>a</attr>
    <attr>b</attr>
    <attr>c</attr>
    <attr>d</attr>
 </property>

Then the getPropertyValue method will receive an array with four Attributes. attr[0] will be attribute "a", attr[1] attribute "b", etc. Similarly, getAttributeValues must return a List with four members, the first being the value of attribute "a", the second for "b", etc.

Author:
Lachlan O'Dea (odela01)
See Also:
JNDIBeanStoreFactory

Field Summary
static Logger logger
           
 
Method Summary
 List<?> getAttributeValues(Object value)
          Converts a Java Bean property value into one or more JNDI attribute values.
 Object getPropertyValue(Attribute[] attr)
          Converts a list of JNDI attributes into an object suitable for a Java Bean property value.
 void init(Properties props)
          Provides a set of properties to initialize the handler.
 

Field Detail

logger

static final Logger logger
Method Detail

init

void init(Properties props)
          throws JNDIBeanStoreConfigException
Provides a set of properties to initialize the handler. A handler implementation may alter aspects of its behaviour based on these properties. Each implementation must document what properties it expects (if any). This method is called once on each handler instance by JNDIBeanStoreFactory with the properties listed by its XML configuration data.

Parameters:
props - The properties to use for initialization.
Throws:
JNDIBeanStoreConfigException - If any of the properties were invalid in any way.

getPropertyValue

@Nullable
Object getPropertyValue(Attribute[] attr)
                        throws NamingException
Converts a list of JNDI attributes into an object suitable for a Java Bean property value. The handler implementation must document the number and nature of the attributes that it expects, as well as the type of the returned value. The Attributes in the array will appear in the order specified in the XML mapping.

Parameters:
attr - An array of JNDI attributes.
Returns:
An object of a type defined by the implementing class.
Throws:
NamingException - If an attribute's values could not be read.
JNDIBeanStoreException - If the attribute values could not be processed.

getAttributeValues

List<?> getAttributeValues(Object value)
                           throws JNDIBeanStoreException
Converts a Java Bean property value into one or more JNDI attribute values. The returned list must contain one element for each attribute mapped to the bean property, in the same order they appear in the XML mapping. If an attribute is multivalued, the corresponding element in the list should itself be a Collection.

Parameters:
value - The bean property value to be converted.
Returns:
A list where each element is the value of a corresponding JNDI attribute. Collection values will be converted to multivalued attributes.
Throws:
JNDIBeanStoreException - If the bean property value could not be processed.


Created 2011-07-14 13:27 EST