@Test public void testLocatorWithSystemPropertyAndTimeout() { long timeout = 1000; System.setProperty(OsgiLocator.TIMEOUT, Long.toString(timeout)); System.setProperty("Factory", "org.apache.karaf.specs.locator.MockCallable"); Class clazz = OsgiLocator.locate(Object.class, "Factory"); assertNotNull("Expected to find a class", clazz); assertEquals("Got the wrong class.", MockCallable.class.getName(), clazz.getName()); System.setProperty("Factory", "org.apache.karaf.specs.locator"); long t0 = System.currentTimeMillis(); clazz = OsgiLocator.locate(Object.class, "Factory"); long t1 = System.currentTimeMillis(); assertNull("Did not expect to find a class", clazz); assertTrue("Timeout issue", (t1 - t0) > timeout / 2); }
public static <T> Class<T> locate(Class<T> factoryId) { return locate(factoryId, factoryId.getName()); }
OsgiLocator { public static <T> Class<T> locate(Class<T> factoryId) { return locate(factoryId, factoryId.getName()); } }
OsgiLocator { public static <T> Class<T> locate(Class<T> factoryId) { return locate(factoryId, factoryId.getName()); } private  OsgiLocator(); }
OsgiLocator { public static <T> Class<T> locate(Class<T> factoryId) { return locate(factoryId, factoryId.getName()); } private  OsgiLocator(); static void unregister(String id, Callable<Class> factory); static void register(String id, Callable<Class> factory); static Class<T> locate(Class<T> factoryId); static Class<T> locate(Class<T> factoryClass, String factoryId); static List<Class<? extends T>> locateAll(Class<T> factoryId); static List<Class<? extends T>> locateAll(Class<T> factoryClass, String factoryId); }
OsgiLocator { public static <T> Class<T> locate(Class<T> factoryId) { return locate(factoryId, factoryId.getName()); } private  OsgiLocator(); static void unregister(String id, Callable<Class> factory); static void register(String id, Callable<Class> factory); static Class<T> locate(Class<T> factoryId); static Class<T> locate(Class<T> factoryClass, String factoryId); static List<Class<? extends T>> locateAll(Class<T> factoryId); static List<Class<? extends T>> locateAll(Class<T> factoryClass, String factoryId); static final long DEFAULT_TIMEOUT; static final String TIMEOUT; }