org.oddjob.values.types
Class MagicClassType

java.lang.Object
  extended by org.oddjob.values.types.MagicClassType
All Implemented Interfaces:
ArooaValue, ValueFactory<ArooaClass>

public class MagicClassType
extends Object
implements ValueFactory<ArooaClass>

Description

Definition for a Magic Bean, which is a bean that can be defined dynamically.

See also MagicBeanDescriptorFactory.

Example

Using a magic-class to create a magic bean.
<oddjob>
    <job>
        <sequential>
            <jobs>
                <variables id="vars">
                    <myClass>
                        <magic-class name="fruit">
                            <properties>
                                <value key="type" value="java.lang.String"/>
                                <value key="quantity" value="java.lang.Integer"/>
                            </properties>
                        </magic-class>
                    </myClass>
                    <myBean>
                        <convert>
                            <value>
                                <bean class="org.oddjob.values.types.MagicBeanType">
                                    <magicClass>
                                        <value value="${vars.myClass}"/>
                                    </magicClass>
                                    <properties>
                                        <value key="type" value="Apple"/>
                                        <value key="quantity" value="24"/>
                                    </properties>
                                </bean>
                            </value>
                        </convert>
                    </myBean>
                </variables>
                <echo id="e">We have ${vars.myBean.is.quantity} ${vars.myBean.is.type}(s).</echo>
            </jobs>
        </sequential>
    </job>
</oddjob>
Author:
rob

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.oddjob.arooa.types.ValueFactory
ValueFactory.Conversions
 
Constructor Summary
MagicClassType()
           
 
Method Summary
 ClassLoader getClassLoader()
           
 String getName()
           
 String getProperties(String key)
           
 void setClassLoader(ClassLoader classLoader)
           
 void setName(String name)
           
 void setProperties(String key, String className)
           
 String toString()
           
 ArooaClass toValue()
          Provide an instance of the type this is a factory for.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MagicClassType

public MagicClassType()
Method Detail

getName

public String getName()

setName

public void setName(String name)

setProperties

public void setProperties(String key,
                          String className)

getProperties

public String getProperties(String key)

getClassLoader

public ClassLoader getClassLoader()

setClassLoader

@Inject
public void setClassLoader(ClassLoader classLoader)

toValue

public ArooaClass toValue()
                   throws ArooaConversionException
Description copied from interface: ValueFactory
Provide an instance of the type this is a factory for.

Specified by:
toValue in interface ValueFactory<ArooaClass>
Returns:
An instance of the type. May be null.
Throws:
ArooaConversionException - If unable to provide a value.

toString

public String toString()
Overrides:
toString in class Object