1 16 17 package tutorial; 18 19 import java.util.Random ; 20 21 import org.apache.avalon.framework.configuration.Configuration; 22 import org.apache.avalon.framework.configuration.ConfigurationException; 23 import org.apache.avalon.framework.configuration.Configurable; 24 import org.apache.avalon.framework.logger.AbstractLogEnabled; 25 26 32 public class RandomGeneratorProvider extends AbstractLogEnabled 33 implements Configurable, RandomGenerator 34 { 35 36 private Random m_random = null; 37 38 46 public void configure( Configuration config ) throws ConfigurationException 47 { 48 getLogger().info( "configuration stage" ); 49 long seed = config.getChild( "seed" ).getValueAsLong( 0 ); 50 getLogger().info( "seed: " + seed ); 51 m_random = new Random ( System.currentTimeMillis() * seed ); 52 } 53 54 58 public int getRandom() 59 { 60 return m_random.nextInt(); 61 } 62 } 63 | Popular Tags |