Yes, it was causing problems for one of our clients. OFBIZ-5204 was a
big help because it identified the cause of the problem. I had
previously left FIXME comments in those bits of code - but that was
because I objected to the memory being wasted by caching DOM trees.
-Adrian
On 6/16/2013 9:43 AM, Scott Gray wrote:
Okay thanks but please don't think I don't appreciate the effort put into
solving this issue across the framework, I definitely do. Hard to detect
quirks like this have no doubt caused issues for many users over many years
(often temporarily solved with a restart) and solving them is a big win for
everybody.
Regards
Scott
On 16/06/2013, at 8:13 PM, Adrian Crum wrote:
Okay, I will remove it and keep a local copy.
-Adrian
On 6/16/2013 9:09 AM, Scott Gray wrote:
It seems largely like a one off effort though right? I mean it's pretty rare
that we make anything other than minor modifications to our schemas.
I guess this just all seems like a lot of effort and code for something that
could have been fixed by caching the entity engine mappings in a map instead of
caching the DOM. I encountered the same bug in 10.04 a few months back and
fixed it by doing just that, it took about 20 minutes.
Now instead we have so much code that we needed a generator to make it and
since we tried one and it wasn't suitable we decided to roll our own generator
as well that might be used rarely (maybe never if you disappear and it isn't
documented).
Regards
Scott
On 16/06/2013, at 7:53 PM, Adrian Crum wrote:
An external tool was suggested and tried, but it wasn't capable of generating
thread-safe classes. So, this was the result of a real need - the need to
generate thread-safe models from OFBiz XML schemas.
For background, look here: https://issues.apache.org/jira/browse/OFBIZ-5204
-Adrian
On 6/16/2013 8:47 AM, Scott Gray wrote:
I'm sure this is a useful tool but are we not stretching the scope of the
project a bit too far with support for home grown code generators?
Regards
Scott
On 16/06/2013, at 7:36 PM, [email protected] wrote:
Author: adrianc
Date: Sun Jun 16 07:36:08 2013
New Revision: 1493474
URL: http://svn.apache.org/r1493474
Log:
XsdToJava.ftl improvement - Append "Element" to class names to avoid name clash.
Modified:
ofbiz/trunk/framework/webtools/webapp/webtools/XsdToJava.ftl
Modified: ofbiz/trunk/framework/webtools/webapp/webtools/XsdToJava.ftl
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/webapp/webtools/XsdToJava.ftl?rev=1493474&r1=1493473&r2=1493474&view=diff
==============================================================================
--- ofbiz/trunk/framework/webtools/webapp/webtools/XsdToJava.ftl (original)
+++ ofbiz/trunk/framework/webtools/webapp/webtools/XsdToJava.ftl Sun Jun 16
07:36:08 2013
@@ -129,7 +129,7 @@ under the License.
</#if>
<#if !(xsdElement.getAttribute("abstract") == "true")>
- public ${className}(Element element) throws ${exceptionClassName} {
+ public ${className}Element(Element element) throws ${exceptionClassName} {
<#-- Class field assignments -->
<#if attributeElements?exists>
<#list attributeElements as attributeElement>
@@ -238,10 +238,10 @@ import org.w3c.dom.Element;
* @see <code>${xsdFileName}</code>
*/
<#if abstract>
-public interface ${className} {
+public interface ${className}Element {
<#else>
@ThreadSafe
-public final class ${className}<#if substitutionGroup?has_content> implements
${substitutionGroup}</#if> {
+public final class ${className}Element<#if substitutionGroup?has_content> implements
${substitutionGroup}</#if> {
</#if>
</#macro>
@@ -301,9 +301,9 @@ public final class ${className}<#if subs
<#local isList = true>
</#if>
<#if isList>
- private final List<${className}> ${fieldName}List; // <${elementName}>
+ private final List<${className}Element> ${fieldName}List; //
<${elementName}>
<#else>
- private final ${className} ${fieldName}; // <${elementName}>
+ private final ${className}Element ${fieldName}; // <${elementName}>
</#if>
</#macro>
@@ -335,12 +335,12 @@ public final class ${className}<#if subs
this.${fieldName}List = Collections.emptyList();
</#if>
} else {
- List<${className}> ${fieldName}List = new
ArrayList<${className}>(${fieldName}ElementList.size());
+ List<${className}Element> ${fieldName}List = new
ArrayList<${className}Element>(${fieldName}ElementList.size());
for (Element ${fieldName}Element : ${fieldName}ElementList) {
<#if abstract>
-
${fieldName}List.add(${className}Factory.create(${fieldName}Element));
+
${fieldName}List.add(${className}ElementFactory.create(${fieldName}Element));
<#else>
- ${fieldName}List.add(new ${className}(${fieldName}Element));
+ ${fieldName}List.add(new
${className}Element(${fieldName}Element));
</#if>
}
this.${fieldName}List =
Collections.unmodifiableList(${fieldName}List);
@@ -354,7 +354,7 @@ public final class ${className}<#if subs
this.${fieldName} = null;
</#if>
} else {
- this.${fieldName} = new ${className}(${fieldName}Element);
+ this.${fieldName} = new ${className}Element(${fieldName}Element);
}
</#if>
</#macro>
@@ -375,13 +375,13 @@ public final class ${className}<#if subs
<#if isList>
/** Returns the <code>&lt;${elementName}&gt;</code> child
elements. */
- public List<${className}> get${className}List() {
+ public List<${className}Element> get${className}List() {
return this.${fieldName}List;
}
<#else>
/** Returns the <code>&lt;${elementName}&gt;</code> child element, or
<code>null</code> if no child element was found. */
- public ${className} get${className}() {
+ public ${className}Element get${className}() {
return this.${fieldName};
}
</#if>
@@ -393,19 +393,19 @@ public final class ${className}<#if subs
<@fileHeader />
/**
- * A ${className} factory.
+ * A ${className}Element factory.
*/
@ThreadSafe
-public final class ${className}Factory {
+public final class ${className}ElementFactory {
- public static ${className} create(Element element) {
+ public static ${className}Element create(Element element) {
String elementName = element.getNodeName();
<#list allElements as globalElement>
<#if globalElement.getAttribute("substitutionGroup") == elementName>
<#local targetElementName = globalElement.getAttribute("name")>
<#local className =
Static["org.ofbiz.base.util.UtilXml"].nodeNameToJavaName(targetElementName, true)>
if ("${targetElementName}".equals(elementName)) {
- return new ${className}(element);
+ return new ${className}Element(element);
}
</#if>
</#list>