/** * Try to invoke a method (usually a setter) on the given object * silently ignoring if method does not exist * @param obj the object * @param m method to invoke * @param p parameter * @throws ConfigurationException if method happens to throw an exception */ public static void invoke (Object obj, String m, Object p) throws ConfigurationException { invoke (obj, m, p, p != null ? p.getClass() : null); }
public void stopService() { Iterator keys = privateList.keySet().iterator(); while (keys.hasNext()) { Element bean = (Element) privateList.get(keys.next()); String id = bean.getAttributeValue("id");// id and key are same Object beanInstance=beanMap.remove(id); String stopMethod = bean.getAttributeValue("stop-method"); if(beanInstance!=null && stopMethod!=null){ try{ QFactory.invoke(beanInstance, stopMethod, null); }catch(Exception e){ log.warn(e); } } } }
public TransactionParticipant createParticipant (Element e) throws ConfigurationException { QFactory factory = getFactory(); TransactionParticipant participant = (TransactionParticipant) factory.newInstance (e.getAttributeValue ("class") ); factory.setLogger (participant, e); QFactory.invoke (participant, "setTransactionManager", this, TransactionManager.class); factory.setConfiguration (participant, e); String realm = e.getAttributeValue("realm"); if (realm != null && realm.trim().length() > 0) realm = ":" + realm; else realm = ""; names.put(participant, Caller.shortClassName(participant.getClass().getName())+realm); if (participant instanceof Destroyable) { destroyables.add((Destroyable) participant); } return participant; }
@Test public void testInvoke3() throws Throwable { QFactory.invoke("", "testQFactorym", ""); assertTrue("Test completed without Exception", true); }
@Test public void testInvoke1() throws Throwable { QFactory.invoke(null, "testQFactorym", "testString", Integer.class); assertTrue("Test completed without Exception", true); }
@Test public void testInvoke2() throws Throwable { QFactory.invoke("", "testQFactorym", null); assertTrue("Test completed without Exception", true); }
@Test public void testInvoke() throws Throwable { QFactory.invoke("", "testQFactorym", "testString", Integer.class); assertTrue("Test completed without Exception", true); }
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; }
private ISOChannel newChannel (Element e, QFactory f) throws ConfigurationException { String channelName = e.getAttributeValue ("class"); if (channelName == null) throw new ConfigurationException ("class attribute missing from channel element."); 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 (getName () != null) channel.setName (getName ()+id); return channel; }
f.setConfiguration(packager, e); QFactory.invoke(channel, "setHeader", e.getAttributeValue("header")); f.setLogger(channel, e); f.setConfiguration(channel, e);