From 60263d5f0bf9f84506b59fc39614d1b034d48bb4 Mon Sep 17 00:00:00 2001 From: Barzilai Spinak Date: Thu, 22 Jan 2026 19:21:53 -0300 Subject: [PATCH 1/2] new QFactory method to instantiate from Element --- jpos/src/main/java/org/jpos/q2/QFactory.java | 73 ++++++++++++------- .../java/org/jpos/q2/iso/ChannelAdaptor.java | 10 +-- jpos/src/main/java/org/jpos/q2/iso/QMUX.java | 28 +++---- .../main/java/org/jpos/q2/iso/QServer.java | 58 +++++---------- 4 files changed, 80 insertions(+), 89 deletions(-) diff --git a/jpos/src/main/java/org/jpos/q2/QFactory.java b/jpos/src/main/java/org/jpos/q2/QFactory.java index 19e7db701c..38f9ce382a 100644 --- a/jpos/src/main/java/org/jpos/q2/QFactory.java +++ b/jpos/src/main/java/org/jpos/q2/QFactory.java @@ -62,7 +62,7 @@ public QFactory (ObjectName loaderName, Q2 q2) { } @SuppressWarnings("PMD.EmptyCatchBlock") - public Object instantiate (Q2 server, Element e) + public Object instantiate (Q2 server, Element e) throws ReflectionException, MBeanException, InstanceNotFoundException @@ -82,7 +82,7 @@ public Object instantiate (Q2 server, Element e) return mserver.instantiate (clazz, loaderName); } - public ObjectInstance createQBean (Q2 server, Element e, Object obj) + public ObjectInstance createQBean (Q2 server, Element e, Object obj) throws MalformedObjectNameException, InstanceAlreadyExistsException, InstanceNotFoundException, @@ -102,7 +102,7 @@ public ObjectInstance createQBean (Q2 server, Element e, Object obj) throw new InstanceAlreadyExistsException (name+" has already been deployed in another file."); } ObjectInstance instance = mserver.registerMBean ( - obj, objectName + obj, objectName ); try { setAttribute (mserver, objectName, "Name", name); @@ -115,7 +115,7 @@ public ObjectInstance createQBean (Q2 server, Element e, Object obj) setAttribute (mserver, objectName, "Server", server); setAttribute (mserver, objectName, "Persist", e); configureQBean(mserver,objectName,e); - setConfiguration (obj, e); // handle legacy (QSP v1) Configurables + setConfiguration (obj, e); // handle legacy (QSP v1) Configurables if (obj instanceof QBean) mserver.invoke (objectName, "init", null, null); @@ -140,8 +140,7 @@ private void getExtraPath (QClassLoader loader, Element e) { } catch (Throwable t) { getQ2().getLog().error(t); } - for (Object o : classpathElement.getChildren("url")) { - Element u = (Element) o; + for (Element u : classpathElement.getChildren("url")) { try { loader.addURL(u.getTextTrim()); } catch (MalformedURLException ex) { @@ -152,8 +151,8 @@ private void getExtraPath (QClassLoader loader, Element e) { } @SuppressWarnings("PMD.EmptyCatchBlock") - public void setAttribute - (MBeanServer server, ObjectName objectName, + public void setAttribute + (MBeanServer server, ObjectName objectName, String attribute, Object value) throws InstanceNotFoundException, MBeanException, @@ -170,7 +169,7 @@ objectName, new Attribute (attribute, value) // okay to fail (produced by some application servers instead of AttributeNotFoundException) } } - + public void startQBean (Q2 server, ObjectName objectName) throws InstanceNotFoundException, MBeanException, @@ -231,7 +230,7 @@ public AttributeList getAttributeList(Element e) * @throws ConfigurationException If an exception is found trying to create the object. */ @SuppressWarnings("unchecked") - protected Object getObject(Element childElement) + protected Object getObject(Element childElement) throws ConfigurationException { String type = childElement.getAttributeValue("type","java.lang.String"); @@ -245,7 +244,7 @@ else if ("boolean".equals (type)) String value = childElement.getText(); value = Environment.getEnvironment().getProperty(value, value); try { - Class attributeType = Class.forName(type); + Class attributeType = Class.forName(type); if(Collection.class.isAssignableFrom(attributeType)) return getCollection(attributeType, childElement); else{ @@ -256,10 +255,10 @@ else if ("boolean".equals (type)) } catch (Exception e1) { throw new ConfigurationException(e1); } - + } - - + + /** Creats a collection from a definition element with the format. *
      *    <{attr|item} type="...">
@@ -278,8 +277,8 @@ protected Collection getCollection(Class type, Element e)
     {
         try{
             Collection col = (Collection) type.newInstance();
-            for (Object o : e.getChildren("item")) {
-                col.add(getObject((Element) o));
+            for (Element o : e.getChildren("item")) {
+                col.add(getObject(o));
             }
             return col;
         }catch(Exception e1){
@@ -318,6 +317,30 @@ public  T newInstance (Class clazz)
         return newInstance(clazz.getName());
     }
 
+    /**
+     * Creates a new instance from the values in {@code Element e}.
+ * If {@code autoConf} is true, it will set the logger from {@code Element e} + * and also trigger the autoconfiguration of properties and internal XML as + * given by {@link #setConfiguration(Object, Element)}.
+ * If the element's {@code enabled} attribute is false, nothing will be created and + * the method returns null. + * + * @param e The XML config + * @param autoConf whether to trigger QFactory autoconfiguration + * @return the new instance, or null if not enabled + * @throws ConfigurationException + */ + public T newInstance(Element e, boolean autoConf) throws ConfigurationException { + if (!QFactory.isEnabled(e)) + return null; + T obj = newInstance(QFactory.getAttributeValue (e, "class")); + if (autoConf) { + setLogger (obj, e); + setConfiguration(obj, e); + } + return obj; + } + public Configuration getConfiguration (Element e) throws ConfigurationException { @@ -372,7 +395,7 @@ public static String getAttributeValue (Element e, String name) { return Environment.getEnvironment().getProperty(s, s); } public void setConfiguration (Object obj, Element e) - throws ConfigurationException + throws ConfigurationException { try { Configuration cfg = getConfiguration (e); @@ -394,8 +417,8 @@ public void setConfiguration (Object obj, Element e) * @param p parameter * @throws ConfigurationException if method happens to throw an exception */ - public static void invoke (Object obj, String m, Object p) - throws ConfigurationException + public static void invoke (Object obj, String m, Object p) + throws ConfigurationException { invoke (obj, m, p, p != null ? p.getClass() : null); } @@ -410,8 +433,8 @@ public static void invoke (Object obj, String m, Object p) * @throws ConfigurationException if method happens to throw an exception */ @SuppressWarnings("PMD.EmptyCatchBlock") - public static void invoke (Object obj, String m, Object p, Class pc) - throws ConfigurationException + public static void invoke (Object obj, String m, Object p, Class pc) + throws ConfigurationException { try { if (p!=null) { @@ -479,7 +502,7 @@ else if (c.isAssignableFrom(double.class) || c.isAssignableFrom(Double.class)) field.set(obj, cfg.getDouble(config.value())); else if (c.isAssignableFrom(boolean.class) || c.isAssignableFrom(Boolean.class)) field.set(obj, cfg.getBoolean(config.value())); - else if (c.isEnum()) + else if (c.isEnum()) field.set(obj, Enum.valueOf((Class) c, v)); else if (c.isArray()) { Class ct = c.getComponentType(); @@ -490,8 +513,8 @@ else if (ct.isAssignableFrom(int.class) || ct.isAssignableFrom(Integer.class)) else if (ct.isAssignableFrom(long.class) || ct.isAssignableFrom(Long.class)) field.set(obj, cfg.getLongs(config.value())); else if (ct.isAssignableFrom(double.class) || ct.isAssignableFrom(Double.class)) - field.set(obj, cfg.getDoubles(config.value())); - } + field.set(obj, cfg.getDoubles(config.value())); + } } } } @@ -539,5 +562,5 @@ private static void expandEnvProperties(Element e, Environment env) { } } } - + } diff --git a/jpos/src/main/java/org/jpos/q2/iso/ChannelAdaptor.java b/jpos/src/main/java/org/jpos/q2/iso/ChannelAdaptor.java index 7c643f29b6..d0bfae2bf0 100644 --- a/jpos/src/main/java/org/jpos/q2/iso/ChannelAdaptor.java +++ b/jpos/src/main/java/org/jpos/q2/iso/ChannelAdaptor.java @@ -235,13 +235,9 @@ public ISOChannel newChannel (Element e, QFactory f) protected void addFilters (FilteredChannel channel, Element e, QFactory fact) throws ConfigurationException { - for (Object o : e.getChildren("filter")) { - Element f = (Element) o; - if (!QFactory.isEnabled(f)) continue; - String clazz = QFactory.getAttributeValue(f, "class"); - ISOFilter filter = (ISOFilter) fact.newInstance(clazz); - fact.setLogger(filter, f); - fact.setConfiguration(filter, f); + for (Element f : e.getChildren("filter")) { + ISOFilter filter = fact.newInstance(f, true); + if (filter == null) continue; String direction = QFactory.getAttributeValue(f, "direction"); if (direction == null) channel.addFilter(filter); diff --git a/jpos/src/main/java/org/jpos/q2/iso/QMUX.java b/jpos/src/main/java/org/jpos/q2/iso/QMUX.java index 6bd3a1cc8e..e9d002d1a5 100644 --- a/jpos/src/main/java/org/jpos/q2/iso/QMUX.java +++ b/jpos/src/main/java/org/jpos/q2/iso/QMUX.java @@ -74,7 +74,7 @@ public class QMUX private Counter rxCounter; private Counter rxMatchCounter; private Counter rxUnhandledCounter; - + public QMUX () { super (); listeners = new ArrayList<>(); @@ -104,7 +104,7 @@ public void initService () throws ConfigurationException { } ready = toStringArray(Environment.get(e.getChildTextTrim ("ready"))); mtiMapping = toStringArray(Environment.get(e.getChildTextTrim ("mtimapping"))); - if (mtiMapping == null || mtiMapping.length != 3) + if (mtiMapping == null || mtiMapping.length != 3) mtiMapping = new String[] { nomap, nomap, "0022446689" }; addListeners (); unhandled = Environment.get(e.getChildTextTrim ("unhandled")); @@ -138,7 +138,7 @@ public void destroyService () { * @see NameRegistrar */ public static MUX getMUX (String name) - throws NameRegistrar.NotFoundException + throws NameRegistrar.NotFoundException { return (MUX) NameRegistrar.get ("mux."+name); } @@ -349,7 +349,7 @@ public String getInQueue () { return in; } public synchronized void setOutQueue (String out) { - this.out = out; + this.out = out; getPersist().getChild("out").setText (out); setModified (true); } @@ -373,17 +373,11 @@ public String[] getReadyIndicatorNames() { } private void addListeners() throws ConfigurationException { - List rlisten = getPersist().getChildren("request-listener"); - if (rlisten.isEmpty()) - return; - QFactory factory = getFactory (); - for (Element l : rlisten) { - ISORequestListener listener = (ISORequestListener) - factory.newInstance (QFactory.getAttributeValue (l, "class")); - factory.setLogger (listener, l); - factory.setConfiguration (listener, l); - addISORequestListener (listener); + for (Element l : getPersist().getChildren("request-listener")) { + ISORequestListener listener = factory.newInstance(l, true); + if (listener != null) + addISORequestListener (listener); } } public void addISORequestListener(ISORequestListener l) { @@ -417,7 +411,7 @@ public String getCountersAsString () { } return sb.toString(); } - + public int getTXCounter() { return tx; } @@ -477,7 +471,7 @@ protected void processUnhandled (ISOMsg m) { sp.out (unhandled, m, 120000); } } - private LocalSpace grabSpace (Element e) + private LocalSpace grabSpace (Element e) throws ConfigurationException { String uri = e != null ? e.getText() : ""; @@ -544,7 +538,7 @@ private String[] toStringArray(String s) { return toStringArray(s, null,null); } private boolean shouldIgnore (ISOMsg m) { - if (m != null && ignorerc != null + if (m != null && ignorerc != null && ignorerc.length() > 0 && m.hasField(39)) { return ignorerc.contains(m.getString(39)); diff --git a/jpos/src/main/java/org/jpos/q2/iso/QServer.java b/jpos/src/main/java/org/jpos/q2/iso/QServer.java index c9c5772ea0..0dddc2f39a 100644 --- a/jpos/src/main/java/org/jpos/q2/iso/QServer.java +++ b/jpos/src/main/java/org/jpos/q2/iso/QServer.java @@ -260,56 +260,33 @@ public String getCountersAsString () { public String getCountersAsString (String isoChannelName) { return server.getCountersAsString (isoChannelName); } + private void addServerSocketFactory () throws ConfigurationException { QFactory factory = getFactory (); - Element persist = getPersist (); - - Element serverSocketFactoryElement = persist.getChild ("server-socket-factory"); - - if (serverSocketFactoryElement != null && QFactory.isEnabled(serverSocketFactoryElement)) { - ISOServerSocketFactory serverSocketFactory = factory.newInstance ( - QFactory.getAttributeValue (serverSocketFactoryElement, "class")); - factory.setLogger (serverSocketFactory, serverSocketFactoryElement); - factory.setConfiguration (serverSocketFactory, serverSocketFactoryElement); - server.setSocketFactory(serverSocketFactory); + Element serverSocketFactoryElement = getPersist().getChild ("server-socket-factory"); + if (serverSocketFactoryElement != null) { + ISOServerSocketFactory serverSocketFactory= factory.newInstance(serverSocketFactoryElement, true); + if (serverSocketFactory != null) + server.setSocketFactory(serverSocketFactory); } } - private void addListeners () - throws ConfigurationException - { + private void addListeners () throws ConfigurationException { QFactory factory = getFactory (); - Iterator iter = getPersist().getChildren ( - "request-listener" - ).iterator(); - while (iter.hasNext()) { - Element l = (Element) iter.next(); - if (!QFactory.isEnabled(l)) - continue; - ISORequestListener listener = factory.newInstance (QFactory.getAttributeValue (l, "class")); - factory.setLogger (listener, l); - factory.setConfiguration (listener, l); - server.addISORequestListener (listener); + for (Element l : getPersist().getChildren("request-listener")) { + ISORequestListener listener = factory.newInstance(l, true); + if (listener != null) + server.addISORequestListener (listener); } } - private void addISOServerConnectionListeners() - throws ConfigurationException - { - + private void addISOServerConnectionListeners() throws ConfigurationException { QFactory factory = getFactory (); - Iterator iter = getPersist().getChildren ( - "connection-listener" - ).iterator(); - while (iter.hasNext()) { - Element l = (Element) iter.next(); - if (!QFactory.isEnabled(l)) - continue; - ISOServerEventListener listener = factory.newInstance (QFactory.getAttributeValue (l, "class")); - factory.setLogger (listener, l); - factory.setConfiguration (listener, l); - server.addServerEventListener(listener); + for (Element l : getPersist().getChildren("connection-listener")) { + ISOServerEventListener listener = factory.newInstance(l, true); + if (listener != null) + server.addServerEventListener(listener); } } @@ -418,9 +395,10 @@ private void initMeters() { baseChannel.setServerName(getName()); } } + private void removeMeters() { var registry = getServer().getMeterRegistry(); - registry.remove(connectionsGauge); + registry.remove(connectionsGauge); if (msgInCounter != null) registry.remove(msgInCounter); if (msgOutCounter != null) From 27e4bf19ee008d187e6ca756cff0d2a1d427f774 Mon Sep 17 00:00:00 2001 From: Barzilai Spinak Date: Sun, 25 Jan 2026 03:08:40 -0300 Subject: [PATCH 2/2] QFactory.newInstance(Element) refactor --- jpos/src/main/java/org/jpos/q2/QFactory.java | 23 +++++++++---------- .../java/org/jpos/q2/iso/ChannelAdaptor.java | 21 ++++++++--------- .../main/java/org/jpos/q2/iso/MUXPool.java | 6 +---- .../jpos/q2/iso/OneShotChannelAdaptor.java | 9 ++++---- jpos/src/main/java/org/jpos/q2/iso/QMUX.java | 2 +- .../main/java/org/jpos/q2/iso/QServer.java | 6 ++--- .../java/org/jpos/q2/qbean/LoggerAdaptor.java | 17 ++++++-------- 7 files changed, 37 insertions(+), 47 deletions(-) diff --git a/jpos/src/main/java/org/jpos/q2/QFactory.java b/jpos/src/main/java/org/jpos/q2/QFactory.java index 38f9ce382a..ace8a4a421 100644 --- a/jpos/src/main/java/org/jpos/q2/QFactory.java +++ b/jpos/src/main/java/org/jpos/q2/QFactory.java @@ -319,25 +319,24 @@ public T newInstance (Class clazz) /** * Creates a new instance from the values in {@code Element e}.
- * If {@code autoConf} is true, it will set the logger from {@code Element e} - * and also trigger the autoconfiguration of properties and internal XML as - * given by {@link #setConfiguration(Object, Element)}.
- * If the element's {@code enabled} attribute is false, nothing will be created and - * the method returns null. + *

+ * The method honors the {@code enabled} attribute in the given {@code Element e}, + * returning null immediately if {@code enabled} is computed to a true-equivalent.

+ *

+ * It also calls {@link #setLogger} to set logger and realm, and {@link #setConfiguration(Object, Element)} + * to trigger the standard [auto]configuration sequence from properties and XML.

* * @param e The XML config - * @param autoConf whether to trigger QFactory autoconfiguration * @return the new instance, or null if not enabled - * @throws ConfigurationException + * @throws ConfigurationException if the instance can't be created (e.g. class not found) + * or the configuration process itself threw the exception. */ - public T newInstance(Element e, boolean autoConf) throws ConfigurationException { + public T newInstance(Element e) throws ConfigurationException { if (!QFactory.isEnabled(e)) return null; T obj = newInstance(QFactory.getAttributeValue (e, "class")); - if (autoConf) { - setLogger (obj, e); - setConfiguration(obj, e); - } + setLogger (obj, e); + setConfiguration(obj, e); return obj; } diff --git a/jpos/src/main/java/org/jpos/q2/iso/ChannelAdaptor.java b/jpos/src/main/java/org/jpos/q2/iso/ChannelAdaptor.java index d0bfae2bf0..1b3881171a 100644 --- a/jpos/src/main/java/org/jpos/q2/iso/ChannelAdaptor.java +++ b/jpos/src/main/java/org/jpos/q2/iso/ChannelAdaptor.java @@ -69,8 +69,8 @@ public class ChannelAdaptor boolean ignoreISOExceptions = false; boolean writeOnly = false; int rx, tx, connects; - long lastTxn = 0l; - long timeout = 0l; + long lastTxn = 0L; + long timeout = 0L; boolean waitForWorkersOnStop; private Thread receiver; private Thread sender; @@ -202,16 +202,15 @@ public String getOutQueue () { return out; } - public ISOChannel newChannel (Element e, QFactory f) + public ISOChannel newChannel (Element e, QFactory f) throws ConfigurationException { String channelName = QFactory.getAttributeValue (e, "class"); String packagerName = QFactory.getAttributeValue (e, "packager"); - ISOChannel channel = (ISOChannel) f.newInstance (channelName); - ISOPackager packager; + ISOChannel channel = f.newInstance(channelName); if (packagerName != null) { - packager = (ISOPackager) f.newInstance (packagerName); + ISOPackager packager = f.newInstance(packagerName); channel.setPackager (packager); f.setConfiguration (packager, e); } @@ -236,7 +235,7 @@ protected void addFilters (FilteredChannel channel, Element e, QFactory fact) throws ConfigurationException { for (Element f : e.getChildren("filter")) { - ISOFilter filter = fact.newInstance(f, true); + ISOFilter filter = fact.newInstance(f); if (filter == null) continue; String direction = QFactory.getAttributeValue(f, "direction"); if (direction == null) @@ -263,8 +262,8 @@ protected ISOChannel initChannel () throws ConfigurationException { 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) { + ISOClientSocketFactory sFac = getFactory().newInstance(socketFactoryString); + if (sFac instanceof LogSource) { ((LogSource) sFac).setLogger(log.getLogger(),getName() + ".socket-factory"); } getFactory().setConfiguration (sFac, e); @@ -286,7 +285,7 @@ protected void initSpaceAndQueues () throws ConfigurationException { keepAlive = "yes".equalsIgnoreCase (Environment.get(persist.getChildTextTrim ("keep-alive"))); ignoreISOExceptions = "yes".equalsIgnoreCase (Environment.get(persist.getChildTextTrim ("ignore-iso-exceptions"))); String t = Environment.get(persist.getChildTextTrim("timeout")); - timeout = t != null && t.length() > 0 ? Long.parseLong(t) : 0l; + timeout = t != null && t.length() > 0 ? Long.parseLong(t) : 0L; ready = getName() + ".ready"; reconnect = getName() + ".reconnect"; waitForWorkersOnStop = "yes".equalsIgnoreCase(Environment.get(persist.getChildTextTrim ("wait-for-workers-on-stop"))); @@ -480,7 +479,7 @@ public synchronized void setSocketFactory (String sFac) { public void resetCounters () { rx = tx = connects = 0; - lastTxn = 0l; + lastTxn = 0L; } public String getCountersAsString () { StringBuilder sb = new StringBuilder(); diff --git a/jpos/src/main/java/org/jpos/q2/iso/MUXPool.java b/jpos/src/main/java/org/jpos/q2/iso/MUXPool.java index 6888da26bb..00831ad5f3 100644 --- a/jpos/src/main/java/org/jpos/q2/iso/MUXPool.java +++ b/jpos/src/main/java/org/jpos/q2/iso/MUXPool.java @@ -100,11 +100,7 @@ public void stopService () { protected void initHandler(Element e) throws ConfigurationException { if (e == null) return; - - QFactory factory = getFactory(); - strategyHandler = factory.newInstance(QFactory.getAttributeValue (e, "class")); - factory.setLogger(strategyHandler, e); - factory.setConfiguration(strategyHandler, e); + strategyHandler = getFactory().newInstance(e); } public ISOMsg request (ISOMsg m, long timeout) throws ISOException { diff --git a/jpos/src/main/java/org/jpos/q2/iso/OneShotChannelAdaptor.java b/jpos/src/main/java/org/jpos/q2/iso/OneShotChannelAdaptor.java index 8157cb4714..355cb98ba2 100644 --- a/jpos/src/main/java/org/jpos/q2/iso/OneShotChannelAdaptor.java +++ b/jpos/src/main/java/org/jpos/q2/iso/OneShotChannelAdaptor.java @@ -196,8 +196,8 @@ public void initChannel () throws ConfigurationException { String socketFactoryString = getSocketFactory(); if (socketFactoryString != null && channel instanceof FactoryChannel) { - ISOClientSocketFactory sFac = (ISOClientSocketFactory) getFactory().newInstance(socketFactoryString); - if (sFac != null && sFac instanceof LogSource) { + ISOClientSocketFactory sFac = getFactory().newInstance(socketFactoryString); + if (sFac instanceof LogSource) { ((LogSource) sFac).setLogger(log.getLogger(),getName() + ".socket-factory"); } getFactory().setConfiguration (sFac, e); @@ -214,10 +214,9 @@ private ISOChannel newChannel (Element e, QFactory f) String packagerName = QFactory.getAttributeValue (e, "packager"); - ISOChannel channel = (ISOChannel) f.newInstance (channelName); - ISOPackager packager; + ISOChannel channel = f.newInstance (channelName); if (packagerName != null) { - packager = (ISOPackager) f.newInstance (packagerName); + ISOPackager packager = f.newInstance (packagerName); channel.setPackager (packager); f.setConfiguration (packager, e); } diff --git a/jpos/src/main/java/org/jpos/q2/iso/QMUX.java b/jpos/src/main/java/org/jpos/q2/iso/QMUX.java index e9d002d1a5..c1511b1902 100644 --- a/jpos/src/main/java/org/jpos/q2/iso/QMUX.java +++ b/jpos/src/main/java/org/jpos/q2/iso/QMUX.java @@ -375,7 +375,7 @@ public String[] getReadyIndicatorNames() { private void addListeners() throws ConfigurationException { QFactory factory = getFactory (); for (Element l : getPersist().getChildren("request-listener")) { - ISORequestListener listener = factory.newInstance(l, true); + ISORequestListener listener = factory.newInstance(l); if (listener != null) addISORequestListener (listener); } diff --git a/jpos/src/main/java/org/jpos/q2/iso/QServer.java b/jpos/src/main/java/org/jpos/q2/iso/QServer.java index 0dddc2f39a..7ea682ddc9 100644 --- a/jpos/src/main/java/org/jpos/q2/iso/QServer.java +++ b/jpos/src/main/java/org/jpos/q2/iso/QServer.java @@ -265,7 +265,7 @@ private void addServerSocketFactory () throws ConfigurationException { QFactory factory = getFactory (); Element serverSocketFactoryElement = getPersist().getChild ("server-socket-factory"); if (serverSocketFactoryElement != null) { - ISOServerSocketFactory serverSocketFactory= factory.newInstance(serverSocketFactoryElement, true); + ISOServerSocketFactory serverSocketFactory= factory.newInstance(serverSocketFactoryElement); if (serverSocketFactory != null) server.setSocketFactory(serverSocketFactory); } @@ -275,7 +275,7 @@ private void addServerSocketFactory () throws ConfigurationException { private void addListeners () throws ConfigurationException { QFactory factory = getFactory (); for (Element l : getPersist().getChildren("request-listener")) { - ISORequestListener listener = factory.newInstance(l, true); + ISORequestListener listener = factory.newInstance(l); if (listener != null) server.addISORequestListener (listener); } @@ -284,7 +284,7 @@ private void addListeners () throws ConfigurationException { private void addISOServerConnectionListeners() throws ConfigurationException { QFactory factory = getFactory (); for (Element l : getPersist().getChildren("connection-listener")) { - ISOServerEventListener listener = factory.newInstance(l, true); + ISOServerEventListener listener = factory.newInstance(l); if (listener != null) server.addServerEventListener(listener); } diff --git a/jpos/src/main/java/org/jpos/q2/qbean/LoggerAdaptor.java b/jpos/src/main/java/org/jpos/q2/qbean/LoggerAdaptor.java index eb326cf9cf..49e53c3866 100644 --- a/jpos/src/main/java/org/jpos/q2/qbean/LoggerAdaptor.java +++ b/jpos/src/main/java/org/jpos/q2/qbean/LoggerAdaptor.java @@ -37,8 +37,8 @@ protected void initService () { } protected void startService () throws ConfigurationException, IOException { logger.removeAllListeners (); - for (Object o : getPersist().getChildren("log-listener")) - addListener((Element) o); + for (Element lle : getPersist().getChildren("log-listener")) + addListener(lle); String redirect = cfg.get("redirect"); long delay = cfg.getLong("delay", 500); @@ -66,15 +66,12 @@ protected void destroyService() { // // logger.destroy (); } - private void addListener (Element e) - throws ConfigurationException - { + + private void addListener (Element e) throws ConfigurationException { QFactory factory = getServer().getFactory(); - if (QFactory.isEnabled(e)) { - String clazz = e.getAttributeValue("class"); - LogListener listener = factory.newInstance(clazz); - factory.setConfiguration(listener, e); - attemptToAddWriter (e.getChild("writer"), listener); + LogListener listener = factory.newInstance(e); + if (listener != null) { + attemptToAddWriter(e.getChild("writer"), listener); logger.addListener(listener); } }