1 8 9 package mx4j.examples.mbeans.helloworld; 10 11 import java.io.FileNotFoundException ; 12 import java.io.IOException ; 13 import java.io.InputStream ; 14 import java.util.Properties ; 15 16 26 public class HelloWorld implements HelloWorldMBean 27 { 28 private int m_times; 29 private Properties m_configuration; 30 31 public String getInfoFromConfiguration(String key) 32 { 33 synchronized (this) 35 { 36 return m_configuration.getProperty(key); 37 } 38 } 39 40 public void reloadConfiguration() throws IOException  41 { 42 String configuration = "jndi.properties"; 44 InputStream is = getClass().getClassLoader().getResourceAsStream(configuration); 45 if (is == null) 46 { 47 throw new FileNotFoundException ("Cannot find " + configuration + " file in classpath"); 48 } 49 50 Properties p = new Properties (); 52 p.load(is); 53 54 synchronized (this) 56 { 57 m_configuration = p; 58 ++m_times; 59 } 60 } 61 62 public int getHowManyTimes() 63 { 64 return m_times; 65 } 66 } 67 | Popular Tags |