cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Davide <dagar...@aliceposta.it>
Subject How to compile an action?
Date Tue, 30 Dec 2003 11:15:21 GMT
Hi,  im'reading the Langham, Ziegler book and i'm trying to compile the 
first action:

package cxa.acting;

import org.apache.avalon.framework.activity.Initializable;
import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.avalon.framework.logger.AbstractLoggable;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.cocoon.acting.Action;
import org.apache.cocoon.environment.Redirector;
import org.apache.cocoon.environment.SourceResolver;

import java.util.HashMap;
import java.util.Map;
import java.util.Random;

public class RandomAction
   extends AbstractLoggable
   implements Action, Initializable, ThreadSafe {

     protected Random generator;

     /**
      * Initialize this component
      */
     public void initialize() {
         // create a random generator
         this.generator = new Random( System.currentTimeMillis() );
     }

     public Map act(Redirector redirector,
                    SourceResolver resolver,
                    Map objectModel,
                    String src,
                    Parameters parameters)
     throws Exception {
         // get the range
         int min = parameters.getParameterAsInteger("min", 0);
         int max = parameters.getParameterAsInteger("max", 100);

         int random = this.generator.nextInt(max - min + 1) + min;

         if ( this.getLogger().isDebugEnabled() ) {
             this.getLogger().debug("Generated random between " + min + " 
and " + max + " : " + random);
         }

         // build resulting map
         Map map = new HashMap(1);
         map.put("number", "" + random);
         return map;
     }

}

I saved it as RandomAction.java and then...???
When i try to compile the action it gives me a lot of error probably 
because the classpath is not set correctly...
my classpath is:
CLASSPATH=C:\Program Files\j2sdk1.4.2_01\lib;C:\Program 
Files\jakarta-tomcat-5.0.16\webapps\cocoon\WEB-INF\lib

what is wrong??

thanks a lot

regards. 
Mime
View raw message