Author: arunpatidar
Date: Tue Jun 28 14:06:41 2016 New Revision: 1750515 URL: http://svn.apache.org/viewvc?rev=1750515&view=rev Log: Applied patch from jira issue - OFBIZ-7422 - Enforce noninstantiability to WidgetDataResourceWorker Class. Thanks Rishi Solanki and Rohit Koushal for your contribution. Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/content/WidgetDataResourceWorker.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/html/HtmlScreenRenderer.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/macro/MacroScreenRenderer.java Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/content/WidgetDataResourceWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/content/WidgetDataResourceWorker.java?rev=1750515&r1=1750514&r2=1750515&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/content/WidgetDataResourceWorker.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/content/WidgetDataResourceWorker.java Tue Jun 28 14:06:41 2016 @@ -23,9 +23,10 @@ import org.ofbiz.base.util.Debug; /** * WidgetContentWorker Class */ -public class WidgetDataResourceWorker { +public final class WidgetDataResourceWorker { public static final String module = WidgetDataResourceWorker.class.getName(); - public static DataResourceWorkerInterface dataresourceWorker = null; + private WidgetDataResourceWorker() {} + private static DataResourceWorkerInterface dataresourceWorker = null; static { try { ClassLoader loader = Thread.currentThread().getContextClassLoader(); @@ -39,4 +40,7 @@ public class WidgetDataResourceWorker { Debug.logError(e, "Could not pre-initialize dynamically loaded class: ", module); } } + public static DataResourceWorkerInterface getDataresourceWorker() { + return dataresourceWorker; + } } Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/html/HtmlScreenRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/html/HtmlScreenRenderer.java?rev=1750515&r1=1750514&r2=1750515&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/html/HtmlScreenRenderer.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/html/HtmlScreenRenderer.java Tue Jun 28 14:06:41 2016 @@ -709,8 +709,8 @@ public class HtmlScreenRenderer extends try { if (UtilValidate.isNotEmpty(dataResourceId)) { - if (WidgetDataResourceWorker.dataresourceWorker != null) { - renderedContent = WidgetDataResourceWorker.dataresourceWorker.renderDataResourceAsTextExt(delegator, dataResourceId, contentContext, locale, mimeTypeId, false); + if (WidgetDataResourceWorker.getDataresourceWorker() != null) { + renderedContent = WidgetDataResourceWorker.getDataresourceWorker().renderDataResourceAsTextExt(delegator, dataResourceId, contentContext, locale, mimeTypeId, false); } else { Debug.logError("Not rendering content, WidgetDataResourceWorker.dataresourceWorker not found.", module); } @@ -721,8 +721,8 @@ public class HtmlScreenRenderer extends Debug.logError("Not rendering content, WidgetContentWorker.contentWorker not found.", module); } } else if (UtilValidate.isNotEmpty(expandedDataResourceId)) { - if (WidgetDataResourceWorker.dataresourceWorker != null) { - renderedContent = WidgetDataResourceWorker.dataresourceWorker.renderDataResourceAsTextExt(delegator, expandedDataResourceId, contentContext, locale, mimeTypeId, false); + if (WidgetDataResourceWorker.getDataresourceWorker() != null) { + renderedContent = WidgetDataResourceWorker.getDataresourceWorker().renderDataResourceAsTextExt(delegator, expandedDataResourceId, contentContext, locale, mimeTypeId, false); } else { Debug.logError("Not rendering content, WidgetDataResourceWorker.dataresourceWorker not found.", module); } Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/macro/MacroScreenRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/macro/MacroScreenRenderer.java?rev=1750515&r1=1750514&r2=1750515&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/macro/MacroScreenRenderer.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/macro/MacroScreenRenderer.java Tue Jun 28 14:06:41 2016 @@ -387,8 +387,8 @@ public class MacroScreenRenderer impleme try { if (UtilValidate.isNotEmpty(dataResourceId)) { - if (WidgetDataResourceWorker.dataresourceWorker != null) { - renderedContent = WidgetDataResourceWorker.dataresourceWorker.renderDataResourceAsTextExt(delegator, dataResourceId, contentContext, locale, mimeTypeId, false); + if (WidgetDataResourceWorker.getDataresourceWorker() != null) { + renderedContent = WidgetDataResourceWorker.getDataresourceWorker().renderDataResourceAsTextExt(delegator, dataResourceId, contentContext, locale, mimeTypeId, false); } else { Debug.logError("Not rendering content, WidgetDataResourceWorker.dataresourceWorker not found.", module); } @@ -399,8 +399,8 @@ public class MacroScreenRenderer impleme Debug.logError("Not rendering content, WidgetContentWorker.contentWorker not found.", module); } } else if (UtilValidate.isNotEmpty(expandedDataResourceId)) { - if (WidgetDataResourceWorker.dataresourceWorker != null) { - renderedContent = WidgetDataResourceWorker.dataresourceWorker.renderDataResourceAsTextExt(delegator, expandedDataResourceId, contentContext, locale, mimeTypeId, false); + if (WidgetDataResourceWorker.getDataresourceWorker() != null) { + renderedContent = WidgetDataResourceWorker.getDataresourceWorker().renderDataResourceAsTextExt(delegator, expandedDataResourceId, contentContext, locale, mimeTypeId, false); } else { Debug.logError("Not rendering content, WidgetDataResourceWorker.dataresourceWorker not found.", module); } |
Free forum by Nabble | Edit this page |