PortFactory { public static Port createPhysicalBus(String clazz) { try { Class<?> c = Thread.currentThread().getContextClassLoader().loadClass(clazz); if (Port.class.isAssignableFrom(c)) { return (Port) c.newInstance(); } else { return null; } } catch (Exception e) { log.error("Could not instantiate PhysicalBus : {0}", e, e.getMessage()); return null; } }  static Port createPhysicalBus(String clazz); final static String PORT_LOG_CATEGORY; }
@Test public void testCreatePhysicalBus() throws ClassNotFoundException, InstantiationException, IllegalAccessException { Port b = PortFactory .createPhysicalBus("org.openremote.controller.protocol.port.DatagramSocketPort"); Assert.assertTrue(b instanceof Port); }