public Object newInstance (String clazz) throws Exception { return getFactory().newInstance (clazz); } }
protected void initStatusListeners (Element config) throws ConfigurationException{ final Iterator iter = config.getChildren ("status-listener").iterator(); while (iter.hasNext()) { final Element e = (Element) iter.next(); final QFactory factory = getFactory(); final TransactionStatusListener listener = (TransactionStatusListener) factory.newInstance (e.getAttributeValue ("class")); factory.setConfiguration (listener, config); addListener(listener); } }
private Collection<ISORequestListener> getListeners(QServer server) throws ConfigurationException { QFactory factory = server.getFactory(); @SuppressWarnings("rawtypes") Iterator iter = server.getPersist().getChildren("request-listener").iterator(); Collection<ISORequestListener> listeners = new ArrayList<ISORequestListener>(); while (iter.hasNext()) { Element l = (Element) iter.next(); ISORequestListener listener = (ISORequestListener) factory.newInstance(l.getAttributeValue("class")); factory.setLogger(listener, l); factory.setConfiguration(listener, l); listeners.add(listener); } return listeners; }
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; }
private void addListeners () throws ConfigurationException { QFactory factory = getFactory (); Iterator iter = getPersist().getChildren ( "request-listener" ).iterator(); while (iter.hasNext()) { Element l = (Element) iter.next(); ISORequestListener listener = (ISORequestListener) factory.newInstance (l.getAttributeValue ("class")); factory.setLogger (listener, l); factory.setConfiguration (listener, l); server.addISORequestListener (listener); } }
private void addISOServerConnectionListeners() throws ConfigurationException { QFactory factory = getFactory (); Iterator iter = getPersist().getChildren ( "connection-listener" ).iterator(); while (iter.hasNext()) { Element l = (Element) iter.next(); ISOServerEventListener listener = (ISOServerEventListener) factory.newInstance (l.getAttributeValue ("class")); factory.setLogger (listener, l); factory.setConfiguration (listener, l); server.addServerEventListener(listener); } }
private void addListeners () throws ConfigurationException { QFactory factory = getFactory (); Iterator iter = getPersist().getChildren ( "request-listener" ).iterator(); while (iter.hasNext()) { Element l = (Element) iter.next(); ISORequestListener listener = (ISORequestListener) factory.newInstance (l.getAttributeValue ("class")); factory.setLogger (listener, l); factory.setConfiguration (listener, l); addISORequestListener (listener); } } public void addISORequestListener(ISORequestListener l) {
protected void initService () throws Exception { QFactory factory = getServer().getFactory(); Element e = getPersist (); task = (Runnable) factory.newInstance (e.getChildTextTrim ("class")); factory.setLogger (task, e); } protected void startService () throws Exception {
protected void initService () throws Exception { QFactory factory = getServer().getFactory(); Element e = getPersist (); task = factory.newInstance (e.getChildTextTrim ("class")); factory.setLogger (task, e); } protected void startService () throws Exception {
protected void initService () throws Exception { Element e = getPersist (); QFactory factory = getServer().getFactory(); sm = (SMAdapter) factory.newInstance (getImpl ()); factory.setLogger (sm, e); factory.setConfiguration (sm, e); }
private void addFilters (FilteredChannel channel, Element e, QFactory fact) throws ConfigurationException { for (Object o : e.getChildren("filter")) { Element f = (Element) o; String clazz = f.getAttributeValue("class"); ISOFilter filter = (ISOFilter) fact.newInstance(clazz); fact.setLogger(filter, f); fact.setConfiguration(filter, f); String direction = f.getAttributeValue("direction"); if (direction == null) channel.addFilter(filter); else if ("incoming".equalsIgnoreCase(direction)) channel.addIncomingFilter(filter); else if ("outgoing".equalsIgnoreCase(direction)) channel.addOutgoingFilter(filter); else if ("both".equalsIgnoreCase(direction)) { channel.addIncomingFilter(filter); channel.addOutgoingFilter(filter); } } }
protected void addFilters (FilteredChannel channel, Element e, QFactory fact) throws ConfigurationException { for (Object o : e.getChildren("filter")) { Element f = (Element) o; String clazz = f.getAttributeValue("class"); ISOFilter filter = (ISOFilter) fact.newInstance(clazz); fact.setLogger(filter, f); fact.setConfiguration(filter, f); String direction = f.getAttributeValue("direction"); if (direction == null) channel.addFilter(filter); else if ("incoming".equalsIgnoreCase(direction)) channel.addIncomingFilter(filter); else if ("outgoing".equalsIgnoreCase(direction)) channel.addOutgoingFilter(filter); else if ("both".equalsIgnoreCase(direction)) { channel.addIncomingFilter(filter); channel.addOutgoingFilter(filter); } } }
private void addServerSocketFactory () throws ConfigurationException { QFactory factory = getFactory (); Element persist = getPersist (); Element serverSocketFactoryElement = persist.getChild ("server-socket-factory"); if (serverSocketFactoryElement != null) { ISOServerSocketFactory serverSocketFactory = (ISOServerSocketFactory) factory.newInstance (serverSocketFactoryElement.getAttributeValue ("class")); factory.setLogger (serverSocketFactory, serverSocketFactoryElement); factory.setConfiguration (serverSocketFactory, serverSocketFactoryElement); server.setSocketFactory(serverSocketFactory); } }
default void addExceptionHandlers(ExceptionHandlerAware receiver, Element elem, QFactory fact) throws ConfigurationException { for (Element o : elem.getChildren("exception-handler")) { String clazz = o.getAttributeValue("class"); ExceptionHandler handler = (ExceptionHandler) fact.newInstance(clazz); fact.setLogger(handler, o); fact.setConfiguration(handler, o); String exception = o.getAttributeValue("exception"); if (exception == null) { receiver.addHandler(handler); } else { Class<? extends Exception> exceptionClass; try { exceptionClass = (Class<? extends Exception>) Class.forName(exception); } catch (Exception e) { throw new ConfigurationException(exception, e); } receiver.addHandler(handler, exceptionClass); } } } }
protected void initService () throws Exception { Element e = getPersist (); QFactory factory = getServer().getFactory(); ks = (SecureKeyStore) factory.newInstance (getImpl ()); factory.setLogger (ks, e); factory.setConfiguration (ks, e); NameRegistrar.register (getName (), ks); }
private void registerTask (Element e) throws ConfigurationException { QFactory qf = getServer().getFactory(); Object obj = qf.newInstance (e.getChildTextTrim ("class")); if (!(obj instanceof MonitorTask)) { throw new ConfigurationException ( obj.toString() + " is not an instance of MonitorTask" ); } qf.setLogger (obj, e); qf.setConfiguration (obj, e); timer.schedule ( new MonitorTimerTask ( e.getAttributeValue("id"), (MonitorTask) obj), getLong (e.getAttributeValue ("delay")), getLong (e.getAttributeValue ("period")) ); } private long getLong (String l)
public void startService () throws Exception { Element config = getPersist (); String provider = config.getAttributeValue ("provider", "org.jpos.ui.UI"); ui = (org.jpos.ui.UI) getFactory().newInstance (provider); ui.setConfig (config); ui.setLog (getLog ()); ui.setObjectFactory (this); ui.configure (); NameRegistrar.register (getName(), ui); }
public void initChannel () throws ConfigurationException { Element persist = getPersist (); Element e = persist.getChild ("channel"); if (e == null) throw new ConfigurationException ("channel element missing"); channel = newChannel (e, getFactory()); String socketFactoryString = getSocketFactory(); if (socketFactoryString != null && channel 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)channel).setSocketFactory(sFac); } } private ISOChannel newChannel (Element e, QFactory f)
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 {
protected void initService () throws Exception { QFactory factory = getServer().getFactory(); dirPoll = createDirPoll(); dirPoll.setPath (getPath ()); dirPoll.setThreadPool (new ThreadPool (1, poolSize)); dirPoll.setPollInterval (pollInterval); if (priorities != null) dirPoll.setPriorities (priorities); dirPoll.setLogger (getLog().getLogger(), getLog().getRealm ()); Configuration cfg = factory.getConfiguration (getPersist()); dirPoll.setConfiguration (cfg); dirPoll.createDirs (); Object dpp = factory.newInstance (getProcessor()); if (dpp instanceof LogSource) { ((LogSource) dpp).setLogger ( getLog().getLogger(), getLog().getRealm () ); } if (dpp instanceof Configurable) { ((Configurable) dpp).setConfiguration (cfg); } dirPoll.setProcessor (dpp); }