private void newChannel () throws ConfigurationException { Element persist = getPersist (); Element e = persist.getChild ("channel"); if (e == null) { throw new ConfigurationException ("channel element missing"); } ChannelAdaptor adaptor = new ChannelAdaptor (); channel = adaptor.newChannel (e, getFactory ()); }
public String checkService () { boolean rc = false; ChannelAdaptor channel; try { channel = (ChannelAdaptor) NameRegistrar.get (serviceName); } catch (NameRegistrar.NotFoundException e) { return Status.ERROR + " channel '" + serviceName + "' not found."; } if (channel.isConnected()) return Status.OK + " Connected"; else return Status.ERROR + " Not connected"; } public String command (String command) {
public String command (String command) { String response = "Unknown command"; ChannelAdaptor channel; try { channel = (ChannelAdaptor) NameRegistrar.get (serviceName); } catch (NameRegistrar.NotFoundException e) { return "Channel '" + serviceName + "' not found"; } if ("STOP".equalsIgnoreCase (command)) { channel.stop(); response = "Channel stopped"; } else if ("START".equalsIgnoreCase (command)) { channel.start(); response = "Channel started"; } return response; } public void setConfiguration (Configuration cfg)
protected ISOChannel initChannel () throws ConfigurationException { Element persist = getPersist (); Element e = persist.getChild ("channel"); if (e == null) throw new ConfigurationException ("channel element missing"); ISOChannel c = newChannel (e, getFactory()); String socketFactoryString = getSocketFactory(); if (socketFactoryString != null && c instanceof FactoryChannel) { ISOClientSocketFactory sFac = (ISOClientSocketFactory) getFactory().newInstance(socketFactoryString); if (sFac != null && sFac instanceof LogSource) { ((LogSource) sFac).setLogger(log.getLogger(),getName() + ".socket-factory"); } getFactory().setConfiguration (sFac, e); ((FactoryChannel)c).setSocketFactory(sFac); } return c; } protected void initSpaceAndQueues () throws ConfigurationException {
private ChannelAdaptor configureAndStart(ChannelAdaptor channelAdaptor, LogListener... logListener) { Logger logger = new Logger(); for (LogListener listener : logListener) { logger.addListener(listener); } logger.setName("testLinkLogger"); channelAdaptor.setName(LINK_NAME); channelAdaptor.setLogger(logger.getName()); channelAdaptor.setPersist(createConfiguration()); channelAdaptor.init(); channelAdaptor.start(); return channelAdaptor; }
public void run () { Thread.currentThread().setName ("channel-sender-" + in); while (running ()){ try { checkConnection (); if (!running()) break; Object o = sp.in (in, delay); getLog().warn ("channel-sender-"+in, e.getMessage ()); } catch (ISOException e) { getLog().warn ("channel-sender-"+in, e.getMessage ()); if (!ignoreISOExceptions) { disconnect (); getLog().warn ("channel-sender-"+in, e.getMessage ()); disconnect (); ISOUtil.sleep (1000);
public ISOChannel newChannel (Element e, QFactory f) throws ConfigurationException { String channelName = e.getAttributeValue ("class"); String packagerName = e.getAttributeValue ("packager"); ISOChannel channel = (ISOChannel) f.newInstance (channelName); ISOPackager packager; if (packagerName != null) { packager = (ISOPackager) f.newInstance (packagerName); channel.setPackager (packager); f.setConfiguration (packager, e); } QFactory.invoke (channel, "setHeader", e.getAttributeValue ("header")); f.setLogger (channel, e); f.setConfiguration (channel, e); if (channel instanceof FilteredChannel) { addFilters ((FilteredChannel) channel, e, f); } if (channel instanceof ExceptionHandlerAware) { addExceptionHandlers((ExceptionHandlerAware) channel, e, f); } if (getName () != null) channel.setName (getName ()); return channel; }
@Test public void testDestroyQBeanThrowsNullPointerException1() throws Throwable { String[] args = new String[0]; Hashtable<String, String> hashtable = new Hashtable<String, String>(100, 100.0F); hashtable.put("testString", "testString"); try { new QFactory(ObjectName.getInstance("testQFactoryParam1", hashtable), null).destroyQBean(new Q2(args), new ObjectName( "testQFactoryParam1", "testQFactoryParam2", "testQFactoryParam3"), new ChannelAdaptor()); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { assertNull("ex.getMessage()", ex.getMessage()); } }
public Boolean call() throws Exception { Thread.currentThread().setName(STOP_CALLER_THREAD_NAME); channelAdaptor.stop(); return true; } });
public String getCountersAsString () { StringBuffer sb = new StringBuffer(); append (sb, "tx=", tx); append (sb, ", rx=", rx); append (sb, ", connects=", connects); sb.append (", last="); sb.append(lastTxn); if (lastTxn > 0) { sb.append (", idle="); sb.append(System.currentTimeMillis() - lastTxn); sb.append ("ms"); } return sb.toString(); } public int getTXCounter() {
private BaseChannel getChannel(QServer server) throws ConfigurationException { Element persist = server.getPersist(); Element e = persist.getChild("channel"); if (e == null) { throw new ConfigurationException("channel element missing"); } ChannelAdaptor adaptor = new ChannelAdaptor(); BaseChannel channel = (BaseChannel) adaptor.newChannel(e, server.getFactory()); if (channel == null) { throw new ConfigurationException("Could not instanciate ISOChannel"); } return channel; }
private void assertStopped(int run) { Set<Thread> threads = waitForExit(findSendAndReceiveThreads()); assertEquals("At run " + run + " both send and receive threads should have exited. Found:\n" + dump(threads), 0, threads.size()); assertFalse("At run " + run + " channel should not be connected", channelAdaptor.isConnected()); }