[Index]

arooa:magic-beans


Define Magic Beans. Magic Beans are beans who's properties can be defined dynamically. Magic beans are useful when you want to collect information in one bean so it can be kept together.

Property Summary

definitions Definitions for Magic Beans.
namespace The namespace for the magic bean element.
prefix The element prefix.

Example Summary

Example 1 Creating a magic bean that define some file information.

Property Detail

definitions

Configured ByELEMENT
AccessREAD_WRITE

Definitions for Magic Beans. This will be a list of org.oddjob.arooa.beanutils.MagicBeanDefinitions.

namespace

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNo.

The namespace for the magic bean element.

prefix

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNo.

The element prefix.


Examples

Example 1

Creating a magic bean that define some file information.

This is an outer Oddjob configuration file that creates the descriptor that defines properties for a filespec element.

<oddjob id="this">
    <job>
        <oddjob file="${this.dir}/MagicBeansInner.xml">
            <descriptorFactory>
                <arooa:magic-beans namespace="oddjob:magic" prefix="magic" xmlns:arooa="http://rgordon.co.uk/oddjob/arooa">
                    <definitions>
                        <is element="filespec">
                            <properties>
                                <is name="description" type="java.lang.String"/>
                                <is name="file" type="java.io.File" configured="ATTRIBUTE"/>
                                <is name="maxSize" type="java.lang.Long"/>
                            </properties>
                        </is>
                    </definitions>
                </arooa:magic-beans>
            </descriptorFactory>
        </oddjob>
    </job>
</oddjob>
The nested inner Oddjob configuration uses a list of filespec magic beans to define information for a For Each job.
<oddjob>
  <job>
    <foreach>
      <values>
        <list>
          <values>
            <magic:filespec description="Big File" file="/files/big" maxSize="1000000" xmlns:magic="oddjob:magic"/>
            <magic:filespec description="Medium File" file="/files/medium" maxSize="20000" xmlns:magic="oddjob:magic"/>
            <magic:filespec description="Small File" file="/files/small" maxSize="3000" xmlns:magic="oddjob:magic"/>
          </values>
        </list>
      </values>
      <configuration>
        <xml>
          <foreach id="each">
            <job>
              <echo>
Checking ${each.current.description} (${each.current.file})
less than ${each.current.maxSize} bytes...</echo>
            </job>
          </foreach>
        </xml>
      </configuration>
    </foreach>
  </job>
</oddjob>
The example will display the following when ran:
 Checking Big File (\files\big)
 less than 1000000 bytes...

 Checking Medium File (\files\medium)
 less than 20000 bytes...
 
 Checking Small File (\files\small)
 less than 3000 bytes...
 


(c) R Gordon Ltd 2005 - Present