1 import java.lang.management.ManagementFactory ; 2 import java.util.ArrayList ; 3 import java.util.List ; 4 5 import javax.management.MBeanServer ; 6 import javax.management.ObjectName ; 7 8 import net.sf.dozer.util.mapping.DozerBeanMapper; 9 import net.sf.dozer.util.mapping.MapperIF; 10 import net.sf.dozer.util.mapping.jmx.DozerAdminController; 11 import net.sf.dozer.util.mapping.jmx.DozerStatisticsController; 12 import net.sf.dozer.util.mapping.util.MapperConstants; 13 import net.sf.dozer.util.mapping.util.TestDataFactory; 14 import net.sf.dozer.util.mapping.vo.SimpleObj; 15 import net.sf.dozer.util.mapping.vo.SimpleObjPrime2; 16 import net.sf.dozer.util.mapping.vo.TestObject; 17 import net.sf.dozer.util.mapping.vo.TestObjectPrime; 18 19 public class JMXTestEngine { 20 21 public static void main(String [] args) throws Exception { 22 System.setProperty(MapperConstants.CONFIG_FILE_SYS_PROP, "samplecustomdozer.properties"); 23 MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); 24 ObjectName name = new ObjectName ("com.example.mbeans:type=DozerStatisticsController"); 25 ObjectName name2 = new ObjectName ("com.example.mbeans:type=DozerAdminController"); 26 DozerStatisticsController mbean = new DozerStatisticsController(); 27 DozerAdminController mbean2 = new DozerAdminController(); 28 29 mbs.registerMBean(mbean, name); 30 mbs.registerMBean(mbean2, name2); 31 performSomeMappings(); 32 33 System.out.println("Waiting forever..."); 34 Thread.sleep(Long.MAX_VALUE); 35 } 36 37 private static void performSomeMappings() { 38 List mappingFiles = new ArrayList (); 39 mappingFiles.add("dozerBeanMapping.xml"); 40 MapperIF mapper = new DozerBeanMapper(mappingFiles); 41 42 try { 43 mapper.map(new String ("yo"), new String ("y")); 44 } catch (Throwable t) { 45 } 46 47 try { 48 mapper.map(null, null); 49 } catch (Throwable t) { 50 } 51 try { 52 mapper.map(new String (),null); 53 } catch (Throwable t) { 54 } 55 56 TestObject to = TestDataFactory.getInputGeneralMappingTestObject(); 57 TestObjectPrime prime = (TestObjectPrime) mapper.map(to, TestObjectPrime.class); 58 TestObject source = (TestObject) mapper.map(prime, TestObject.class); 59 mapper.map(source, TestObjectPrime.class); 60 61 int numIters = 4000; 62 for (int i=0;i<numIters;i++) { 63 SimpleObj src = (SimpleObj) TestDataFactory.getSimpleObj(); 64 mapper.map(src, SimpleObjPrime2.class); 65 } 66 } 67 } 68 | Popular Tags |