Author: adrianc
Date: Sat Nov 1 10:49:29 2014
New Revision: 1635917
URL: http://svn.apache.org/r1635917
Log:
Begin working on making widget models thread safe.
Modified:
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidget.java
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenu.java
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreen.java
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTree.java
Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidget.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidget.java?rev=1635917&r1=1635916&r2=1635917&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidget.java
(original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidget.java Sat Nov
1 10:49:29 2014
@@ -30,25 +30,23 @@ import org.w3c.dom.Element;
* extended by other widget model classes.
*/
@SuppressWarnings("serial")
-public class ModelWidget implements Serializable {
+public abstract class ModelWidget implements Serializable {
/**
* The parameter name used to control widget boundary comments. Currently
* set to "widgetVerbose".
*/
public static final String enableBoundaryCommentsParam = "widgetVerbose";
- protected String name;
- private String systemId;
- private int startColumn;
- private int startLine;
-
- protected ModelWidget() {}
+ private final String name;
+ private final String systemId;
+ private final int startColumn;
+ private final int startLine;
/**
* Derived classes must call this constructor.
* @param widgetElement The XML Element for the widget
*/
- public ModelWidget(Element widgetElement) {
+ protected ModelWidget(Element widgetElement) {
this.name = widgetElement.getAttribute("name");
this.systemId = (String) widgetElement.getUserData("systemId");
this.startColumn = ((Integer)
widgetElement.getUserData("startColumn")).intValue();
Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java?rev=1635917&r1=1635916&r2=1635917&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java
(original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java Sat
Nov 1 10:49:29 2014
@@ -203,8 +203,6 @@ public class ModelForm extends ModelWidg
protected List<UpdateArea> onSortColumnUpdateAreas;
// ===== CONSTRUCTORS =====
- /** Default Constructor */
- public ModelForm() {}
/** XML Constructor */
public ModelForm(Element formElement, ModelReader entityModelReader,
DispatchContext dispatchContext) {
@@ -2060,11 +2058,6 @@ public class ModelForm extends ModelWidg
return lstNm;
}
- @Override
- public String getName() {
- return this.name;
- }
-
public String getCurrentFormName(Map<String, Object> context) {
Integer itemIndex = (Integer) context.get("itemIndex");
String formName = (String) context.get("formName");
@@ -2102,7 +2095,7 @@ public class ModelForm extends ModelWidg
condTrue = boolVal.booleanValue();
} else {
throw new IllegalArgumentException(
- "Return value from target condition eval was not a
Boolean: " + retVal.getClass().getName() + " [" + retVal + "] of form " +
this.name);
+ "Return value from target condition eval was not a
Boolean: " + retVal.getClass().getName() + " [" + retVal + "] of form " +
getName());
}
if (condTrue && !targetType.equals("inter-app")) {
@@ -2110,7 +2103,7 @@ public class ModelForm extends ModelWidg
}
}
} catch (EvalError e) {
- String errmsg = "Error evaluating BeanShell target conditions on
form " + this.name;
+ String errmsg = "Error evaluating BeanShell target conditions on
form " + getName();
Debug.logError(e, errmsg, module);
throw new IllegalArgumentException(errmsg);
}
@@ -2162,7 +2155,7 @@ public class ModelForm extends ModelWidg
@Override
public String getBoundaryCommentName() {
- return formLocation + "#" + name;
+ return formLocation + "#" + getName();
}
public void resetBshInterpreter(Map<String, Object> context) {
@@ -2311,13 +2304,6 @@ public class ModelForm extends ModelWidg
/**
* @param string
*/
- public void setName(String string) {
- this.name = string;
- }
-
- /**
- * @param string
- */
public void setTarget(String string) {
this.target = FlexibleStringExpander.getInstance(string);
}
@@ -2860,11 +2846,11 @@ public class ModelForm extends ModelWidg
}
} else {
throw new IllegalArgumentException(
- "Return value from style condition eval was not a
Boolean: " + retVal.getClass().getName() + " [" + retVal + "] of form " +
this.name);
+ "Return value from style condition eval was not a
Boolean: " + retVal.getClass().getName() + " [" + retVal + "] of form " +
getName());
}
}
} catch (EvalError e) {
- String errmsg = "Error evaluating BeanShell style conditions on
form " + this.name;
+ String errmsg = "Error evaluating BeanShell style conditions on
form " + getName();
Debug.logError(e, errmsg, module);
throw new IllegalArgumentException(errmsg);
}
Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenu.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenu.java?rev=1635917&r1=1635916&r2=1635917&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenu.java
(original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenu.java Sat
Nov 1 10:49:29 2014
@@ -90,8 +90,6 @@ public class ModelMenu extends ModelWidg
// ===== CONSTRUCTORS =====
- /** Default Constructor */
- public ModelMenu() {}
/** XML Constructor */
public ModelMenu(Element menuElement) {
@@ -368,7 +366,7 @@ public class ModelMenu extends ModelWidg
}
public String getCurrentMenuName(Map<String, Object> context) {
- return this.name;
+ return getName();
}
public String getId() {
@@ -389,7 +387,7 @@ public class ModelMenu extends ModelWidg
@Override
public String getBoundaryCommentName() {
- return menuLocation + "#" + name;
+ return menuLocation + "#" + getName();
}
/**
@@ -445,13 +443,6 @@ public class ModelMenu extends ModelWidg
/**
* @param string
*/
- public void setName(String string) {
- this.name = string;
- }
-
- /**
- * @param string
- */
public void setTarget(String string) {
this.target = string;
}
Modified:
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreen.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreen.java?rev=1635917&r1=1635916&r2=1635917&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreen.java
(original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreen.java
Sat Nov 1 10:49:29 2014
@@ -57,8 +57,6 @@ public class ModelScreen extends ModelWi
protected ModelScreenWidget.Section section;
// ===== CONSTRUCTORS =====
- /** Default Constructor */
- protected ModelScreen() {}
/** XML Constructor */
public ModelScreen(Element screenElement, Map<String, ModelScreen>
modelScreenMap, String sourceLocation) {
@@ -72,7 +70,7 @@ public class ModelScreen extends ModelWi
// read in the section, which will read all sub-widgets too
Element sectionElement = UtilXml.firstChildElement(screenElement,
"section");
if (sectionElement == null) {
- throw new IllegalArgumentException("No section found for the
screen definition with name: " + this.name);
+ throw new IllegalArgumentException("No section found for the
screen definition with name: " + getName());
}
this.section = new ModelScreenWidget.Section(this, sectionElement);
this.section.isMainSection = true;
@@ -360,7 +358,7 @@ public class ModelScreen extends ModelWi
try {
transactionTimeout =
Integer.parseInt(transactionTimeoutPar);
} catch (NumberFormatException nfe) {
- String msg = "TRANSACTION_TIMEOUT parameter for screen ["
+ this.sourceLocation + "#" + this.name + "] is invalid and it will be ignored:
" + nfe.toString();
+ String msg = "TRANSACTION_TIMEOUT parameter for screen ["
+ this.sourceLocation + "#" + getName() + "] is invalid and it will be ignored:
" + nfe.toString();
Debug.logWarning(msg, module);
}
}
@@ -396,7 +394,7 @@ public class ModelScreen extends ModelWi
} catch (ScreenRenderException e) {
throw e;
} catch (RuntimeException e) {
- String errMsg = "Error rendering screen [" + this.sourceLocation +
"#" + this.name + "]: " + e.toString();
+ String errMsg = "Error rendering screen [" + this.sourceLocation +
"#" + getName() + "]: " + e.toString();
Debug.logError(errMsg + ". Rolling back transaction.", module);
try {
// only rollback the transaction if we started one...
@@ -407,7 +405,7 @@ public class ModelScreen extends ModelWi
// after rolling back, rethrow the exception
throw new ScreenRenderException(errMsg, e);
} catch (Exception e) {
- String errMsg = "Error rendering screen [" + this.sourceLocation +
"#" + this.name + "]: " + e.toString();
+ String errMsg = "Error rendering screen [" + this.sourceLocation +
"#" + getName() + "]: " + e.toString();
Debug.logError(errMsg + ". Rolling back transaction.", module);
try {
// only rollback the transaction if we started one...
Modified:
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java?rev=1635917&r1=1635916&r2=1635917&view=diff
==============================================================================
---
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java
(original)
+++
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java
Sat Nov 1 10:49:29 2014
@@ -216,13 +216,13 @@ public abstract class ModelScreenWidget
if (isMainSection) {
return modelScreen.getSourceLocation() + "#" +
modelScreen.getName();
} else {
- return name;
+ return getName();
}
}
@Override
public String rawString() {
- return "<section" + (UtilValidate.isNotEmpty(this.name)?" name=\""
+ this.name + "\"":"") + ">";
+ return "<section" + (UtilValidate.isNotEmpty(getName())?" name=\""
+ getName() + "\"":"") + ">";
}
}
@@ -384,7 +384,7 @@ public abstract class ModelScreenWidget
this.saveCollapsed =
!("false".equals(screenletElement.getAttribute("save-collapsed")));
this.padded =
!"false".equals(screenletElement.getAttribute("padded"));
- if (this.collapsible && UtilValidate.isEmpty(this.name) &&
idExdr.isEmpty()) {
+ if (this.collapsible && UtilValidate.isEmpty(getName()) &&
idExdr.isEmpty()) {
throw new IllegalArgumentException("Collapsible screenlets
must have a name or id [" + this.modelScreen.getName() + "]");
}
this.titleExdr =
FlexibleStringExpander.getInstance(screenletElement.getAttribute("title"));
@@ -690,7 +690,7 @@ public abstract class ModelScreenWidget
@Override
public String rawString() {
- return "<decorator-section name=\"" + this.name + "\">";
+ return "<decorator-section name=\"" + getName() + "\">";
}
}
@@ -704,9 +704,9 @@ public abstract class ModelScreenWidget
@Override
public void renderWidgetString(Appendable writer, Map<String, Object>
context, ScreenStringRenderer screenStringRenderer) throws GeneralException,
IOException {
Map<String, ? extends Object> preRenderedContent =
UtilGenerics.checkMap(context.get("preRenderedContent"));
- if (preRenderedContent != null &&
preRenderedContent.containsKey(this.name)) {
+ if (preRenderedContent != null &&
preRenderedContent.containsKey(getName())) {
try {
- writer.append((String) preRenderedContent.get(this.name));
+ writer.append((String) preRenderedContent.get(getName()));
} catch (IOException e) {
String errMsg = "Error rendering pre-rendered content in
screen named [" + this.modelScreen.getName() + "]: " + e.toString();
Debug.logError(e, errMsg, module);
@@ -716,16 +716,16 @@ public abstract class ModelScreenWidget
SectionsRenderer sections = (SectionsRenderer)
context.get("sections");
// for now if sections is null, just log a warning; may be
permissible to make the screen for flexible
if (sections == null) {
- Debug.logWarning("In decorator-section-include could not
find sections object in the context, not rendering section with name [" +
this.name + "]", module);
+ Debug.logWarning("In decorator-section-include could not
find sections object in the context, not rendering section with name [" +
getName() + "]", module);
} else {
- sections.render(this.name);
+ sections.render(getName());
}
}
}
@Override
public String rawString() {
- return "<decorator-section-include name=\"" + this.name + "\">";
+ return "<decorator-section-include name=\"" + getName() + "\">";
}
}
@@ -816,7 +816,7 @@ public abstract class ModelScreenWidget
try {
modelForm.renderFormString(writer, context,
formStringRenderer);
} catch (IOException e) {
- String errMsg = "Error rendering included form named [" + name
+ "] at location [" + this.getLocation(context) + "]: " + e.toString();
+ String errMsg = "Error rendering included form named [" +
getName() + "] at location [" + this.getLocation(context) + "]: " +
e.toString();
Debug.logError(e, errMsg, module);
throw new RuntimeException(errMsg + e);
}
Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTree.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTree.java?rev=1635917&r1=1635916&r2=1635917&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTree.java
(original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTree.java Sat
Nov 1 10:49:29 2014
@@ -85,9 +85,6 @@ public class ModelTree extends ModelWidg
// ===== CONSTRUCTORS =====
/** Default Constructor */
- /** XML Constructor */
- public ModelTree() {}
-
public ModelTree(Element treeElement, Delegator delegator, LocalDispatcher
dispatcher) {
super(treeElement);
this.rootNodeName = treeElement.getAttribute("root-node-name");
@@ -125,7 +122,7 @@ public class ModelTree extends ModelWidg
}
if (nodeList.size() == 0) {
- throw new IllegalArgumentException("No node elements found for the
tree definition with name: " + this.name);
+ throw new IllegalArgumentException("No node elements found for the
tree definition with name: " + getName());
}
}
@@ -204,7 +201,7 @@ public class ModelTree extends ModelWidg
@Override
public String getBoundaryCommentName() {
- return treeLocation + "#" + name;
+ return treeLocation + "#" + getName();
}
public void setTreeLocation(String treeLocation) {
@@ -255,7 +252,7 @@ public class ModelTree extends ModelWidg
node.renderNodeString(writer, context, treeStringRenderer, 0);
buf.append(writer.toString());
} catch (IOException e2) {
- String errMsg = "Error rendering included label with name [" +
name + "] : " + e2.toString();
+ String errMsg = "Error rendering included label with name [" +
getName() + "] : " + e2.toString();
Debug.logError(e2, errMsg, module);
throw new RuntimeException(errMsg);
}