throw new ConfigurationException (ex.getMessage());
/** * 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; }
public JComponent create (UI ui, Element e) { JTextArea textArea = new JTextArea (25, 80); String font = e.getAttributeValue ("font"); if (font != null) textArea.setFont (Font.decode (font)); textArea.setBackground(Color.black); textArea.setForeground(Color.white); String logId = e.getAttributeValue ("logger", "Q2"); try { int maxEvents = Integer.parseInt ( e.getAttributeValue ("max-events", "100") ); int maxLines = Integer.parseInt ( e.getAttributeValue ("max-lines", "1000") ); LogProducer logger = (LogProducer) NameRegistrar.get ("logger." + logId); logger.addListener ( new Listener (logger, ui, textArea, maxEvents, maxLines) ); } catch (NameRegistrar.NotFoundException ex) { textArea.setText (ex.toString ()); } return textArea; } public static class Listener implements LogListener, Runnable {
/** * 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; }
private Map<String,Object> muxInfo (Route r, String path) { try { return muxInfo((QMUX) QMUX.getMUX((String) r.parameters(path).get("muxname"))); } catch (NameRegistrar.NotFoundException e) { return mapOf("error", e.getMessage() + " not found"); } }
public void setConfiguration (Configuration cfg) throws ConfigurationException { try { cs = NameRegistrar.get(cfg.get("crypto-service", "crypto-service")); } catch (NameRegistrar.NotFoundException e) { throw new ConfigurationException(e.getMessage()); } } }
public void setConfiguration (Configuration cfg) throws ConfigurationException { try { cs = NameRegistrar.get(cfg.get("crypto-service", "crypto-service")); } catch (NameRegistrar.NotFoundException e) { throw new ConfigurationException(e.getMessage()); } } }
@Test public void testAddChannelThrowsNotFoundException() throws Throwable { ChannelPool channelPool = new ChannelPool(); try { channelPool.addChannel("testChannelPoolName1"); fail("Expected NotFoundException to be thrown"); } catch (NameRegistrar.NotFoundException ex) { assertEquals("ex.getMessage()", "channel.testChannelPoolName1", ex.getMessage()); assertEquals("channelPool.pool.size()", 0, channelPool.pool.size()); } }
@Test public void testGetMUXThrowsNotFoundException() throws Throwable { try { QMUX.getMUX("testQMUXName"); fail("Expected NotFoundException to be thrown"); } catch (NameRegistrar.NotFoundException ex) { assertEquals("ex.getMessage()", "mux.testQMUXName", ex.getMessage()); } }
@Test public void testRemoveChannelThrowsNotFoundException() throws Throwable { ChannelPool channelPool = new ChannelPool(); try { channelPool.removeChannel("testChannelPoolName1"); fail("Expected NotFoundException to be thrown"); } catch (NameRegistrar.NotFoundException ex) { assertEquals("ex.getMessage()", "channel.testChannelPoolName1", ex.getMessage()); assertEquals("channelPool.pool.size()", 0, channelPool.pool.size()); } }
public JComponent create(UI ui, Element e) { try { TransactionManager tm = (TransactionManager) NameRegistrar.get (e.getAttributeValue ("transaction-manager")); return new TMMonitor (ui, tm); } catch (NameRegistrar.NotFoundException ex) { return new JTextArea (ex.toString()); } } }
@Test public void testNotFoundExceptionConstructor1() throws Throwable { NameRegistrar.NotFoundException notFoundException = new NameRegistrar.NotFoundException("testNotFoundExceptionDetail"); assertEquals("notFoundException.getMessage()", "testNotFoundExceptionDetail", notFoundException.getMessage()); } }
@Test public void testGetServerThrowsNotFoundException() throws Throwable { try { ISOServer.getServer("testISOServerName"); fail("Expected NotFoundException to be thrown"); } catch (NameRegistrar.NotFoundException ex) { assertEquals("ex.getMessage()", "server.testISOServerName", ex.getMessage()); } } }
@Test public void testGetSMAdapterThrowsNotFoundException() throws Throwable { try { BaseSMAdapter.getSMAdapter("14CharactersXX"); fail("Expected NotFoundException to be thrown"); } catch (NameRegistrar.NotFoundException ex) { assertEquals("ex.getMessage()", "s-m-adapter.14CharactersXX", ex.getMessage()); } }