commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark R. Diggory" <mdigg...@latte.harvard.edu>
Subject Implementing my project in Jelly.
Date Sat, 07 Dec 2002 18:54:01 GMT
Here's my project (currently being developed in Ant).

I have a set of tasks that map to a set of classes available in a 
package used for random number generation.

For example

"cern.jet.random.Uniform.java"

gets wrapped by

"org.mrd.ant.distributions.Uniform.java"

so that a Uniform random number generator gets created and the value of 
uniform.nextDouble() gets loaded into the Ant project properties.

project.setProperty(this.getName(), Double.toString(uniform.nextDouble()));

This gets used in an ant script like this:


<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="pva_analysis" name="PVA Batch Example">
         <taskdef name="uniform" 
classname="org.mrd.ant.distributions.Uniform">
	...
	</taskdef>

	<target name="xxx">
	   <batch ...>
		<uniform name="rngSeed" min="0"/>
	...

which sets a property in the project (I built a batch task that 
basically is a for-loop to increment this value).



My reasons for wanting to move to Jelly are that I actually want to make 
the random number generator itself available in the project and be able 
to draw random numbers from it more like this:

<j:jelly xmlns:j="jelly:core" 
xmlns:dist="jelly:org.mrd.ant.distributions.MyTagLibrary">

   <dist:uniform name="rngSeed" min="0"/>

   <j:set var="cnt1" value="0"/>
   <j:while test="${cnt1 != 5}">
        <j:set var="cnt1" value="${cnt1 + 1}"/>
        <foo:simulation seed="${rngSeed.nextDouble()}">
   	   ...
        </foo:simulation>
   </j:while>

</j:jelly>

I see an example of this in the swing demo, but what I also see is that 
the name of the bean is also the name of the tag.

<frame title="This...">
...
</frame>

${frame.show()}

instead of an attribute value (which is what I'm trying to do).

<dist:uniform name="rngSeed" min="0"/>

${rngSeed.nextDouble()}


My question is: Is this possible?

Also, I notice that the SwingTagLibrary uses a Bean Factory to create 
the "frame" class behind the frame tag using these methods...

     /**
      * Register a widget factory for the given element name
      */
     protected void registerFactory(String name, Factory factory) {
         getFactoryMap().put(name, factory);
     }

     /**
      * Register a bean factory for the given element name and class
      */
     protected void registerBeanFactory(String name, Class beanClass) {
         registerFactory(name, new BeanFactory(beanClass));
     }

How does the "frame" get made available in the script?

-Mark




Mime
View raw message