/** * Retrieves a thread pool executor from NameRegistrar given its name, and * its expected class * * @param name * @param clazz * @throws NotFoundException */ @SuppressWarnings("unchecked") public static <T extends ThreadPoolExecutor> T getThreadPoolExecutor( java.lang.String name, Class<T> clazz) throws NotFoundException { T res = null; Object object = NameRegistrar.get(THREAD_POOL_EXECUTOR__QBEAN_PREFIX + name); if (clazz.isAssignableFrom(object.getClass())) { res = (T) object; } else { throw new NotFoundException(name); } return res; }
/** * Retrieves a thread pool executor from NameRegistrar given its name * * @param name * @throws NotFoundException */ public static ThreadPoolExecutor getThreadPoolExecutor(java.lang.String name) throws NotFoundException { ThreadPoolExecutor res = null; Object object = NameRegistrar.get(THREAD_POOL_EXECUTOR__QBEAN_PREFIX + name); if (object instanceof ThreadPoolExecutor) { res = (ThreadPoolExecutor) object; } else { throw new NotFoundException(name); } return res; }
/** * Get a value from the registry. * * @param <T> desired type of entry value. * @param key the key whose associated value is to be returned. * @return a value * @throws NotFoundException if key not present in registrar */ public static <T> T get(String key) throws NotFoundException { @SuppressWarnings("unchecked") T obj = (T) sp.rdp(key); if (obj == null) { throw new NotFoundException(key); } return obj; }
@Test public void testNotFoundExceptionConstructor1() throws Throwable { NameRegistrar.NotFoundException notFoundException = new NameRegistrar.NotFoundException("testNotFoundExceptionDetail"); assertEquals("notFoundException.getMessage()", "testNotFoundExceptionDetail", notFoundException.getMessage()); } }