From e6b7436f4cd88c5a4bf2e31d73b26b6641bb572c Mon Sep 17 00:00:00 2001 From: Jumper Chen Date: Mon, 9 Sep 2024 17:11:59 +0800 Subject: [PATCH] ZK-5703: Debug messages shouldn't be created if debug is disabled, may cause side effects --- .../main/java/org/zkoss/io/Serializables.java | 28 ++-- .../main/java/org/zkoss/lang/Exceptions.java | 9 +- .../src/main/java/org/zkoss/lang/Objects.java | 5 +- .../org/zkoss/util/resource/ClassLocator.java | 9 +- .../org/zkoss/util/resource/Locators.java | 10 +- .../util/resource/impl/LabelLoaderImpl.java | 12 +- .../main/java/org/zkoss/xel/fn/CommonFns.java | 14 +- .../java/org/zkoss/xel/taglib/Taglibs.java | 6 +- .../java/org/zkoss/xel/util/Evaluators.java | 33 ++--- .../org/zkoss/zk/au/http/AuDynaMediar.java | 10 +- .../zkoss/zk/au/http/AuMultipartUploader.java | 6 +- .../zkoss/zk/au/http/DHtmlUpdateServlet.java | 19 ++- .../org/zkoss/zk/scripting/Interpreters.java | 6 +- .../org/zkoss/zk/ui/EventListenerInfo.java | 10 +- .../org/zkoss/zk/ui/HtmlShadowElement.java | 16 ++- .../zk/ui/event/impl/DesktopEventQueue.java | 12 +- .../zkoss/zk/ui/http/DHtmlLayoutFilter.java | 6 +- .../java/org/zkoss/zk/ui/http/WebManager.java | 14 +- .../org/zkoss/zk/ui/impl/DesktopImpl.java | 12 +- .../zkoss/zk/ui/impl/PollingServerPush.java | 8 +- .../zkoss/zk/ui/impl/RequestQueueImpl.java | 6 +- .../zkoss/zk/ui/impl/SimpleDesktopCache.java | 8 +- .../org/zkoss/zk/ui/impl/UiEngineImpl.java | 10 +- .../zk/ui/metainfo/DefinitionLoaders.java | 22 +-- .../org/zkoss/zk/ui/sys/ConfigParser.java | 18 +-- .../org/zkoss/zk/ui/util/ConventionWires.java | 124 ++++++++--------- .../zk/ui/util/GenericAutowireComposer.java | 84 ++++++------ .../java/org/zkoss/bind/impl/BinderImpl.java | 126 ++++++++---------- .../bind/impl/ChildrenBindingHandler.java | 13 +- .../zkoss/bind/impl/FormBindingHandler.java | 18 ++- .../java/org/zkoss/bind/impl/ParamCall.java | 6 +- .../bind/impl/PropertyBindingHandler.java | 33 +++-- .../zkoss/bind/impl/SaveFormBindingImpl.java | 35 ++--- .../bind/xel/zel/BindExpressionBuilder.java | 16 +-- zkdoc/release-note | 1 + .../jpa/OpenEntityManagerInViewListener.java | 57 +++++--- .../web/servlet/dsp/InterpreterServlet.java | 4 +- .../org/zkoss/web/servlet/http/Encodes.java | 19 +-- .../org/zkoss/web/servlet/http/Https.java | 2 +- .../web/util/resource/ExtendletLoader.java | 8 +- .../web/util/resource/ResourceLoader.java | 8 +- 41 files changed, 464 insertions(+), 399 deletions(-) diff --git a/zcommon/src/main/java/org/zkoss/io/Serializables.java b/zcommon/src/main/java/org/zkoss/io/Serializables.java index bc388f3fbf2..8e6daaa8ea7 100644 --- a/zcommon/src/main/java/org/zkoss/io/Serializables.java +++ b/zcommon/src/main/java/org/zkoss/io/Serializables.java @@ -1,9 +1,9 @@ /* Serializables.java Purpose: - + Description: - + History: Sun Jun 25 22:54:45 2006, Created by tomyeh @@ -61,11 +61,15 @@ public static void smartWrite(ObjectOutputStream s, Map map) s.writeObject(nm); s.writeObject(val); } catch (java.io.NotSerializableException ex) { - logio.error("Unable to serialize entry: "+nm+'='+val); + logio.error("Unable to serialize entry: {}={}", nm, + val); throw ex; } } else if (nm != null && debug) { - logio.debug("Skip not-serializable entry: "+nm+'='+val); + if (logio.isDebugEnabled()) { + logio.debug("Skip not-serializable entry: {}={}", nm, + val); + } } } } @@ -101,11 +105,13 @@ public static void smartWrite(ObjectOutputStream s, Collection col) try { s.writeObject(val); } catch (java.io.NotSerializableException ex) { - logio.error("Unable to serialize item: "+val); + logio.error("Unable to serialize item: {}", val); throw ex; } } else if (val != null && debug) { - logio.debug("Skip not-serializable item: "+val); + if (logio.isDebugEnabled()) { + logio.debug("Skip not-serializable item: {}", val); + } } } } @@ -164,11 +170,13 @@ public static void smartWrite(ObjectOutputStream s, T[] ary) try { s.writeObject(val); } catch (java.io.NotSerializableException ex) { - logio.error("Unable to serialize item: "+val); + logio.error("Unable to serialize item: {}", val); throw ex; } } else if (val != null && debug) { - logio.debug("Skip not-serializable item: "+val); + if (logio.isDebugEnabled()) { + logio.debug("Skip not-serializable item: {}", val); + } } } } @@ -182,8 +190,8 @@ public static void smartWrite(ObjectOutputStream s, Object val) throws IOException { final boolean bser = val instanceof java.io.Serializable || val instanceof java.io.Externalizable; - s.writeObject(bser ? val: null); + s.writeObject(bser ? val : null); if (!bser && val != null && logio.isDebugEnabled()) - logio.debug("Skip not-serializable object: "+val); + logio.debug("Skip not-serializable object: {}", val); } } diff --git a/zcommon/src/main/java/org/zkoss/lang/Exceptions.java b/zcommon/src/main/java/org/zkoss/lang/Exceptions.java index 585327633fe..c899e256629 100644 --- a/zcommon/src/main/java/org/zkoss/lang/Exceptions.java +++ b/zcommon/src/main/java/org/zkoss/lang/Exceptions.java @@ -2,7 +2,7 @@ Purpose: Utilities for Exceptions - Description: + Description: History: 2001/4/22, Tom M. Yeh: Created. @@ -80,7 +80,8 @@ public static final Throwable getCause(Throwable ex) { // return ((javax.servlet.jsp.el.ELException)ex).getRootCause(); } } catch (Throwable e2) { - if (log.isDebugEnabled()) log.debug("Ignored: unable to resolve " + ex.getClass()); + if (log.isDebugEnabled()) + log.debug("Ignored: unable to resolve {}", ex.getClass()); } return t; } @@ -301,7 +302,9 @@ else if (ex instanceof UndeclaredThrowableException) if (t != null) ex = t; } } catch (Throwable e2) { - if (log.isDebugEnabled()) log.debug("Ignored: unable to resolve " + ex.getClass()); + if (log.isDebugEnabled()) + log.debug("Ignored: unable to resolve {}", + ex.getClass()); } //Remove the dependence on EL /* try { diff --git a/zcommon/src/main/java/org/zkoss/lang/Objects.java b/zcommon/src/main/java/org/zkoss/lang/Objects.java index 187322a2936..05ea37f00be 100644 --- a/zcommon/src/main/java/org/zkoss/lang/Objects.java +++ b/zcommon/src/main/java/org/zkoss/lang/Objects.java @@ -113,7 +113,7 @@ public static final int hashCode(byte[] v) { h = nextHashCode(h, v[j]); return h; } - /** + /** * Generates hash codes for an array of bytes up to the specified length. * It is suggested to cache the hash code. * @@ -413,7 +413,8 @@ public static final Object clone(Object o) { try { return kls.getMethod("clone").invoke(o); } catch (NoSuchMethodException ex) { - if (log.isDebugEnabled()) log.debug("No clone() for "+kls); + if (log.isDebugEnabled()) + log.debug("No clone() for {}", kls); } } diff --git a/zcommon/src/main/java/org/zkoss/util/resource/ClassLocator.java b/zcommon/src/main/java/org/zkoss/util/resource/ClassLocator.java index e3988b372bd..06db25f7df3 100644 --- a/zcommon/src/main/java/org/zkoss/util/resource/ClassLocator.java +++ b/zcommon/src/main/java/org/zkoss/util/resource/ClassLocator.java @@ -1,9 +1,9 @@ /* ClassLocator.java Purpose: - + Description: - + History: Tue Aug 30 09:56:06 2005, Created by tomyeh @@ -109,7 +109,7 @@ private static void resolveDependency(XMLResource xr, List rcs, Map rcmap, Set resolving, String elName) { if (!resolving.add(xr.name)) throw new IllegalStateException("Recusrive reference among "+resolving); - + checkCompDenpendency(xr, rcmap, elName); for (String nm: xr.depends) { @@ -121,7 +121,8 @@ private static void resolveDependency(XMLResource xr, rcs.add(new Resource(xr.url, xr.document)); resolving.remove(xr.name); - if (log.isDebugEnabled()) log.debug("Adding resolved resource: "+xr.name); + if (log.isDebugEnabled()) + log.debug("Adding resolved resource: {}", xr.name); } private static void checkCompDenpendency(XMLResource xr, Map rcmap, String elName) { diff --git a/zcommon/src/main/java/org/zkoss/util/resource/Locators.java b/zcommon/src/main/java/org/zkoss/util/resource/Locators.java index 67eb2cc1f20..5630d690c09 100644 --- a/zcommon/src/main/java/org/zkoss/util/resource/Locators.java +++ b/zcommon/src/main/java/org/zkoss/util/resource/Locators.java @@ -1,8 +1,8 @@ /* Locators.java - Purpose: - Description: + Purpose: + Description: History: 90/12/07 10:34:55, Create, Tom M. Yeh. @@ -120,16 +120,16 @@ public String toString() { locale = Locales.getCurrent(); final int jslash = file.lastIndexOf('/'); //>= -1 - final int jdot = + final int jdot = jslash >= 0 ? file.indexOf('.', jslash + 1): file.indexOf('.'); final String ext = jdot >= 0 ? file.substring(jdot): ""; final int jul = Locales.indexOfUnderline(file, jslash >= 0 ? jslash + 1: 0); final String base = file.substring(0, jul >= 0 && (jdot < 0 || jul < jdot) ? jul: - jdot >= 0 ? jdot: file.length()); + jdot >= 0 ? jdot : file.length()); if (log.isDebugEnabled()) - log.debug("svl=" + file + " base=" + base + " ext=" + ext); + log.debug("svl={} base={} ext={}", file, base, ext); //search the existence based on locale final int baseLen = base.length(); diff --git a/zcommon/src/main/java/org/zkoss/util/resource/impl/LabelLoaderImpl.java b/zcommon/src/main/java/org/zkoss/util/resource/impl/LabelLoaderImpl.java index 6e81da30974..a249adf36a5 100644 --- a/zcommon/src/main/java/org/zkoss/util/resource/impl/LabelLoaderImpl.java +++ b/zcommon/src/main/java/org/zkoss/util/resource/impl/LabelLoaderImpl.java @@ -1,9 +1,9 @@ /* LabelLoader.java Purpose: - + Description: - + History: Mon Jun 12 13:05:05 2006, Created by tomyeh @@ -52,7 +52,7 @@ * Used to implement {@link org.zkoss.util.resource.Labels}. * *

Notice that the encoding of the Locale dependent file (*.properties) - * is assumed to be UTF-8. If it is not the case, please refer to + * is assumed to be UTF-8. If it is not the case, please refer to * ZK Configuration Reference * for more information. *

Specify the library property of org.zkoss.util.resource.LabelLoader.class @@ -109,7 +109,9 @@ public Object filter(Object key, Object value) { * @since 8.6.0 */ protected Object handleMissingLabel(Object key) { - log.debug("The key of [{}] is not found in labels!", key); + if (log.isDebugEnabled()) { + log.debug("The key of [{}] is not found in labels!", key); + } return null; } @@ -220,7 +222,7 @@ private final Map loadLabels(Locale locale) { WaitLock lock = null; for (;;) { final Object o; - synchronized (_syncLabels) { + synchronized (_syncLabels) { o = _syncLabels.get(locale); if (o == null) _syncLabels.put(locale, lock = new WaitLock()); //lock it diff --git a/zcommon/src/main/java/org/zkoss/xel/fn/CommonFns.java b/zcommon/src/main/java/org/zkoss/xel/fn/CommonFns.java index e0922220d38..655b7c1ffd3 100644 --- a/zcommon/src/main/java/org/zkoss/xel/fn/CommonFns.java +++ b/zcommon/src/main/java/org/zkoss/xel/fn/CommonFns.java @@ -1,9 +1,9 @@ /* CommonFns.java Purpose: - + Description: - + History: Wed Apr 20 18:35:21 2005, Created by tomyeh @@ -119,16 +119,16 @@ public static final String getLabel(String key) { try { final Class cls = Classes.forNameByThread(clsnm); final Field fld = cls.getField(fldnm); - return Messages.get(((Integer)fld.get(null)).intValue()); + return Messages.get(((Integer) fld.get(null)).intValue()); } catch (ClassNotFoundException ex) { - log.warn("Class not found: "+clsnm, ex); + log.warn("Class not found: {}", clsnm, ex); } catch (NoSuchFieldException ex) { - log.warn("Field not found: "+fldnm, ex); + log.warn("Field not found: {}", fldnm, ex); } catch (IllegalAccessException ex) { - log.warn("Field not accessible: "+fldnm, ex); + log.warn("Field not accessible: {}", fldnm, ex); } } else if (log.isDebugEnabled()) { - log.debug("Not a valid format: "+key); + log.debug("Not a valid format: {}", key); } } return Labels.getLabel(key); diff --git a/zcommon/src/main/java/org/zkoss/xel/taglib/Taglibs.java b/zcommon/src/main/java/org/zkoss/xel/taglib/Taglibs.java index 3da8754b6d2..c7e4ac687d2 100644 --- a/zcommon/src/main/java/org/zkoss/xel/taglib/Taglibs.java +++ b/zcommon/src/main/java/org/zkoss/xel/taglib/Taglibs.java @@ -1,9 +1,9 @@ /* Taglibs.java Purpose: - + Description: - + History: Fri Aug 10 16:42:37 2007, Created by tomyeh @@ -330,7 +330,7 @@ private static final Map getDefaultTLDs() { if (IDOMs.checkVersion(res.document, res.url)) parseConfig(urls, res.document.getRootElement(), loc); } catch (Exception ex) { - log.error("Failed to parse "+ res.url, ex); //keep running + log.error("Failed to parse {}", res.url, ex); //keep running } } } catch (Exception ex) { diff --git a/zcommon/src/main/java/org/zkoss/xel/util/Evaluators.java b/zcommon/src/main/java/org/zkoss/xel/util/Evaluators.java index e576e8f940b..f7053bd5391 100644 --- a/zcommon/src/main/java/org/zkoss/xel/util/Evaluators.java +++ b/zcommon/src/main/java/org/zkoss/xel/util/Evaluators.java @@ -1,9 +1,9 @@ /* Evaluators.java Purpose: - + Description: - + History: Fri Sep 14 12:24:23 2007, Created by tomyeh @@ -16,28 +16,29 @@ */ package org.zkoss.xel.util; +import static org.zkoss.lang.Generics.cast; + +import java.net.URL; +import java.util.Enumeration; +import java.util.HashMap; import java.util.Iterator; import java.util.Map; -import java.util.HashMap; -import java.util.Enumeration; -import java.net.URL; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.zkoss.lang.Classes; -import static org.zkoss.lang.Generics.cast; -import org.zkoss.lang.SystemException; -import org.zkoss.util.resource.Locator; -import org.zkoss.util.resource.ClassLocator; -import org.zkoss.idom.input.SAXBuilder; import org.zkoss.idom.Document; import org.zkoss.idom.Element; +import org.zkoss.idom.input.SAXBuilder; import org.zkoss.idom.util.IDOMs; -import org.zkoss.xel.XelContext; +import org.zkoss.lang.Classes; +import org.zkoss.lang.SystemException; +import org.zkoss.util.resource.ClassLocator; +import org.zkoss.util.resource.Locator; import org.zkoss.xel.ExpressionFactory; import org.zkoss.xel.VariableResolver; import org.zkoss.xel.VariableResolverX; +import org.zkoss.xel.XelContext; /** * It maps a name with an evaluator implementation. @@ -118,7 +119,8 @@ public static final String add(String name, String evalcls) { || evalcls == null || evalcls.length() == 0) throw new IllegalArgumentException("emty or null"); - if (log.isDebugEnabled()) log.debug("Evaluator is added: "+name+", "+evalcls); + if (log.isDebugEnabled()) + log.debug("Evaluator is added: {}, {}", name, evalcls); final String evalnm = name.toLowerCase(java.util.Locale.ENGLISH); final Object old; @@ -162,8 +164,9 @@ synchronized static final void load() { final ClassLocator loc = new ClassLocator(); for (Enumeration en = loc.getResources("metainfo/xel/config.xml"); en.hasMoreElements();) { - final URL url = (URL)en.nextElement(); - if (log.isDebugEnabled()) log.debug("Loading "+url); + final URL url = (URL) en.nextElement(); + if (log.isDebugEnabled()) + log.debug("Loading {}", url); try { final Document doc = new SAXBuilder(false, false, true).build(url); if (IDOMs.checkVersion(doc, url)) diff --git a/zk/src/main/java/org/zkoss/zk/au/http/AuDynaMediar.java b/zk/src/main/java/org/zkoss/zk/au/http/AuDynaMediar.java index 700bc971b28..ce3e6124f9c 100644 --- a/zk/src/main/java/org/zkoss/zk/au/http/AuDynaMediar.java +++ b/zk/src/main/java/org/zkoss/zk/au/http/AuDynaMediar.java @@ -1,9 +1,9 @@ /* AuDynaMediar.java Purpose: - + Description: - + History: Fri Jan 11 19:14:17 2008, Created by tomyeh @@ -53,7 +53,7 @@ /** * The AU processor used to response the content for {@link DynamicMedia#getMedia} - * + * * @author tomyeh * @since 3.0.2 */ @@ -128,7 +128,9 @@ public void service(HttpServletRequest request, HttpServletResponse response, St if (comp == null) { // B65-ZK-1599 response.sendError(HttpServletResponse.SC_GONE, Messages.get(MZk.PAGE_NOT_FOUND, pi + " - " + uuid)); - log.debug("Failed to load media, " + pi); + if (log.isDebugEnabled()) { + log.debug("Failed to load media, {}", pi); + } return; } final Object cc = ((ComponentCtrl) comp).getExtraCtrl(); diff --git a/zk/src/main/java/org/zkoss/zk/au/http/AuMultipartUploader.java b/zk/src/main/java/org/zkoss/zk/au/http/AuMultipartUploader.java index 7c8fec2468b..280f7d13fc0 100644 --- a/zk/src/main/java/org/zkoss/zk/au/http/AuMultipartUploader.java +++ b/zk/src/main/java/org/zkoss/zk/au/http/AuMultipartUploader.java @@ -563,21 +563,21 @@ private static final Media processItem(Desktop desktop, FileItem fi, boolean alw //note: AImage converts stream to binary array } catch (Throwable ex) { if (log.isDebugEnabled()) - log.debug("Unknown file format: " + ctype); + log.debug("Unknown file format: {}", ctype); } } else if (ctypelc.startsWith("audio/")) { try { return fi.isInMemory() ? new AAudio(name, fi.get()) : new StreamAudio(name, fi, ctypelc); } catch (Throwable ex) { if (log.isDebugEnabled()) - log.debug("Unknown file format: " + ctype); + log.debug("Unknown file format: {}", ctype); } } else if (ctypelc.startsWith("video/")) { try { return fi.isInMemory() ? new AVideo(name, fi.get()) : new StreamVideo(name, fi, ctypelc); } catch (Throwable ex) { if (log.isDebugEnabled()) - log.debug("Unknown file format: " + ctype); + log.debug("Unknown file format: {}", ctype); } } else if (ctypelc.startsWith("text/")) { String charset = getCharset(ctype); diff --git a/zk/src/main/java/org/zkoss/zk/au/http/DHtmlUpdateServlet.java b/zk/src/main/java/org/zkoss/zk/au/http/DHtmlUpdateServlet.java index 0c80fe466b0..bb223ddeb84 100644 --- a/zk/src/main/java/org/zkoss/zk/au/http/DHtmlUpdateServlet.java +++ b/zk/src/main/java/org/zkoss/zk/au/http/DHtmlUpdateServlet.java @@ -347,7 +347,9 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) final AuExtension aue = getAuExtensionByPath(pi); if (aue == null) { response.sendError(HttpServletResponse.SC_NOT_FOUND); - log.debug("Unknown path info: {}", pi); + if (log.isDebugEnabled()) { + log.debug("Unknown path info: {}", pi); + } return; } @@ -377,7 +379,9 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) // Fix for ZK-5142 if (!("POST".equals(request.getMethod()))) { response.sendError(HttpServletResponse.SC_NOT_FOUND); - log.debug("Request method is not POST: {}", Servlets.getDetail(request)); + if (log.isDebugEnabled()) { + log.debug("Request method is not POST: {}", Servlets.getDetail(request)); + } return; //done } @@ -436,7 +440,8 @@ public void process(Session sess, HttpServletRequest request, HttpServletRespons final String errClient = request.getHeader("ZK-Error-Report"); if (errClient != null) if (log.isDebugEnabled()) - log.debug("Error found at client: " + errClient + "\n" + Servlets.getDetail(request)); + log.debug("Error found at client: {}\n{}", errClient, + Servlets.getDetail(request)); //parse desktop ID final WebApp wapp = sess.getWebApp(); @@ -451,8 +456,8 @@ public void process(Session sess, HttpServletRequest request, HttpServletRespons if (dtid == null) { //Bug 1929139: incomplete request (IE only) if (log.isDebugEnabled()) { - final String msg = "Incomplete request\n" + Servlets.getDetail(request); - log.debug(msg); + log.debug("Incomplete request\n{}", + Servlets.getDetail(request)); } response.sendError(467, "Incomplete request"); @@ -509,7 +514,9 @@ public void process(Session sess, HttpServletRequest request, HttpServletRespons if (aureqs.isEmpty()) { final String errmsg = "Illegal request: cmd required"; - log.debug(errmsg); + if (log.isDebugEnabled()) { + log.debug(errmsg); + } responseError(request, response, errmsg); return; } diff --git a/zk/src/main/java/org/zkoss/zk/scripting/Interpreters.java b/zk/src/main/java/org/zkoss/zk/scripting/Interpreters.java index 5d7ec5177b4..6f46ebe5085 100644 --- a/zk/src/main/java/org/zkoss/zk/scripting/Interpreters.java +++ b/zk/src/main/java/org/zkoss/zk/scripting/Interpreters.java @@ -1,9 +1,9 @@ /* Interpreters.java Purpose: - + Description: - + History: Fri Feb 2 10:48:47 2007, Created by tomyeh @@ -141,7 +141,7 @@ public static final String add(String zslang, String ipcls) { } if (log.isDebugEnabled()) - log.debug("Scripting language is added: " + zslang + ", " + ipcls); + log.debug("Scripting language is added: {}, {}", zslang, ipcls); _zslangs.add(zslang); final String zsl = zslang.toLowerCase(java.util.Locale.ENGLISH); diff --git a/zk/src/main/java/org/zkoss/zk/ui/EventListenerInfo.java b/zk/src/main/java/org/zkoss/zk/ui/EventListenerInfo.java index 9cb843b4918..e2bd172c903 100644 --- a/zk/src/main/java/org/zkoss/zk/ui/EventListenerInfo.java +++ b/zk/src/main/java/org/zkoss/zk/ui/EventListenerInfo.java @@ -1,9 +1,9 @@ /* EventListenerInfo.java Purpose: - + Description: - + History: Thu Dec 15 19:29:49 TST 2011, Created by tomyeh @@ -66,11 +66,13 @@ try { s.writeObject(li); } catch (java.io.NotSerializableException ex) { - logio.error("Unable to serialize item: " + li.listener); + logio.error("Unable to serialize item: {}", + li.listener); throw ex; } } else if (debug) { - logio.debug("Skip not-serializable item: " + li.listener); + logio.debug("Skip not-serializable item: {}", + li.listener); } } diff --git a/zk/src/main/java/org/zkoss/zk/ui/HtmlShadowElement.java b/zk/src/main/java/org/zkoss/zk/ui/HtmlShadowElement.java index 313cbeba557..e3996023134 100644 --- a/zk/src/main/java/org/zkoss/zk/ui/HtmlShadowElement.java +++ b/zk/src/main/java/org/zkoss/zk/ui/HtmlShadowElement.java @@ -814,7 +814,8 @@ protected void rebuildSubShadowTree() { public void beforeHostChildRemoved(Component child, int indexOfChild) { if (log.isDebugEnabled()) { - log.debug("beforeHostChildRemoved " + child + ", in this shadow " + ShadowElementsCtrl.getCurrentInfo()); + log.debug("beforeHostChildRemoved {}, in this shadow {}", child, + ShadowElementsCtrl.getCurrentInfo()); } Object currentInfo = ShadowElementsCtrl.getCurrentInfo(); @@ -996,7 +997,8 @@ public void onHostChildAdded(Component child) { public void beforeHostParentChanged(Component parent) { if (log.isDebugEnabled()) { - log.debug("beforeHostParentChanged " + parent + ", in this shadow " + ShadowElementsCtrl.getCurrentInfo()); + log.debug("beforeHostParentChanged {}, in this shadow {}", parent, + ShadowElementsCtrl.getCurrentInfo()); } if (parent == null) { ((ComponentCtrl) _host).removeShadowRoot(this); @@ -1007,8 +1009,8 @@ public void beforeHostParentChanged(Component parent) { public void beforeHostChildAdded(Component child, Component insertBefore, int indexOfInsertBefore) { if (log.isDebugEnabled()) { - log.debug("beforeHostChildAdded " + child + ", " + insertBefore + ", in this shadow " - + ShadowElementsCtrl.getCurrentInfo()); + log.debug("beforeHostChildAdded {}, {}, in this shadow {}", child, + insertBefore, ShadowElementsCtrl.getCurrentInfo()); } Object currentInfo = ShadowElementsCtrl.getCurrentInfo(); @@ -1308,7 +1310,8 @@ public static Direction inRange(HtmlShadowElement se, Component target) { public void afterHostChildAdded(Component child, int indexOfChild) { if (log.isDebugEnabled()) { - log.debug("afterHostChildAdded " + child + ", in this shadow " + ShadowElementsCtrl.getCurrentInfo()); + log.debug("afterHostChildAdded {}, in this shadow {}", child, + ShadowElementsCtrl.getCurrentInfo()); } Object currentInfo = ShadowElementsCtrl.getCurrentInfo(); if (currentInfo instanceof HtmlShadowElement) { // added as my child in our control code @@ -1369,7 +1372,8 @@ public void afterHostChildAdded(Component child, int indexOfChild) { public void afterHostChildRemoved(Component child) { if (log.isDebugEnabled()) { - log.debug("afterHostChildRemoved " + child + ", in this shadow " + ShadowElementsCtrl.getCurrentInfo()); + log.debug("afterHostChildRemoved {}, in this shadow {}", child, + ShadowElementsCtrl.getCurrentInfo()); } } diff --git a/zk/src/main/java/org/zkoss/zk/ui/event/impl/DesktopEventQueue.java b/zk/src/main/java/org/zkoss/zk/ui/event/impl/DesktopEventQueue.java index b6a0b89b25b..68aac37cfba 100644 --- a/zk/src/main/java/org/zkoss/zk/ui/event/impl/DesktopEventQueue.java +++ b/zk/src/main/java/org/zkoss/zk/ui/event/impl/DesktopEventQueue.java @@ -1,9 +1,9 @@ /* DesktopEventQueue.java Purpose: - + Description: - + History: Fri May 2 17:44:12 2008, Created by tomyeh @@ -100,12 +100,12 @@ private void subscribe(EventListener listener, EventListener callback, boo if (exec == null) throw new IllegalStateException("Execution required"); ((DesktopCtrl) exec.getDesktop()).enableServerPush(true, this); - //B65-ZK-1840 make sure the flag is true after enabling (otherwise disabling will fail) + //B65-ZK-1840 make sure the flag is true after enabling (otherwise disabling will fail) _serverPushEnabled = true; } if (log.isDebugEnabled()) { - log.debug("Subscribe event queue, async is [" + async + "]"); + log.debug("Subscribe event queue, async is [{}]", async); } _listenerInfos.add(new ListenerInfo(listener, callback, async)); } @@ -120,7 +120,7 @@ public boolean unsubscribe(EventListener listener) { } it.remove(); if (inf.async && --_nAsync == 0 && _serverPushEnabled) - //B65-ZK-1840 added enabler argument for reference counting + //B65-ZK-1840 added enabler argument for reference counting ((DesktopCtrl) Executions.getCurrent().getDesktop()).enableServerPush(false, this); return true; } @@ -144,7 +144,7 @@ public void close() { _listenerInfos.clear(); if (_serverPushEnabled) { try { - //B65-ZK-1840 added enabler argument for reference counting + //B65-ZK-1840 added enabler argument for reference counting ((DesktopCtrl) Executions.getCurrent().getDesktop()).enableServerPush(false, this); } catch (Throwable ex) { log.warn("Ingored: unable to stop server push", ex); diff --git a/zk/src/main/java/org/zkoss/zk/ui/http/DHtmlLayoutFilter.java b/zk/src/main/java/org/zkoss/zk/ui/http/DHtmlLayoutFilter.java index 864e688b8eb..675d76aa582 100644 --- a/zk/src/main/java/org/zkoss/zk/ui/http/DHtmlLayoutFilter.java +++ b/zk/src/main/java/org/zkoss/zk/ui/http/DHtmlLayoutFilter.java @@ -1,9 +1,9 @@ /* DHtmlLayoutFilter.java Purpose: - + Description: - + History: Wed Nov 30 00:49:59 2005, Created by tomyeh @@ -78,7 +78,7 @@ public class DHtmlLayoutFilter implements Filter { protected void process(HttpServletRequest request, HttpServletResponse response, String content) throws ServletException, IOException { if (log.isDebugEnabled()) - log.debug("Content to filter:\n" + content); + log.debug("Content to filter:\n{}", content); final WebManager webman = WebManager.getWebManager(_ctx); final WebApp wapp = webman.getWebApp(); diff --git a/zk/src/main/java/org/zkoss/zk/ui/http/WebManager.java b/zk/src/main/java/org/zkoss/zk/ui/http/WebManager.java index e51bb4e4607..59e90bf4cc2 100644 --- a/zk/src/main/java/org/zkoss/zk/ui/http/WebManager.java +++ b/zk/src/main/java/org/zkoss/zk/ui/http/WebManager.java @@ -1,9 +1,9 @@ /* WebManager.java Purpose: - + Description: - + History: Thu Jun 15 13:28:19 2006, Created by tomyeh @@ -123,15 +123,15 @@ public WebManager(ServletContext ctx, String updateURI) { @SuppressWarnings("deprecation") public WebManager(ServletContext ctx, String updateURI, String resourceURI) { if (log.isDebugEnabled()) - log.debug("Starting WebManager at " + ctx); + log.debug("Starting WebManager at {}", ctx); if (ctx == null || updateURI == null) throw new IllegalArgumentException("null"); if (getWebManagerIfAny(ctx) != null) throw new UiException("Only one Web manager is allowed in one context: " + ctx); - log.info("Starting ZK " + org.zkoss.zk.Version.RELEASE + ' ' + WebApps.getEdition() + " (build: " - + org.zkoss.zk.ui.impl.AbstractWebApp.loadBuild() + ')'); + log.info("Starting ZK {} {} (build: {})", org.zkoss.zk.Version.RELEASE, + WebApps.getEdition(), org.zkoss.zk.ui.impl.AbstractWebApp.loadBuild()); _ctx = ctx; _updateURI = updateURI; @@ -403,7 +403,7 @@ public static final WebApp getWebApp(ServletContext ctx) { /** Called by DHtmlLayoutServlet#init when WebManager is created * by HttpSessionListener#contextInitialized - * + * * @param updateURI the URI for asynchronous update. */ /*package*/ void setUpdateUri(String updateURI) { @@ -540,7 +540,7 @@ public Desktop getDesktop(Session sess, ServletRequest request, ServletResponse Desktop desktop = (Desktop) request.getAttribute(ATTR_DESKTOP); if (desktop == null && autocreate) { if (log.isDebugEnabled()) - log.debug("Create desktop for " + path); + log.debug("Create desktop for {}", path); request.setAttribute(ATTR_DESKTOP, desktop = newDesktop(sess, request, response, path)); } return desktop; diff --git a/zk/src/main/java/org/zkoss/zk/ui/impl/DesktopImpl.java b/zk/src/main/java/org/zkoss/zk/ui/impl/DesktopImpl.java index 8911208f2e9..8f43983afcc 100644 --- a/zk/src/main/java/org/zkoss/zk/ui/impl/DesktopImpl.java +++ b/zk/src/main/java/org/zkoss/zk/ui/impl/DesktopImpl.java @@ -1527,7 +1527,11 @@ private boolean enableServerPush(ServerPush serverPush, boolean enable, Serializ } // B65-ZK-2105: Do not add if enabler is null. if (enabler != null && !enablers.add(enabler)) { - log.debug("trying to enable already enabled serverpush by: " + enabler); + if (log.isDebugEnabled()) { + log.debug( + "trying to enable already enabled serverpush by: {}", + enabler); + } return false; } if (enablersEmptyBefore) { @@ -1536,7 +1540,11 @@ private boolean enableServerPush(ServerPush serverPush, boolean enable, Serializ } else { // B65-ZK-2105: Do remove if enabler is null. if (enabler != null && !enablers.remove(enabler)) { - log.debug("trying to disable already disabled serverpush by: " + enabler); + if (log.isDebugEnabled()) { + log.debug( + "trying to disable already disabled serverpush by: {}", + enabler); + } return false; } // B65-ZK-2105: No need to check if enablers is empty before, it would cause B30-2202620 side effect. diff --git a/zk/src/main/java/org/zkoss/zk/ui/impl/PollingServerPush.java b/zk/src/main/java/org/zkoss/zk/ui/impl/PollingServerPush.java index 79dd321c2c2..e79a2845f53 100644 --- a/zk/src/main/java/org/zkoss/zk/ui/impl/PollingServerPush.java +++ b/zk/src/main/java/org/zkoss/zk/ui/impl/PollingServerPush.java @@ -1,9 +1,9 @@ /* PollingServerPush.java Purpose: - + Description: - + History: Fri Aug 3 18:53:21 2007, Created by tomyeh @@ -316,7 +316,9 @@ public boolean activate(long timeout) throws InterruptedException, DesktopUnavai return false; //timeout } - log.debug("Executions.activate() took more than 10 minutes"); + if (log.isDebugEnabled()) { + log.debug("Executions.activate() took more than 10 minutes"); + } loop = true; //try again } } diff --git a/zk/src/main/java/org/zkoss/zk/ui/impl/RequestQueueImpl.java b/zk/src/main/java/org/zkoss/zk/ui/impl/RequestQueueImpl.java index 6886f0a9c3b..e64c77d86dd 100644 --- a/zk/src/main/java/org/zkoss/zk/ui/impl/RequestQueueImpl.java +++ b/zk/src/main/java/org/zkoss/zk/ui/impl/RequestQueueImpl.java @@ -1,9 +1,9 @@ /* RequestQueueImpl.java Purpose: - + Description: - + History: Fri Jan 20 09:51:39 2006, Created by tomyeh @@ -103,7 +103,7 @@ public void addRequests(Collection requests) { //ignore it since a long request might remove a timer //while clients already queues onTimer generated by the timer if (log.isDebugEnabled()) - log.debug("Ignore request: " + ex.getMessage()); + log.debug("Ignore request: {}", ex.getMessage()); } } } diff --git a/zk/src/main/java/org/zkoss/zk/ui/impl/SimpleDesktopCache.java b/zk/src/main/java/org/zkoss/zk/ui/impl/SimpleDesktopCache.java index 4d21d641350..02ad6493dce 100644 --- a/zk/src/main/java/org/zkoss/zk/ui/impl/SimpleDesktopCache.java +++ b/zk/src/main/java/org/zkoss/zk/ui/impl/SimpleDesktopCache.java @@ -2,9 +2,9 @@ {{IS_NOTE Purpose: - + Description: - + History: Tue Apr 18 13:00:34 2006, Created by tomyeh }}IS_NOTE @@ -220,7 +220,7 @@ public void sessionDidActivate(Session sess) { public void stop() { if (log.isDebugEnabled()) - log.debug("Invalidated and remove: " + _desktops); + log.debug("Invalidated and remove: {}", _desktops); final boolean old = _desktops.disableExpunge(true); try { ArrayList desktops = null; @@ -277,7 +277,7 @@ protected void onExpunge(Value v) { desktopDestroyed(v.getValue()); if (log.isDebugEnabled()) - log.debug("Expunge desktop: " + v.getValue()); + log.debug("Expunge desktop: {}", v.getValue()); } private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { diff --git a/zk/src/main/java/org/zkoss/zk/ui/impl/UiEngineImpl.java b/zk/src/main/java/org/zkoss/zk/ui/impl/UiEngineImpl.java index c1432c6fbf8..f77b7f3ca37 100644 --- a/zk/src/main/java/org/zkoss/zk/ui/impl/UiEngineImpl.java +++ b/zk/src/main/java/org/zkoss/zk/ui/impl/UiEngineImpl.java @@ -1517,8 +1517,9 @@ private static final void handleError(Throwable ex, UiVisualizer uv, List zkex -> zkmax. User-supplied ThemeProvider, ThemeRegistry, // and ThemeResolver will not get overridden by using flag variables. But multiple such // configurations in different metainfo/zk/zk.xml still needs to be resolved by the assistance @@ -566,7 +566,7 @@ private static void parseDesktopConfig(Configuration config, Element conf) throw if (!cls.getName().startsWith("org.zkoss.")) config.setCustomThemeProvider(true); if (log.isDebugEnabled()) - log.debug("ThemeProvider: " + cls.getName()); + log.debug("ThemeProvider: {}", cls.getName()); config.setThemeProvider((ThemeProvider) cls.newInstance()); } } @@ -579,7 +579,7 @@ private static void parseDesktopConfig(Configuration config, Element conf) throw if (!cls.getName().startsWith("org.zkoss.")) config.setCustomThemeRegistry(true); if (log.isDebugEnabled()) - log.debug("ThemeRegistry: " + cls.getName()); + log.debug("ThemeRegistry: {}", cls.getName()); ThemeFns.setThemeRegistry((ThemeRegistry) cls.newInstance()); } } @@ -592,7 +592,7 @@ private static void parseDesktopConfig(Configuration config, Element conf) throw if (!cls.getName().startsWith("org.zkoss.")) config.setCustomThemeResolver(true); if (log.isDebugEnabled()) - log.debug("ThemeResolver: " + cls.getName()); + log.debug("ThemeResolver: {}", cls.getName()); ThemeFns.setThemeResolver((ThemeResolver) cls.newInstance()); } } @@ -602,7 +602,7 @@ private static void parseDesktopConfig(Configuration config, Element conf) throw cls = parseClass(conf, "theme-uri-handler-class", ThemeURIHandler.class); if (cls != null) { if (log.isDebugEnabled()) - log.debug("ThemeURIHandler: " + cls.getName()); + log.debug("ThemeURIHandler: {}", cls.getName()); config.addThemeURIHandler((ThemeURIHandler) cls.newInstance()); } diff --git a/zk/src/main/java/org/zkoss/zk/ui/util/ConventionWires.java b/zk/src/main/java/org/zkoss/zk/ui/util/ConventionWires.java index 6adc5c62184..564483213d0 100644 --- a/zk/src/main/java/org/zkoss/zk/ui/util/ConventionWires.java +++ b/zk/src/main/java/org/zkoss/zk/ui/util/ConventionWires.java @@ -1,9 +1,9 @@ /* ConventionWires.java Purpose: - + Description: - + History: Thu Dec 8 13:04:09 TST 2011, Created by tomyeh @@ -47,24 +47,24 @@ public class ConventionWires { private static final Logger log = LoggerFactory.getLogger(ConventionWires.class); - /** Wire fellow components and space owner ancestors of the specified - * Id space into a controller Java object. This implementation checks the + /** Wire fellow components and space owner ancestors of the specified + * Id space into a controller Java object. This implementation checks the * setXxx() method names first then the * field names. If a setXxx() method name matches the id of a fellow or - * space owner ancestors and with correct - * argument type, the found method is called with the fellow component as the - * argument. If no proper setXxx() method then search the field of the - * controller object for a matched field with name equals to the fellow - * component's id and proper type. Then the fellow component + * space owner ancestors and with correct + * argument type, the found method is called with the fellow component as the + * argument. If no proper setXxx() method then search the field of the + * controller object for a matched field with name equals to the fellow + * component's id and proper type. Then the fellow component * is assigned as the value of the matched field. - * + * *

Note that fellow components are looked up first, then the space owner * ancestors

- *

since 3.5.2, the controller would be assigned as a variable of the given idspace + *

since 3.5.2, the controller would be assigned as a variable of the given idspace * per the naming convention composed of the idspace id and controller Class name. e.g. - * if the idspace id is "xwin" and the controller class is + * if the idspace id is "xwin" and the controller class is * org.zkoss.MyController, then the variable name would be "xwin$MyController"

- * + * *

This is useful in writing controller code in MVC design practice. You * can wire the components into the controller object per the * component's id and do whatever you like.

@@ -72,7 +72,7 @@ public class ConventionWires { *

Since 3.6.0, for Groovy or other environment that * '$' is not applicable, you can invoke {@link #wireFellows(IdSpace,Object,char)} * to use '_' as the separator. - * + * * @param idspace the id space to be bound * @param controller the controller Java object to be injected the fellow components. */ @@ -104,35 +104,35 @@ public static final void wireFellows(IdSpace idspace, Object controller, char se new ConventionWire(controller, separator, ignoreZScript, ignoreXel).wireFellows(idspace); } - /**

Wire accessible variable objects of the specified component into a - * controller Java object. This implementation checks the - * setXxx() method names first then the field names. If a setXxx() method - * name matches the name of the resolved variable object with correct - * argument type and the associated field value is null, then the method is - * called with the resolved variable object as the argument. - * If no proper setXxx() method then search the + /**

Wire accessible variable objects of the specified component into a + * controller Java object. This implementation checks the + * setXxx() method names first then the field names. If a setXxx() method + * name matches the name of the resolved variable object with correct + * argument type and the associated field value is null, then the method is + * called with the resolved variable object as the argument. + * If no proper setXxx() method then search the * field name of the controller object. If the field name matches the name * of the resolved variable object with correct field type and null field * value, the field is then assigned the resolved variable object. - *

- * + *

+ * *

The controller would be assigned as a variable of the given component * per the naming convention composed of the component id and controller Class name. e.g. - * if the component id is "xwin" and the controller class is + * if the component id is "xwin" and the controller class is * org.zkoss.MyController, then the variable name would be "xwin$MyController"

* *

This is useful in writing controller code in MVC design practice. You - * can wire the embedded objects, components, and accessible variables into - * the controller object per the components' id and variables' name and do + * can wire the embedded objects, components, and accessible variables into + * the controller object per the components' id and variables' name and do * whatever you like. *

- + *

Since 3.6.0, for Groovy or other environment that * '$' is not applicable, you can invoke {@link #wireVariables(Component,Object,char)} * to use '_' as the separator. - * + * * @param comp the reference component to wire variables - * @param controller the controller Java object to be injected the + * @param controller the controller Java object to be injected the * accessible variable objects. * @see org.zkoss.zk.ui.util.GenericAutowireComposer */ @@ -164,34 +164,34 @@ public static final void wireVariables(Component comp, Object controller, char s new ConventionWire(controller, separator, ignoreZScript, ignoreXel).wireVariables(comp); } - /**

Wire accessible variables of the specified page into a - * controller Java object. This implementation checks the - * setXxx() method names first then the field names. If a setXxx() method - * name matches the name of the resolved variable object with correct - * argument type and the associated field value is null, then the method is - * called with the resolved variable object as the argument. - * If no proper setXxx() method then search the + /**

Wire accessible variables of the specified page into a + * controller Java object. This implementation checks the + * setXxx() method names first then the field names. If a setXxx() method + * name matches the name of the resolved variable object with correct + * argument type and the associated field value is null, then the method is + * called with the resolved variable object as the argument. + * If no proper setXxx() method then search the * field name of the controller object. If the field name matches the name * of the resolved variable object with correct field type and null field - * value, the field is then assigned the resolved variable object.

+ * value, the field is then assigned the resolved variable object.

* - *

The controller would be assigned as a variable of the given page + *

The controller would be assigned as a variable of the given page * per the naming convention composed of the page id and controller Class name. e.g. - * if the page id is "xpage" and the controller class is + * if the page id is "xpage" and the controller class is * org.zkoss.MyController, then the variable name would be "xpage$MyController"

* *

Since 3.0.8, if the method name of field name matches the ZK implicit - * object name, ZK implicit object will be wired in, too.

+ * object name, ZK implicit object will be wired in, too.

*

This is useful in writing controller code in MVC design practice. You - * can wire the embedded objects, components, and accessible variables into - * the controller object per the component's id and variable name and do + * can wire the embedded objects, components, and accessible variables into + * the controller object per the component's id and variable name and do * whatever you like. *

- * + * *

Since 3.6.0, for Groovy or other environment that * '$' is not applicable, you can invoke {@link #wireVariables(Page,Object,char)} * to use '_' as the separator. - * + * * @param page the reference page to wire variables * @param controller the controller Java object to be injected the fellow components. */ @@ -360,8 +360,8 @@ private static String composerNameByClass(String id, Class cls, char separator) return id + separator + (j >= 0 ? clsname.substring(j + 1) : clsname); } - /**Wire implicit variables of the specified component into a controller Java object. - * + /**Wire implicit variables of the specified component into a controller Java object. + * * @param comp the component * @param controller the controller object */ @@ -369,27 +369,27 @@ public static final void wireImplicit(Component comp, Object controller) { new ConventionWire(controller, '$', true, true).wireImplicit(comp); } - /**

Adds forward conditions to myid source component so onXxx source - * event received by - * myid component can be forwarded to the specified target - * component with the target event name onXxx$myid.

- *

The controller is a POJO file with onXxx$myid methods (the event handler - * codes). This utility method search such onXxx$myid methods and adds - * forward condition to the source myid component looked up by - * {@link Component#getAttributeOrFellow} of the specified component, so you - * don't have to specify in zul file the "forward" attribute one by one. - * If the source component cannot be looked up or the object looked up is + /**

Adds forward conditions to myid source component so onXxx source + * event received by + * myid component can be forwarded to the specified target + * component with the target event name onXxx$myid.

+ *

The controller is a POJO file with onXxx$myid methods (the event handler + * codes). This utility method search such onXxx$myid methods and adds + * forward condition to the source myid component looked up by + * {@link Component#getAttributeOrFellow} of the specified component, so you + * don't have to specify in zul file the "forward" attribute one by one. + * If the source component cannot be looked up or the object looked up is * not a component, this method will log the error and ignore it. *

- *

Cascaded '$' will add Forwards cascadedly. E.g. define method - * onClick$btn$w1 in window w2. This method will add a forward on the button + *

Cascaded '$' will add Forwards cascadedly. E.g. define method + * onClick$btn$w1 in window w2. This method will add a forward on the button * "btn.onClick=w1.onClick$btn" and add another forward on the window w1 * "w1.onClick$btn=w2.onClick$btn$w1"

- * + * *

Since 3.6.0, for Groovy or other environment that * '$' is not applicable, you can invoke {@link #addForwards(Component,Object,char)} * to use '_' as the separator. - * + * * @param comp the targetComponent * @param controller the controller code with onXxx$myid event handler methods */ @@ -428,7 +428,9 @@ public static void addForwards(Component comp, Object controller, char separator } if (srccomp == null || !(srccomp instanceof Component)) { if (log.isDebugEnabled()) - log.debug("Cannot find the associated component to forward event: " + mdname); + log.debug( + "Cannot find the associated component to forward event: {}", + mdname); break; } else { ((Component) srccomp).addForward(srcevt, xcomp, mdname); diff --git a/zk/src/main/java/org/zkoss/zk/ui/util/GenericAutowireComposer.java b/zk/src/main/java/org/zkoss/zk/ui/util/GenericAutowireComposer.java index 0524357ff97..5e0b26dda0b 100644 --- a/zk/src/main/java/org/zkoss/zk/ui/util/GenericAutowireComposer.java +++ b/zk/src/main/java/org/zkoss/zk/ui/util/GenericAutowireComposer.java @@ -1,8 +1,8 @@ /* GenericAutowireComposer.java Purpose: - + Description: - + History: Jun 11, 2008 10:56:06 AM, Created by henrichen @@ -39,27 +39,27 @@ import org.zkoss.zk.ui.event.SerializableEventListener; /** - *

A skeletal composer that you can extend and write intuitive onXxx + *

A skeletal composer that you can extend and write intuitive onXxx * event handler methods with "auto-wired" accessible variable objects such - * as implicit objects, components, and external resolvable variables in a ZK - * zuml page. This class will registers onXxx events to the supervised - * component and wire all accessible variable objects to this composer by - * calling setXxx() method or set xxx field value directly per the variable - * name. Since 3.0.7, this composer has wired all implicit objects - * such as self, spaceOwner, page, desktop, session, application, - * componentScope, spaceScope, pageScope, desktopScope, sessionScope, - * applicationScope, and requestScope, so you can use them directly. Besides - * that, it also provides alert(String message) method, so you can call alert() - * without problems. Since 3.5.2, the composer itself would be assigned as an - * attribute of the supervised component per the naming convention of - * the component id and composer class name or of component id and "composer". - * e.g. If the component id is "mywin" and the composer class is org.zkoss.MyComposer, - * then the composer can be referenced by the variable name of "mywin$MyController" or + * as implicit objects, components, and external resolvable variables in a ZK + * zuml page. This class will registers onXxx events to the supervised + * component and wire all accessible variable objects to this composer by + * calling setXxx() method or set xxx field value directly per the variable + * name. Since 3.0.7, this composer has wired all implicit objects + * such as self, spaceOwner, page, desktop, session, application, + * componentScope, spaceScope, pageScope, desktopScope, sessionScope, + * applicationScope, and requestScope, so you can use them directly. Besides + * that, it also provides alert(String message) method, so you can call alert() + * without problems. Since 3.5.2, the composer itself would be assigned as an + * attribute of the supervised component per the naming convention of + * the component id and composer class name or of component id and "composer". + * e.g. If the component id is "mywin" and the composer class is org.zkoss.MyComposer, + * then the composer can be referenced by the variable name of "mywin$MyController" or * "mywin$composer". Notice that the '$' separator can be changed to other character * such as '_' for Groovy or other environment that '$' is not applicable. Simply * extends this class and calling {@link #GenericAutowireComposer(char separator)} * constructor with proper separator character.

- * + * *

Alternatives: in most cases, you don't extend from {@link GenericAutowireComposer} directly. * Rather, you can extend from one of the following skeletons. *

@@ -74,19 +74,19 @@ * *

Notice that since this composer kept references to the components, single * instance composer object cannot be shared by multiple components.

- * - *

The following is an example. The onOK event listener is registered into + * + *

The following is an example. The onOK event listener is registered into * the target window, and the Textbox component with id name "mytextbox" is - * injected into the "mytextbox" field automatically (so you can use - * mytextbox variable directly in onOK). The "value" property of "mytextbox" + * injected into the "mytextbox" field automatically (so you can use + * mytextbox variable directly in onOK). The "value" property of "mytextbox" * is assigned with composer's getTitle(), i.e. "ZK".

- * + * *

  * MyComposer.java
- * 
+ *
  * public class MyComposer extends GenericAutowireComposer {
  *     private Textbox mytextbox;
- *     
+ *
  *     public void onOK() {
  *         mytextbox.setValue("Enter Pressed");
  *         alert("Hi!");
@@ -95,9 +95,9 @@
  *         return "ZK";
  *     }
  * }
- * 
+ *
  * test.zul
- * 
+ *
  * <window id="mywin" apply="MyComposer">
  *     <textbox id="mytextbox" value="${mywin$composer.title}"/>
  * </window>
@@ -111,7 +111,7 @@
  *     <textbox id="mytextbox" value="${mc.title}"/>
  * </window>
  * 
- * + * * @author henrichen * @since 3.0.6 * @see ConventionWires @@ -123,7 +123,7 @@ public abstract class GenericAutowireComposer extends Gener private static final String ON_CLONE_DO_AFTER_COMPOSE = "onCLONE_DO_AFTER_COMPOSE"; private static Logger log = LoggerFactory.getLogger(GenericAutowireComposer.class); - /** Implicit Object; the applied component itself. + /** Implicit Object; the applied component itself. * @since 3.0.7 */ protected transient T self; @@ -209,7 +209,7 @@ public abstract class GenericAutowireComposer extends Gener *

In other words, whether to ignore variables defined in ZSCRIPT and XEL depends * on the library variables called org.zkoss.zk.ui.composer.autowire.zscript * and org.zkoss.zk.ui.composer.autowire.xel. - * Furthermore, if not specified, their values are default to false, i.e., + * Furthermore, if not specified, their values are default to false, i.e., * they shall not be wired (i.e., shall be ignored) *

If you want to control whether to wire ZSCRIPT's or XEL's variable * explicitly, you could use @@ -234,7 +234,7 @@ protected GenericAutowireComposer() { *

In other words, whether to ignore variables defined in ZSCRIPT and XEL depends * on the library variables called org.zkoss.zk.ui.composer.autowire.zscript * and org.zkoss.zk.ui.composer.autowire.xel. - * Furthermore, if not specified, their values are default to false, i.e., + * Furthermore, if not specified, their values are default to false, i.e., * they shall not be wired (i.e., shall be ignored) *

If you want to control whether to wire ZSCRIPT's or XEL's variable * explicitly, you could use @@ -294,9 +294,9 @@ protected Page getPage() { } /** - * Auto wire accessible variables of the specified component into a - * controller Java object; a subclass that - * override this method should remember to call super.doAfterCompose(comp) + * Auto wire accessible variables of the specified component into a + * controller Java object; a subclass that + * override this method should remember to call super.doAfterCompose(comp) * or it will not work. */ public void doAfterCompose(T comp) throws Exception { @@ -320,7 +320,7 @@ public void onEvent(CreateEvent event) throws Exception { } /** Shortcut to call Messagebox.show(String). - * @since 3.0.7 + * @since 3.0.7 */ private static Method _alert; @@ -336,7 +336,9 @@ protected void alert(String m) { _alert.invoke(null, new Object[] { m }); return; //done } catch (Throwable ex) { - log.debug("Failed to invoke org.zkoss.zul.Messagebox", ex); + if (log.isDebugEnabled()) { + log.debug("Failed to invoke org.zkoss.zul.Messagebox", ex); + } //Ignore } } @@ -344,12 +346,12 @@ protected void alert(String m) { org.zkoss.zk.ui.util.Clients.alert(m); } - //ComponentCloneListener - /** Internal use only. Call-back method of CloneComposerListener. You shall - * not call this method directly. Clone this Composer when its applied + //ComponentCloneListener + /** Internal use only. Call-back method of CloneComposerListener. You shall + * not call this method directly. Clone this Composer when its applied * component is cloned. * @param comp the clone of the applied component - * @return A clone of this Composer. + * @return A clone of this Composer. * @since 3.5.2 */ public Object willClone(Component comp) { @@ -361,7 +363,7 @@ public Object willClone(Component comp) { composerClone = (Composer) Classes.newInstance(getClass(), null); exec.setAttribute(COMPOSER_CLONE + idcode, composerClone); - //cannot call doAfterCompose directly because the clone + //cannot call doAfterCompose directly because the clone //component might not be attach to Page yet comp.addEventListener(ON_CLONE_DO_AFTER_COMPOSE, new CloneDoAfterCompose()); Events.postEvent(new Event(ON_CLONE_DO_AFTER_COMPOSE, comp, composerClone)); diff --git a/zkbind/src/main/java/org/zkoss/bind/impl/BinderImpl.java b/zkbind/src/main/java/org/zkoss/bind/impl/BinderImpl.java index 79143df7bf5..ed81201d495 100644 --- a/zkbind/src/main/java/org/zkoss/bind/impl/BinderImpl.java +++ b/zkbind/src/main/java/org/zkoss/bind/impl/BinderImpl.java @@ -1,9 +1,9 @@ /* BinderImpl.java Purpose: - + Description: - + History: Jul 29, 2011 6:08:51 PM, Created by henrichen @@ -175,7 +175,7 @@ public class BinderImpl implements Binder, BinderCtrl, Serializable { private static final Map, Map>> _globalCommandMethodCache = DISABLE_METHOD_CACHE ? new EmptyCacheMap() : new CacheMap, Map>>( 200, CacheMap.DEFAULT_LIFETIME); //class,map - //command and default command method parsing and caching + //command and default command method parsing and caching private static final CachedItem NULL_METHOD = new CachedItem(null); private static final String COMMAND_METHOD_MAP_INIT = "$INIT_FLAG$"; private static final String COMMAND_METHOD_DEFAULT = "$DEFAULT_FLAG$"; @@ -231,7 +231,7 @@ public boolean isDefaultMethod(Method method) { private final ReferenceBindingHandler _refBindingHandler; /* the relation of form and inner save-bindings */ - private Map> _assocFormSaveBindings; //form comp -> savebindings + private Map> _assocFormSaveBindings; //form comp -> savebindings private Map>> _reversedAssocFormSaveBindings; //associated comp -> binding -> associated save bindings of _formSaveBindingMap private final Map _listenerMap; //comp+evtnm -> eventlistener @@ -302,8 +302,8 @@ public BinderImpl(String qname, String qscope) { _hasValidators = new HashSet(); _templateResolvers = new HashMap>(); _listenerMap = new HashMap(); - //use same queue name if user was not specified, - //this means, binder in same scope, same queue, they will share the notification by "base"."property" + //use same queue name if user was not specified, + //this means, binder in same scope, same queue, they will share the notification by "base"."property" _quename = qname != null && !Strings.isEmpty(qname) ? qname : DEFAULT_QUEUE_NAME; _quescope = qscope != null && !Strings.isBlank(qscope) ? qscope : DEFAULT_QUEUE_SCOPE; _queueListener = new QueueListener(); @@ -322,7 +322,7 @@ private void init() { } } } - + /** * @since 6.0.1 */ @@ -330,13 +330,13 @@ public void init(Component comp, Object viewModel, Map initArgs) if (_init) throw new UiException("binder is already initialized"); _init = true; - + _rootComp = comp; //initial associated view model setViewModel(viewModel); _dummyTarget.addEventListener(ON_POST_COMMAND, new PostCommandListener()); _dummyTarget.addEventListener(ON_VMSGS_CHANGED, new VMsgsChangedListener()); - + initQueue(); if (viewModel instanceof Composer && !(viewModel instanceof BindComposer)) { //do we need to warn this? @@ -447,12 +447,11 @@ public Map> getBindings(Component comp) { //called when onPropertyChange is fired to the subscribed event queue private void doPropertyChange(Object base, String prop) { - String debugInfo = MessageFormat.format("doPropertyChange: base=[{0}],prop=[{1}]", base, prop); if (_log.isDebugEnabled()) { - _log.debug(debugInfo); + _log.debug("doPropertyChange: base=[{}],prop=[{}]", base, prop); } - //zk-1468, + //zk-1468, //ignore a coming ref-binding if the binder is the same since it was loaded already. if (base instanceof ReferenceBinding && ((ReferenceBinding) base).getBinder() == this) { return; @@ -508,21 +507,20 @@ private void doPropertyChange0(Object base, String prop, Set bindin BindContextUtil.setConverterArgs(this, comp, ctx, (PropertyBinding) binding); } - String debugInfo = MessageFormat.format("doPropertyChange:binding.load() " - + "binding=[{0}],context=[{1}]", binding, ctx); try { if (_log.isDebugEnabled()) { - _log.debug(debugInfo); + _log.debug("doPropertyChange:binding.load() binding=[{}],context=[{}]", binding, ctx); } doPrePhase(Phase.LOAD_BINDING, ctx); binding.load(ctx); } catch (Exception ex) { - throw new RuntimeException(debugInfo, ex); + throw new RuntimeException(MessageFormat.format("doPropertyChange:binding.load() " + + "binding=[{0}],context=[{1}]", binding, ctx), ex); } finally { doPostPhase(Phase.LOAD_BINDING, ctx); } - //zk-1468, + //zk-1468, //notify the ref-binding changed since other nested binder might use it if (binding instanceof ReferenceBinding && binding != base) { notifyChange(binding, "."); @@ -675,7 +673,7 @@ public Validator getValidator(String name) { return validator; } - //Note: assume system renderer is state-less + //Note: assume system renderer is state-less protected Object getRenderer(String name) { Object renderer = RENDERERS.get(name); if (renderer == null && name.indexOf('.') > 0) { //might be a class path @@ -700,7 +698,7 @@ public BindEvaluatorX getEvaluatorX() { public void storeForm(Component comp, String id, Form form) { final String oldid = (String) comp.getAttribute(FORM_ID, Component.COMPONENT_SCOPE); - //check if a form exist already, allow to store a form with same id again for replacing the form + //check if a form exist already, allow to store a form with same id again for replacing the form if (oldid != null && !oldid.equals(id)) { throw new IllegalArgumentException( "try to store 2 forms in same component id : 1st " + oldid + ", 2nd " + id); @@ -716,7 +714,7 @@ public void storeForm(Component comp, String id, Form form) { if (form instanceof FormLegacyExt) { final FormLegacyExt fex = (FormLegacyExt) form; comp.setAttribute(id + "Status", fex.getStatus()); //by convention fxStatus - + if (oldForm instanceof FormLegacyExt) { //copy the filed information, this is for a form-init that assign a user form for (String fn : ((FormLegacyExt) oldForm).getLoadFieldNames()) { fex.addLoadFieldName(fn); @@ -1246,9 +1244,9 @@ private void addPropertyLoadBindings0(Component comp, String attr, String loadEx final BindingKey bkey = getBindingKey(comp, evtnm); _propertyBindingHandler.addLoadEventBinding(comp, bkey, binding); } - //if no command , always add to prompt binding, a prompt binding will be load when , + //if no command , always add to prompt binding, a prompt binding will be load when , //1.load a component property binding - //2.property change (TODO, DENNIS, ISSUE, I think loading of property change is triggered by tracker in doPropertyChange, not by prompt-binding + //2.property change (TODO, DENNIS, ISSUE, I think loading of property change is triggered by tracker in doPropertyChange, not by prompt-binding final BindingKey bkey = getBindingKey(comp, attr); _propertyBindingHandler.addLoadPromptBinding(comp, bkey, binding); @@ -1299,7 +1297,7 @@ private void addPropertySaveBindings0(Component comp, String attr, String saveEx Map converterArgs, String validatorExpr, Map validatorArgs) { final boolean prompt = isPrompt(beforeCmds, afterCmds); final BindingExecutionInfoCollector collector = getBindingExecutionInfoCollector(); - //check attribute _accessInfo natural characteristics to register Command event listener + //check attribute _accessInfo natural characteristics to register Command event listener final ComponentCtrl compCtrl = (ComponentCtrl) comp; final Annotation ann = AnnotationUtil.getSystemAnnotation(compCtrl, attr); //check which attribute of component should fire save on which event. @@ -1642,7 +1640,7 @@ private void onEvent0(Event event) throws Exception { //command need to be confirmed shall be execute first! //must sort the command sequence? - //BUG 619, event may come from children of some component, + //BUG 619, event may come from children of some component, //ex tabbox.onSelect is form tab, so we cannot depend on event's target final Component comp = _target; //_target is always equals _commandBinding.getComponent(); final String evtnm = event.getName(); @@ -1655,9 +1653,9 @@ private void onEvent0(Event event) throws Exception { _log.debug("====Start command event [{}]", event); } //BUG ZK-757, The timing of saving textbox's value attribute to ViewModel is later than command execution on onChange event - //We should save the prompt with validation first. + //We should save the prompt with validation first. //For a prompt binding that also binds with a command, that should not be mixed with command - //If user concern the timing of prompt save and validation with command, they should use condition not prompt + //If user concern the timing of prompt save and validation with command, they should use condition not prompt if (_prompt) { promptResult = BinderImpl.this.doSaveEvent(comp, event, notifys); //save on event } @@ -1797,7 +1795,7 @@ public void postCommand(String command, Map args) { * @param evt event that fire this command, nullable * @param commandArgs the passed in argument for executing command * @param notifys container for properties that is to be notifyChange - * @return the result of the doCommand, COMMAND_SUCCESS or COMMAND_FAIL_VALIDATE + * @return the result of the doCommand, COMMAND_SUCCESS or COMMAND_FAIL_VALIDATE */ private int doCommand(Component comp, CommandBinding commandBinding, String command, Event evt, Map commandArgs, Set notifys) { @@ -1805,7 +1803,7 @@ private int doCommand(Component comp, CommandBinding commandBinding, String comm String debugInfo = MessageFormat.format("doCommand " + "comp=[{0}],command=[{1}],evtnm=[{2}]", comp, command, evtnm); if (_log.isDebugEnabled()) { - _log.debug("Start " + debugInfo); + _log.debug("Start {}", debugInfo); } BindContext ctx = BindContextUtil.newBindContext(this, commandBinding, false, command, comp, evt); BindContextUtil.setCommandArgs(this, comp, ctx, commandArgs); @@ -1858,7 +1856,7 @@ private void doGlobalCommand(Component comp, String command, Event evt, Map notifys) { String debugInfo = MessageFormat.format("doGlobalCommand comp=[{0}],command=[{1}]", comp, command); if (_log.isDebugEnabled()) { - _log.debug("Start " + debugInfo); + _log.debug("Start {}", debugInfo); } BindContext ctx = BindContextUtil.newBindContext(this, null, false, command, comp, evt); @@ -1883,10 +1881,10 @@ private void doGlobalCommand(Component comp, String command, Event evt, Map commandArgs, BindContext ctx, Set notifys) { - String debugInfo = MessageFormat.format("doGlobalCommandExecute comp=[{0}],command=[{1}]", comp, command); + String debugInfo = MessageFormat.format("doGlobalCommandExecute comp=[{0}],command=[{1}]", comp, command); try { if (_log.isDebugEnabled()) { - _log.debug("before " + debugInfo); + _log.debug("before {}", debugInfo); } doPrePhase(Phase.EXECUTE, ctx); @@ -1978,7 +1976,7 @@ static void handleNotifyChange(BindContext ctx, Object viewModel, } } - //for event -> prompt only, no command + //for event -> prompt only, no command private boolean doSaveEvent(Component comp, Event evt, Set notifys) { final String evtnm = evt == null ? null : evt.getName(); if (_log.isDebugEnabled()) { @@ -2000,11 +1998,9 @@ private void doLoadEvent(Component comp, Event evt) { //doCommand -> doValidate protected boolean doValidate(Component comp, String command, Event evt, BindContext ctx, Set notifys) { final Set validates = new HashSet(); - String debugInfo = MessageFormat.format("doValidate " - + "comp=[{0}],command=[{1}],evt=[{2}],context=[{3}]", comp, command, evt, ctx); try { if (_log.isDebugEnabled()) { - _log.debug(debugInfo); + _log.debug("doValidate comp=[{}],command=[{}],evt=[{}],context=[{}]", comp, command, evt, ctx); } doPrePhase(Phase.VALIDATE, ctx); @@ -2042,7 +2038,6 @@ public BindingKey getBindingKey(Component comp, String attr) { if (_log.isDebugEnabled()) { _log.debug("doValidate validates=[{}]", validates); } - debugInfo += MessageFormat.format(",validates=[{0}]", validates); boolean valid = true; //ZK-878 Exception if binding a form with errorMessage @@ -2073,7 +2068,7 @@ public BindingKey getBindingKey(Component comp, String attr) { return valid; } } catch (Exception e) { - _log.error(debugInfo, e); + _log.error("doValidate comp=[{}],command=[{}],evt=[{}],context=[{}],validates=[{}]", comp, command, evt, ctx, validates, e); throw UiException.Aide.wrap(e, e.getMessage()); } finally { doPostPhase(Phase.VALIDATE, ctx); @@ -2098,8 +2093,6 @@ protected ParamCall createParamCall(BindContext ctx) { protected void doExecute(Component comp, String command, Map commandArgs, BindContext ctx, Set notifys) { - String debugInfo = MessageFormat.format("doExecute " - + "comp=[{0}],command=[{1}],notifys=[{2}]", comp, command, notifys); try { Matcher matcher = CALL_OTHER_VM_COMMAND_PATTERN.matcher(command); if (matcher.find()) { @@ -2112,7 +2105,7 @@ protected void doExecute(Component comp, String command, Map com } } if (_log.isDebugEnabled()) { - _log.debug("before " + debugInfo); + _log.debug("before doExecute comp=[{}],command=[{}],notifys=[{}]", comp, command, notifys); } doPrePhase(Phase.EXECUTE, ctx); @@ -2147,7 +2140,7 @@ protected void doExecute(Component comp, String command, Map com _log.debug("after doExecute notifys=[{}]", notifys); } } catch (Exception ex) { - throw new RuntimeException(debugInfo, ex); + throw new RuntimeException(MessageFormat.format("doExecute comp=[{0}],command=[{1}],notifys=[{2}]", comp, command, notifys), ex); } finally { doPostPhase(Phase.EXECUTE, ctx); } @@ -2238,34 +2231,32 @@ private Method getCommandMethod(Class clz, String command, CommandMethodInfoP //doCommand -> doSaveBefore protected void doSaveBefore(Component comp, String command, Event evt, BindContext ctx, Set notifys) { - String debugInfo = MessageFormat.format("doSaveBefore " - + "comp=[{0}],command=[{1}],evt=[{2}],notifys=[{3}]", comp, command, evt, notifys); if (_log.isDebugEnabled()) { - _log.debug(debugInfo); + _log.debug("doSaveBefore comp=[{}],command=[{}],evt=[{}],notifys=[{}]", comp, command, evt, notifys); } try { doPrePhase(Phase.SAVE_BEFORE, ctx); _propertyBindingHandler.doSaveBefore(comp, command, evt, notifys); _formBindingHandler.doSaveBefore(comp, command, evt, notifys); } catch (Exception ex) { - throw new RuntimeException(debugInfo, ex); + throw new RuntimeException(MessageFormat.format("doSaveBefore " + + "comp=[{0}],command=[{1}],evt=[{2}],notifys=[{3}]", comp, command, evt, notifys), ex); } finally { doPostPhase(Phase.SAVE_BEFORE, ctx); } } protected void doSaveAfter(Component comp, String command, Event evt, BindContext ctx, Set notifys) { - String debugInfo = MessageFormat.format("doSaveAfter " - + "comp=[{0}],command=[{1}],evt=[{2}],notifys=[{3}]", comp, command, evt, notifys); if (_log.isDebugEnabled()) { - _log.debug(debugInfo); + _log.debug("doSaveAfter comp=[{}],command=[{}],evt=[{}],notifys=[{}]", comp, command, evt, notifys); } try { doPrePhase(Phase.SAVE_AFTER, ctx); _propertyBindingHandler.doSaveAfter(comp, command, evt, notifys); _formBindingHandler.doSaveAfter(comp, command, evt, notifys); } catch (Exception ex) { - throw new RuntimeException(debugInfo, ex); + throw new RuntimeException(MessageFormat.format("doSaveAfter " + + "comp=[{0}],command=[{1}],evt=[{2}],notifys=[{3}]", comp, command, evt, notifys), ex); } finally { doPostPhase(Phase.SAVE_AFTER, ctx); } @@ -2273,9 +2264,8 @@ protected void doSaveAfter(Component comp, String command, Event evt, BindContex } protected void doLoadBefore(Component comp, String command, BindContext ctx) { - String debugInfo = MessageFormat.format("doLoadBefore comp=[{0}],command=[{1}]", comp, command); if (_log.isDebugEnabled()) { - _log.debug(debugInfo); + _log.debug("doLoadBefore comp=[{}],command=[{}]", comp, command); } try { doPrePhase(Phase.LOAD_BEFORE, ctx); @@ -2283,16 +2273,15 @@ protected void doLoadBefore(Component comp, String command, BindContext ctx) { _formBindingHandler.doLoadBefore(comp, command); _childrenBindingHandler.doLoadBefore(comp, command); } catch (Exception ex) { - throw new RuntimeException(debugInfo, ex); + throw new RuntimeException(MessageFormat.format("doLoadBefore comp=[{0}],command=[{1}]", comp, command), ex); } finally { doPostPhase(Phase.LOAD_BEFORE, ctx); } } protected void doLoadAfter(Component comp, String command, BindContext ctx) { - String debugInfo = MessageFormat.format("doLoadAfter comp=[{0}],command=[{1}]", comp, command); if (_log.isDebugEnabled()) { - _log.debug(debugInfo); + _log.debug("doLoadAfter comp=[{}],command=[{}]", comp, command); } try { doPrePhase(Phase.LOAD_AFTER, ctx); @@ -2300,7 +2289,7 @@ protected void doLoadAfter(Component comp, String command, BindContext ctx) { _formBindingHandler.doLoadAfter(comp, command); _childrenBindingHandler.doLoadAfter(comp, command); } catch (Exception ex) { - throw new RuntimeException(debugInfo, ex); + throw new RuntimeException(MessageFormat.format("doLoadAfter comp=[{0}],command=[{1}]", comp, command), ex); } finally { doPostPhase(Phase.LOAD_AFTER, ctx); } @@ -2326,13 +2315,13 @@ public void removeBindings(Component comp) { TrackerImpl tracker = (TrackerImpl) getTracker(); tracker.removeTrackings(comp); } - + private void removeBindings(Collection removed, Component comp) { _formBindingHandler.removeBindings(removed); _propertyBindingHandler.removeBindings(removed); _childrenBindingHandler.removeBindings(removed); } - + /** * Remove all bindings that associated with the specified component and key (_fieldExpr|evtnm|formid). * @param comp the component @@ -2341,10 +2330,10 @@ private void removeBindings(Collection removed, Component comp) { public void removeBindings(Component comp, String key) { checkInit(); removeEventCommandListenerIfExists(comp, key); //_listenerMap; //comp+evtnm -> eventlistener - + final BindingKey bkey = getBindingKey(comp, key); final Set removed = new HashSet(); - + _formBindingHandler.removeBindings(bkey, removed); _propertyBindingHandler.removeBindings(bkey, removed); _childrenBindingHandler.removeBindings(bkey, removed); @@ -2352,13 +2341,13 @@ public void removeBindings(Component comp, String key) { _validationMessages.clearMessages(comp, key); } _hasValidators.remove(bkey); - + removeTemplateResolver(comp, key); - + if (_refBindingHandler != null) { _refBindingHandler.removeReferenceBinding(comp, key); } - + //F80 - store subtree's binder annotation count removeBindings(removed, comp); } @@ -2547,9 +2536,9 @@ private void addPropertyLoadBindings4Command(Component comp, String loadExpr, St null, null, null, null); addBinding(comp, attr, binding); - //if no command , always add to prompt binding, a prompt binding will be load when , + //if no command , always add to prompt binding, a prompt binding will be load when , //1.load a component property binding - //2.property change (TODO, DENNIS, ISSUE, I think loading of property change is triggered by tracker in doPropertyChange, not by prompt-binding + //2.property change (TODO, DENNIS, ISSUE, I think loading of property change is triggered by tracker in doPropertyChange, not by prompt-binding final BindingKey bkey = getBindingKey(comp, attr); _propertyBindingHandler.addLoadPromptBinding(comp, bkey, binding); @@ -2618,9 +2607,8 @@ public void notifyChange(Object base, String attr) { private void postGlobalCommand(Component comp, CommandBinding commandBinding, String command, Event evt, Map args) { - String debugInfo = MessageFormat.format("postGlobalCommand command=[{0}],args=[{1}]", command, args); if (_log.isDebugEnabled()) { - _log.debug(debugInfo); + _log.debug("postGlobalCommand command=[{}],args=[{}]", command, args); } final BindingExecutionInfoCollector collector = getBindingExecutionInfoCollector(); @@ -2634,7 +2622,7 @@ private void postGlobalCommand(Component comp, CommandBinding commandBinding, St getEventQueue().publish(new GlobalCommandEvent(_rootComp, command, args, evt)); } catch (Exception ex) { - throw new RuntimeException(debugInfo, ex); + throw new RuntimeException(MessageFormat.format("postGlobalCommand command=[{0}],args=[{1}]", command, args), ex); } finally { if (collector != null) { collector.popStack(); @@ -2814,7 +2802,9 @@ public void setValidationMessages(ValidationMessages messages) { private void didActivate() { _activating = true; try { - _log.debug("didActivate : [{}]", BinderImpl.this); + if (_log.isDebugEnabled()) { + _log.debug("didActivate : [{}]", BinderImpl.this); + } //re-tie value to tracker. loadComponent(_rootComp, false); } finally { diff --git a/zkbind/src/main/java/org/zkoss/bind/impl/ChildrenBindingHandler.java b/zkbind/src/main/java/org/zkoss/bind/impl/ChildrenBindingHandler.java index 19de4dfc6ba..fbf053628c2 100644 --- a/zkbind/src/main/java/org/zkoss/bind/impl/ChildrenBindingHandler.java +++ b/zkbind/src/main/java/org/zkoss/bind/impl/ChildrenBindingHandler.java @@ -1,9 +1,9 @@ /* ChildrenBindingHandler.java Purpose: - + Description: - + History: 2012/1/2 Created by Dennis Chen @@ -28,7 +28,7 @@ import org.zkoss.zk.ui.Component; /** - * to help children-binding implementation of BinderImpl + * to help children-binding implementation of BinderImpl * @author dennis * @since 6.0.0 */ @@ -52,7 +52,7 @@ } // void addLoadEventBinding(Component comp, BindingKey bkey, LoadChildrenBinding binding) { - // List bindings = _loadEventBindings.get(bkey); + // List bindings = _loadEventBindings.get(bkey); // if (bindings == null) { // bindings = new ArrayList(); // _loadEventBindings.put(bkey, bindings); @@ -88,15 +88,14 @@ private void doLoadBinding(Component comp, LoadChildrenBinding binding, String c if (binding instanceof InitChildrenBindingImpl) { ctx.setAttribute(BinderImpl.IGNORE_TRACKER, Boolean.TRUE); //ignore tracker when doing el , we don't need to track the init } - String debugInfo = getLoadBindingDebugInfo("doLoadChildrenBinding", comp, binding, ctx, command); try { if (_log.isDebugEnabled()) { - _log.debug(debugInfo); + _log.debug(getLoadBindingDebugInfo("doLoadChildrenBinding", comp, binding, ctx, command)); } doPrePhase(Phase.LOAD_BINDING, ctx); binding.load(ctx); } catch (Exception ex) { - throw new RuntimeException(debugInfo, ex); + throw new RuntimeException(getLoadBindingDebugInfo("doLoadChildrenBinding", comp, binding, ctx, command), ex); } finally { doPostPhase(Phase.LOAD_BINDING, ctx); } diff --git a/zkbind/src/main/java/org/zkoss/bind/impl/FormBindingHandler.java b/zkbind/src/main/java/org/zkoss/bind/impl/FormBindingHandler.java index 7f17f7492f7..20116b13f75 100644 --- a/zkbind/src/main/java/org/zkoss/bind/impl/FormBindingHandler.java +++ b/zkbind/src/main/java/org/zkoss/bind/impl/FormBindingHandler.java @@ -1,9 +1,9 @@ /* FormBindingHelper.java Purpose: - + Description: - + History: 2011/11/14 Created by Dennis Chen @@ -31,7 +31,7 @@ import org.zkoss.zk.ui.event.Event; /** - * to help form-binding implementation of BinderImpl + * to help form-binding implementation of BinderImpl * @author dennis * @since 6.0.0 */ @@ -105,15 +105,14 @@ private void doSaveBinding(Component comp, SaveFormBinding binding, String comma evt); BindContextUtil.setValidatorArgs(_binder, binding.getComponent(), ctx, binding); //TODO converter args when we support converter in form - String debugInfo = getSaveBindingDebugInfo("doSaveFormBinding", comp, binding, command, evt, notifys); try { if (_log.isDebugEnabled()) { - _log.debug(debugInfo); + _log.debug(getSaveBindingDebugInfo("doSaveFormBinding", comp, binding, command, evt, notifys)); } doPrePhase(Phase.SAVE_BINDING, ctx); binding.save(ctx); } catch (Exception ex) { - throw new RuntimeException(debugInfo, ex); + throw new RuntimeException(getSaveBindingDebugInfo("doSaveFormBinding", comp, binding, command, evt, notifys), ex); } finally { doPostPhase(Phase.SAVE_BINDING, ctx); } @@ -132,20 +131,19 @@ private void doLoadBinding(Component comp, LoadFormBinding binding, String comma ctx.setAttribute(BinderImpl.IGNORE_TRACKER, Boolean.TRUE); //ignore tracker when doing el , we don't need to track the init } //TODO converter args when we support converter in form - String debugInfo = getLoadBindingDebugInfo("doLoadFormBinding", comp, binding, ctx, command); try { if (_log.isDebugEnabled()) { - _log.debug(debugInfo); + _log.debug(getLoadBindingDebugInfo("doLoadFormBinding", comp, binding, ctx, command)); } doPrePhase(Phase.LOAD_BINDING, ctx); binding.load(ctx); - //if there is a valodator, clear the validation message after load + //if there is a validator, clear the validation message after load if (((BinderImpl) binding.getBinder()).hasValidator(binding.getComponent(), binding.getFormId())) { clearValidationMessages(binding.getBinder(), binding.getComponent(), binding.getFormId()); } } catch (Exception ex) { - throw new RuntimeException(debugInfo, ex); + throw new RuntimeException(getLoadBindingDebugInfo("doLoadFormBinding", comp, binding, ctx, command), ex); } finally { doPostPhase(Phase.LOAD_BINDING, ctx); } diff --git a/zkbind/src/main/java/org/zkoss/bind/impl/ParamCall.java b/zkbind/src/main/java/org/zkoss/bind/impl/ParamCall.java index 43cf81ac213..1bda34846e2 100644 --- a/zkbind/src/main/java/org/zkoss/bind/impl/ParamCall.java +++ b/zkbind/src/main/java/org/zkoss/bind/impl/ParamCall.java @@ -179,7 +179,9 @@ public void call(Object base, Method method) { if (c == null) c = invokEx; if (c instanceof OperationException) { //ZK-4255: Expectable exceptions - _log.debug("", c); + if (_log.isDebugEnabled()) { + _log.debug("", c); + } } else { _log.error("", c); } @@ -353,7 +355,7 @@ public Object resolveParameter(Annotation anno, Class returnType, Supplier xnotifys = getNotifys(ctx); if (xnotifys != null) { @@ -221,7 +217,8 @@ private boolean doValidateSaveEvent(Component comp, SavePropertyBinding binding, return valid; } catch (Exception e) { - _log.error(debugInfo); + _log.error(MessageFormat.format("doValidateSaveEvent " + + "comp=[{0}],binding=[{1}],evt=[{2}],validate=[{3}],result=[{4}]", comp, binding, evt, p, valid)); throw UiException.Aide.wrap(e); } finally { doPostPhase(Phase.VALIDATE, ctx); @@ -284,7 +281,7 @@ void doSaveBefore(Component comp, String command, Event evt, Set notif } void doSaveAfter(Component comp, String command, Event evt, Set notifys) { - // final BindEvaluatorX eval = getEvaluatorX(); + // final BindEvaluatorX eval = getEvaluatorX(); final List bindings = _saveAfterBindings.get(command); if (bindings != null) { for (SavePropertyBinding binding : bindings) { diff --git a/zkbind/src/main/java/org/zkoss/bind/impl/SaveFormBindingImpl.java b/zkbind/src/main/java/org/zkoss/bind/impl/SaveFormBindingImpl.java index b29faf5827a..b480a3768eb 100644 --- a/zkbind/src/main/java/org/zkoss/bind/impl/SaveFormBindingImpl.java +++ b/zkbind/src/main/java/org/zkoss/bind/impl/SaveFormBindingImpl.java @@ -1,9 +1,9 @@ /* SaveFormBindingImpl.java Purpose: - + Description: - + History: Aug 9, 2011 6:30:34 PM, Created by henrichen @@ -98,7 +98,7 @@ public Validator getValidator() { return null; // final BindContext ctx = BindContextUtil.newBindContext(getBinder(), this, false, null, getComponent(), null); - // ctx.setAttribute(BinderImpl.IGNORE_TRACKER, Boolean.TRUE);//ignore tracker when doing el, we don't need to trace validator + // ctx.setAttribute(BinderImpl.IGNORE_TRACKER, Boolean.TRUE);//ignore tracker when doing el, we don't need to trace validator final BindEvaluatorX eval = getBinder().getEvaluatorX(); Object obj = eval.getValue(/*ctx*/null, getComponent(), _validator); @@ -132,7 +132,7 @@ public void save(BindContext ctx) { final Form form = getFormBean(ctx); BindingExecutionInfoCollector collector = ((BinderCtrl) getBinder()).getBindingExecutionInfoCollector(); - + //update form field into backing bean if (form instanceof FormLegacy) { if (form instanceof FormLegacyExt) { @@ -197,7 +197,7 @@ public void save(BindContext ctx) { } } } - + binder.notifyChange(formStatus, "."); //notify change of fxStatus and fxStatus.* } if (collector != null) { @@ -220,8 +220,8 @@ private String getConditionString(BindContext ctx) { //--SaveBinding--// public Property getValidate(BindContext ctx) { - //we should not check this binding need to validate or not here, - //since other validator may want to know the value of porperty of this binding, so just provide it + //we should not check this binding need to validate or not here, + //since other validator may want to know the value of porperty of this binding, so just provide it final Binder binder = getBinder(); final BindEvaluatorX eval = binder.getEvaluatorX(); final Component comp = getComponent(); //ctx.getComponent(); @@ -238,8 +238,8 @@ public Property getValidate(BindContext ctx) { //--SaveFormBinding--// public Set getValidates(BindContext ctx) { final Set properties = new HashSet(2); - //we should not check this binding need to validate or not here, - //since other validator may want to know the value of porperty of this binding, so just provide it + //we should not check this binding need to validate or not here, + //since other validator may want to know the value of porperty of this binding, so just provide it final Binder binder = getBinder(); final BindEvaluatorX eval = binder.getEvaluatorX(); final Component comp = getComponent(); //ctx.getComponent(); @@ -261,11 +261,16 @@ public Set getValidates(BindContext ctx) { } catch (PropertyNotFoundException e) { //ignore PropertyNotFoundException, might be new added expression } - if (valref == null) - log.debug("value reference not found by expression [" + expr.getExpressionString() - + "], check if you are trying to save to a variable only expression"); - else - properties.add(new PropertyImpl(valref.getBase(), (String) valref.getProperty(), value)); + if (valref == null) { + if (log.isDebugEnabled()) { + log.debug( + "value reference not found by expression [{}], check if you are trying to save to a variable only expression", + expr.getExpressionString()); + } + } else { + properties.add(new PropertyImpl(valref.getBase(), + (String) valref.getProperty(), value)); + } } } } @@ -309,7 +314,7 @@ public void validate(ValidationContext vctx) { // if (expr != null) { // final Object base = eval.getValue(vctx.getBindContext(), getComponent(), expr); // BindELContext.addNotifys(getValidatorMethod(validator.getClass()), base, null, null, vctx.getBindContext()); - // } + // } // } // } diff --git a/zkbind/src/main/java/org/zkoss/bind/xel/zel/BindExpressionBuilder.java b/zkbind/src/main/java/org/zkoss/bind/xel/zel/BindExpressionBuilder.java index 73b4d56e729..241af6e16f9 100644 --- a/zkbind/src/main/java/org/zkoss/bind/xel/zel/BindExpressionBuilder.java +++ b/zkbind/src/main/java/org/zkoss/bind/xel/zel/BindExpressionBuilder.java @@ -1,9 +1,9 @@ /* BindExpressionBuilder.java Purpose: - + Description: - + History: Aug 15, 2011 11:04:37 AM, Created by henrichen @@ -82,7 +82,7 @@ protected void addTracking(List series) { if (binding != null && series != null && !series.isEmpty()) { //to prevent unnecessary from-save in nested expression in from binding and cause save error - //e.g @bind(fx.hash[fx.key]) or @bind(vm.hash[fx.key]) + //e.g @bind(fx.hash[fx.key]) or @bind(vm.hash[fx.key]) final Boolean isVisted = (Boolean) _ctx.getAttribute(_isVisitedKey); if (!Boolean.TRUE.equals(isVisted)) { @@ -102,14 +102,14 @@ protected void addTracking(List series) { final Component comp = bctx != null ? bctx.getComponent() : binding.getComponent(); final Object base = comp.getAttribute(prop, true); final String fieldName = fieldName(it); - + if (fieldName != null) { if (base instanceof FormLegacy) { // ZK-4501: add SimpleForm back for compatibility final FormLegacy formLegacyBean = (FormLegacy) base; - + if (binding instanceof SavePropertyBinding && !Boolean.TRUE.equals(isVisted)) { if (_log.isDebugEnabled()) { - _log.debug("add save-field '%s' to form '%s'", fieldName, formLegacyBean); + _log.debug("add save-field '{}' to form '{}'", fieldName, formLegacyBean); } if (formLegacyBean instanceof FormLegacyExt) { ((FormLegacyExt) formLegacyBean).addSaveFieldName(fieldName); @@ -118,7 +118,7 @@ protected void addTracking(List series) { } else if (binding instanceof LoadPropertyBinding || binding instanceof LoadChildrenBinding || binding instanceof ReferenceBinding) { if (_log.isDebugEnabled()) { - _log.debug("add load-field '%s' to form '%s'", fieldName, formLegacyBean); + _log.debug("add load-field '{}' to form '{}'", fieldName, formLegacyBean); } if (formLegacyBean instanceof FormLegacyExt) { ((FormLegacyExt) formLegacyBean).addLoadFieldName(fieldName); @@ -126,7 +126,7 @@ protected void addTracking(List series) { } } else if (base instanceof Form) { final Form formBean = (Form) base; - + if (binding instanceof SavePropertyBinding && !Boolean.TRUE.equals(isVisted)) { if (_log.isDebugEnabled()) { _log.debug("add save-field '{}' to form '{}'", fieldName, formBean); diff --git a/zkdoc/release-note b/zkdoc/release-note index 3998a4b6964..eb6d3b07b26 100644 --- a/zkdoc/release-note +++ b/zkdoc/release-note @@ -12,6 +12,7 @@ ZK 10.1.0 ZK-5659: Tree only renders 50 nodes in client mvvm ZK-5677: Executions.schedule cause infinite loop if async event causes exception ZK-5696: Nested Shadow element fails in ZK 10 + ZK-5703: Debug messages shouldn't be created if debug is disabled, may cause side effects * Upgrade Notes + Remove Htmls.encodeJavaScript(), Strings.encodeJavaScript(), Strings.escape() with Strings.ESCAPE_JAVASCRIPT, and replace them with OWASP Java Encoder APIs instead. diff --git a/zkplus/src/main/java/org/zkoss/zkplus/jpa/OpenEntityManagerInViewListener.java b/zkplus/src/main/java/org/zkoss/zkplus/jpa/OpenEntityManagerInViewListener.java index d6f07d294b4..02e81824220 100644 --- a/zkplus/src/main/java/org/zkoss/zkplus/jpa/OpenEntityManagerInViewListener.java +++ b/zkplus/src/main/java/org/zkoss/zkplus/jpa/OpenEntityManagerInViewListener.java @@ -2,9 +2,9 @@ {{IS_NOTE Purpose: - + Description: - + History: Mon Dec 17 2007, Created by jeffliu }}IS_NOTE @@ -28,7 +28,7 @@ /** * Listener to init and cleanup the JPA entityManager automatically - * + * *

In WEB-INF/zk.xml, add following lines: *


  * 	<listener>
@@ -49,8 +49,11 @@ public void cleanup(Execution exec, Execution parent, List errs) throws Exceptio
 		if (parent == null) {
 			try {
 				if (errs == null || errs.isEmpty()) {
-					log.debug("JPA: Committing the database transaction: " + exec + " for entityManager:"
-							+ JpaUtil.getEntityManager());
+					if (log.isDebugEnabled()) {
+						log.debug(
+								"JPA: Committing the database transaction: {} for entityManager:{}",
+								exec, JpaUtil.getEntityManager());
+					}
 					JpaUtil.getEntityManager().getTransaction().commit();
 				} else {
 					final Throwable ex = (Throwable) errs.get(0);
@@ -58,12 +61,17 @@ public void cleanup(Execution exec, Execution parent, List errs) throws Exceptio
 				}
 			} finally {
 				if (JpaUtil.getEntityManager().isOpen()) {
-					log.debug("JPA: close a database transaction: " + exec + " for entityManager:"
-							+ JpaUtil.getEntityManager());
+					if (log.isDebugEnabled()) {
+						log.debug(
+								"JPA: close a database transaction: {} for entityManager:{}",
+								exec, JpaUtil.getEntityManager());
+					}
 					JpaUtil.getEntityManager().close();
-				} else
-					log.debug("JPA: the database transaction is not open: " + exec + " for entityManager:"
-							+ JpaUtil.getEntityManager());
+				} else if (log.isDebugEnabled()) {
+					log.debug(
+							"JPA: the database transaction is not open: {} for entityManager:{}",
+							exec, JpaUtil.getEntityManager());
+				}
 			}
 		}
 	}
@@ -72,21 +80,24 @@ public void cleanup(Execution exec, Execution parent, List errs) throws Exceptio
 	public void init(Execution exec, Execution parent) throws Exception {
 
 		if (parent == null) {
-			log.debug("JPA: Starting a database transaction: " + exec + " for entityManager:"
-					+ JpaUtil.getEntityManager());
+			if (log.isDebugEnabled()) {
+				log.debug(
+						"JPA: Starting a database transaction: {} for entityManager:{}",
+						exec, JpaUtil.getEntityManager());
+			}
 			JpaUtil.getEntityManager().getTransaction().begin();
 		}
 	}
 
 	/**
-	 * 

Default exception handler. + *

Default exception handler. * This implementation simply rollback the transaction.

- * - *

Application developer might want to extends this class and override - * this method to do other things like compensate for any permanent changes - * during the conversation, and finally restart business conversation... + * + *

Application developer might want to extends this class and override + * this method to do other things like compensate for any permanent changes + * during the conversation, and finally restart business conversation... * what can be done here depends on the applications design.

- * + * * @param exec the execution to clean up. * @param ex the Throwable which is not handled during the execution */ @@ -105,11 +116,17 @@ protected void handleException(Execution exec, Throwable ex) { private void rollback(Execution exec, Throwable ex) { try { if (JpaUtil.getEntityManager().getTransaction().isActive()) { - log.debug("Trying to rollback database transaction after exception:" + ex); + if (log.isDebugEnabled()) { + log.debug( + "Trying to rollback database transaction after exception:{}", + String.valueOf(ex)); + } JpaUtil.getEntityManager().getTransaction().rollback(); } } catch (Throwable rbEx) { - log.error("Could not rollback transaction after exception! Original Exception:\n" + ex, rbEx); + log.error( + "Could not rollback transaction after exception! Original Exception:\n{}", + ex, rbEx); } } diff --git a/zweb-dsp/src/main/java/org/zkoss/web/servlet/dsp/InterpreterServlet.java b/zweb-dsp/src/main/java/org/zkoss/web/servlet/dsp/InterpreterServlet.java index f9e86c087dc..08b4b95958e 100644 --- a/zweb-dsp/src/main/java/org/zkoss/web/servlet/dsp/InterpreterServlet.java +++ b/zweb-dsp/src/main/java/org/zkoss/web/servlet/dsp/InterpreterServlet.java @@ -117,7 +117,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) final String path = Https.getThisServletPath(request); if (log.isDebugEnabled()) - log.debug("Get " + path); + log.debug("Get {}", path); final Object old = Charsets.setup(request, response, _charset); final ServletContext ctx = getServletContext(); @@ -125,7 +125,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) final Interpretation cnt = (Interpretation) ResourceCaches.get(getCache(), ctx, path, null); if (cnt == null) { if (Https.isIncluded(request)) - log.error("Not found: " + path); + log.error("Not found: {}", path); //It might be eaten, so log the error response.sendError(HttpServletResponse.SC_NOT_FOUND, Encode.forJavaScript(Encode.forHtml(path))); diff --git a/zweb/src/main/java/org/zkoss/web/servlet/http/Encodes.java b/zweb/src/main/java/org/zkoss/web/servlet/http/Encodes.java index 17ed7261d3d..5e11887a691 100644 --- a/zweb/src/main/java/org/zkoss/web/servlet/http/Encodes.java +++ b/zweb/src/main/java/org/zkoss/web/servlet/http/Encodes.java @@ -1,9 +1,9 @@ /* Encodes.java Purpose: - + Description: - + History: Fri Jun 21 14:13:50 2002, Created by tomyeh @@ -210,7 +210,7 @@ private static final int next(StringBuffer sb, char cc, int j) { * If the name already exists in the query string, it will be removed first. * If your name has appeared in the string, it will replace * your new value to the query string. - * Otherwise, it will append the name/value to the new string. + * Otherwise, it will append the name/value to the new string. * *

The query string might contain servlet path and other parts. * This method starts the searching from the first '?'. @@ -219,7 +219,7 @@ private static final int next(StringBuffer sb, char cc, int j) { * * @param str The query string like xxx?xxx=xxx&xxx=xxx or null. * @param name The get parameter name. - * @param value The value associated with the get parameter name. + * @param value The value associated with the get parameter name. * @return The new or result query string with your name/value. * @see #addToQueryString */ @@ -357,7 +357,7 @@ public static final StringBuffer removeFromQueryString(StringBuffer sb, String n * It resolves "*" contained in URI, if any, to the proper Locale, * and the browser code. * Refer to {@link Servlets#locate(ServletContext, ServletRequest, String, Locator)} - * for details. + * for details. * *

In additions, if uri starts with "/", the context path, e.g., * /zkdemo, is prefixed. @@ -384,7 +384,7 @@ public static final StringBuffer removeFromQueryString(StringBuffer sb, String n * To do that, you can implement {@link URLEncoder}, and then * specify the class with the library property called * org.zkoss.web.servlet.http.URLEncoder. - * When {@link #encodeURL} encodes an URL, it will invoke + * When {@link #encodeURL} encodes an URL, it will invoke * {@link URLEncoder#encodeURL} such you can do customized encoding, * such as insert a special prefix. * @@ -464,7 +464,7 @@ private static final String encodeURL0(ServletContext ctx, ServletRequest reques if (newctx != null) { ctx = newctx; } else if (log.isDebugEnabled()) { - log.debug("Context not found: " + ctxroot); + log.debug("Context not found: {}", ctxroot); } ctxpathSpecified = true; } else if (Https.isIncluded(request) || Https.isForwarded(request)) { @@ -476,7 +476,8 @@ private static final String encodeURL0(ServletContext ctx, ServletRequest reques if (j >= 0) { uri = pgpath.substring(0, j + 1) + uri; } else { - log.warn("The current page doesn't contain '/':" + pgpath); + log.warn("The current page doesn't contain '/':{}", + pgpath); } } } @@ -525,7 +526,7 @@ private static final String encodeURL0(ServletContext ctx, ServletRequest reques * To do that, you can implement {@link URLEncoder}, and then * specify the class with the library property called * org.zkoss.web.servlet.http.URLEncoder. - * When {@link #encodeURL} encodes an URL, it will invoke + * When {@link #encodeURL} encodes an URL, it will invoke * {@link URLEncoder#encodeURL} such you can do customized encoding, * such as insert a special prefix. * diff --git a/zweb/src/main/java/org/zkoss/web/servlet/http/Https.java b/zweb/src/main/java/org/zkoss/web/servlet/http/Https.java index 4868dfce674..c382c6e384c 100644 --- a/zweb/src/main/java/org/zkoss/web/servlet/http/Https.java +++ b/zweb/src/main/java/org/zkoss/web/servlet/http/Https.java @@ -752,7 +752,7 @@ private static int[] parseRange(String range) { } catch (Throwable ex) { //ignore } if (log.isDebugEnabled()) - log.debug("Failed to parse Range: " + range); + log.debug("Failed to parse Range: {}", range); return null; } } diff --git a/zweb/src/main/java/org/zkoss/web/util/resource/ExtendletLoader.java b/zweb/src/main/java/org/zkoss/web/util/resource/ExtendletLoader.java index ab166359e48..4aebe6f94b2 100644 --- a/zweb/src/main/java/org/zkoss/web/util/resource/ExtendletLoader.java +++ b/zweb/src/main/java/org/zkoss/web/util/resource/ExtendletLoader.java @@ -1,9 +1,9 @@ /* ExtendletLoader.java Purpose: - + Description: - + History: Wed May 28 17:01:32 2008, Created by tomyeh @@ -103,7 +103,7 @@ public long getLastModified(String src) { public V load(String src) throws Exception { if (log.isDebugEnabled()) - log.debug("Parse " + src); + log.debug("Parse {}", src); final String path = getRealPath(src); InputStream is = null; if (getCheckPeriod() >= 0) { @@ -116,7 +116,7 @@ public V load(String src) throws Exception { is = real.openStream(); } } catch (Throwable ex) { - log.warn("Unable to read from URL: " + path, ex); + log.warn("Unable to read from URL: {}", path, ex); } } diff --git a/zweb/src/main/java/org/zkoss/web/util/resource/ResourceLoader.java b/zweb/src/main/java/org/zkoss/web/util/resource/ResourceLoader.java index 63f483550a9..2ca97870412 100644 --- a/zweb/src/main/java/org/zkoss/web/util/resource/ResourceLoader.java +++ b/zweb/src/main/java/org/zkoss/web/util/resource/ResourceLoader.java @@ -1,9 +1,9 @@ /* ResourceLoader.java Purpose: - + Description: - + History: Tue Aug 30 18:31:26 2005, Created by tomyeh @@ -99,12 +99,12 @@ public V load(ResourceInfo src) throws Exception { if (!src.file.exists() && src.extra != null && ((ServletContextLocator) src.extra).getResourceAsStream(src.path) == null) { if (log.isDebugEnabled()) - log.debug("Not found: " + src.file); + log.debug("Not found: {}", src.file); return null; //File not found } if (log.isDebugEnabled()) - log.debug("Loading " + src.file); + log.debug("Loading {}", src.file); try { return parse(src.path, src.file, src.extra); } catch (FileNotFoundException ex) {