Skip to content

Commit 5e65add

Browse files
Merge branch 'develop'
2 parents f92582e + 96c2f16 commit 5e65add

File tree

9 files changed

+123
-39
lines changed

9 files changed

+123
-39
lines changed

wffweb/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>com.webfirmframework</groupId>
55
<artifactId>wffweb</artifactId>
6-
<version>2.1.9</version>
6+
<version>2.1.10</version>
77

88
<properties>
99
<maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format>

wffweb/src/main/java/com/webfirmframework/wffweb/css/file/AbstractCssFileBlock.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,9 @@ public String toString() {
139139
toStringBuilder.delete(0, toStringBuilder.length());
140140
for (final CssProperty cssProperty : this) {
141141
toStringBuilder.append(cssProperty.getCssName())
142-
.append(":")
142+
.append(':')
143143
.append(cssProperty.getCssValue())
144-
.append(";");
144+
.append(';');
145145
}
146146
setModified(false);
147147
}

wffweb/src/main/java/com/webfirmframework/wffweb/server/page/Task.java

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@
1515
*/
1616
package com.webfirmframework.wffweb.server.page;
1717

18-
import com.webfirmframework.wffweb.server.page.js.WffJsFile;
18+
import java.util.Comparator;
19+
import java.util.Set;
20+
import java.util.TreeSet;
21+
1922
import com.webfirmframework.wffweb.util.data.NameValue;
2023

2124
/**
@@ -104,10 +107,13 @@ public enum Task {
104107

105108
private static String jsObjectString;
106109

110+
// WffJsFile.PRODUCTION_MODE, there is bug while enabling this
111+
private static final boolean SHORT_NAME_ENABLED = false;
112+
107113
private Task() {
108114
valueByte = (byte) ordinal();
109115
shortName = "T".concat(String.valueOf(ordinal()));
110-
jsNameValue = WffJsFile.PRODUCTION_MODE
116+
jsNameValue = SHORT_NAME_ENABLED
111117
? shortName.concat(":").concat(String.valueOf(ordinal()))
112118
: name().concat(":").concat(String.valueOf(ordinal()));
113119
}
@@ -190,4 +196,37 @@ public String getShortName() {
190196
return shortName;
191197
}
192198

199+
/**
200+
* @return the sorted set of tasks in the descending order of the name of
201+
* task length.
202+
* @since 2.1.10
203+
* @author WFF
204+
*/
205+
public static Set<Task> getSortedTasks() {
206+
207+
final Set<Task> sortedTaskNames = new TreeSet<Task>(
208+
new Comparator<Task>() {
209+
210+
@Override
211+
public int compare(final Task o1, final Task o2) {
212+
// to sort the tasks in descending order of the length
213+
// of the
214+
// names
215+
if (o1.name().length() > o2.name().length()) {
216+
return -1;
217+
}
218+
if (o1.name().length() < o2.name().length()) {
219+
return 1;
220+
}
221+
return -1;
222+
}
223+
});
224+
225+
for (final Task task : Task.values()) {
226+
sortedTaskNames.add(task);
227+
}
228+
229+
return sortedTaskNames;
230+
}
231+
193232
}

wffweb/src/main/java/com/webfirmframework/wffweb/server/page/js/WffJsFile.java

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
import java.io.BufferedReader;
1919
import java.io.InputStream;
2020
import java.io.InputStreamReader;
21-
import java.util.LinkedHashSet;
21+
import java.util.Comparator;
2222
import java.util.Set;
23+
import java.util.TreeSet;
2324
import java.util.logging.Level;
2425
import java.util.logging.Logger;
2526

@@ -78,14 +79,29 @@ public enum WffJsFile {
7879

7980
private static volatile int variableId = 0;
8081

81-
private static final String HEART_BEAT_JS = "setInterval(function(){try{wffWS.send([]);}catch(e){}},\"${HEARTBEAT_INTERVAL}\");";
82+
private static final String HEART_BEAT_JS = "setInterval(function(){try{wffWS.send([]);}catch(e){wffWS.closeSocket();}},\"${HEARTBEAT_INTERVAL}\");";
8283

8384
static {
8485

8586
if (PRODUCTION_MODE) {
8687

87-
functionNames = new LinkedHashSet<String>();
88-
variableNames = new LinkedHashSet<String>();
88+
final Comparator<String> descendingLehgth = new Comparator<String>() {
89+
90+
@Override
91+
public int compare(final String o1, final String o2) {
92+
// to sort in descending order of the length of the names
93+
if (o1.length() > o2.length()) {
94+
return -1;
95+
}
96+
if (o1.length() < o2.length()) {
97+
return 1;
98+
}
99+
return -1;
100+
}
101+
};
102+
103+
functionNames = new TreeSet<String>(descendingLehgth);
104+
variableNames = new TreeSet<String>(descendingLehgth);
89105

90106
// should be in descending order of the value length
91107

@@ -96,19 +112,17 @@ public enum WffJsFile {
96112
functionNames.add("parseWffBinaryMessageBytes");
97113
functionNames.add("getAttrUpdatedWffBMBytes");
98114
functionNames.add("getWffBinaryMessageBytes");
99-
functionNames.add("getWffBinaryMessageBytes");
100115
functionNames.add("getIntFromOptimizedBytes");
101116
functionNames.add("getOptimizedBytesFromInt");
102117
functionNames.add("isWffWindowEventSupported");
103118
functionNames.add("getTagByTagNameAndWffId");
104119
functionNames.add("getTagDeletedWffBMBytes");
105120
functionNames.add("createTagFromWffBMBytes");
106121
functionNames.add("getTagCreatedWffBMBytes");
107-
functionNames.add("getTagByTagNameAndWffId");
108-
functionNames.add("createTagFromWffBMBytes");
109122
functionNames.add("wffRemovePrevBPInstance");
110123
functionNames.add("getWffIdFromWffIdBytes");
111124
functionNames.add("getWffIdFromWffIdBytes");
125+
functionNames.add("extractEachValueBytes");
112126
functionNames.add("getWffIdBytesFromTag");
113127
functionNames.add("getWffIdBytesFromTag");
114128
functionNames.add("wffRemoveBPInstance");
@@ -118,11 +132,11 @@ public enum WffJsFile {
118132
functionNames.add("splitAttrNameValue");
119133
functionNames.add("getBytesFromDouble");
120134
functionNames.add("getStringFromBytes");
121-
functionNames.add("splitAttrNameValue");
122135
functionNames.add("concatArrayValues");
123136
functionNames.add("getTaskNameValue");
124137
functionNames.add("getValueTypeByte");
125138
functionNames.add("onWffWindowClose");
139+
functionNames.add("getValueTypeByte");
126140
functionNames.add("getIntFromBytes");
127141
functionNames.add("getBytesFromInt");
128142
functionNames.add("getTagByWffId");
@@ -133,25 +147,29 @@ public enum WffJsFile {
133147

134148
variableNames.add("wffRemovePrevBPInstanceInvoked");
135149
variableNames.add("maxBytesLengthFromTotalBytes");
150+
variableNames.add("totalNoOfBytesForAllValues");
136151
variableNames.add("maxBytesLengthForAllValues");
137152
variableNames.add("totalNoOfBytesForAllValues");
138153
variableNames.add("indexInWffBinaryMessage");
139154
variableNames.add("valueLengthBytesLength");
155+
variableNames.add("nameLengthBytesLength");
140156
variableNames.add("wffBinaryMessageBytes");
141157
variableNames.add("maxNoValueLengthBytes");
142158
variableNames.add("attrNameAndValueBytes");
143159
variableNames.add("nameLengthBytesLength");
144160
variableNames.add("extractEachValueBytes");
161+
variableNames.add("nameLengthBytesLength");
162+
variableNames.add("maxNoNameLengthBytes");
145163
variableNames.add("nameValueCallbackFun");
146164
variableNames.add("superParentNameValue");
147165
variableNames.add("currentParentTagName");
148166
variableNames.add("maxValuesBytesLength");
149167
variableNames.add("maxNoNameLengthBytes");
150168
variableNames.add("parentOfExistingTag");
169+
variableNames.add("maxNoOfValuesBytes");
151170
variableNames.add("wffInstanceIdBytes");
152171
variableNames.add("attrNameValueBytes");
153172
variableNames.add("currentParentWffId");
154-
variableNames.add("maxNoOfValuesBytes");
155173
variableNames.add("callbackFunctions");
156174
variableNames.add("attrNameValueArry");
157175
variableNames.add("superParentValues");
@@ -163,11 +181,14 @@ public enum WffJsFile {
163181
variableNames.add("valueLengthBytes");
164182
variableNames.add("methodNameBytes");
165183
variableNames.add("valueLegthBytes");
184+
variableNames.add("bmObjOrArrBytes");
185+
variableNames.add("nameLengthBytes");
166186
variableNames.add("valuesToAppend");
167187
variableNames.add("parentDocIndex");
168188
variableNames.add("beforeTagWffId");
169189
variableNames.add("nameLegthBytes");
170190
variableNames.add("nodeValueBytes");
191+
variableNames.add("nameLegthBytes");
171192
variableNames.add("callbackFunId");
172193
variableNames.add("fromByteArray");
173194
variableNames.add("applicableTag");
@@ -202,7 +223,6 @@ public enum WffJsFile {
202223
variableNames.add("nameBytes");
203224
variableNames.add("beforeTag");
204225
variableNames.add("attrValue");
205-
variableNames.add("attrValue");
206226
variableNames.add("attrBytes");
207227
variableNames.add("htmlNodes");
208228
variableNames.add("wffTagId");
@@ -274,7 +294,9 @@ private void init() {
274294
builder.append(line);
275295

276296
if (!line.isEmpty()) {
277-
if (!PRODUCTION_MODE) {
297+
if (line.charAt(line.length() - 1) != ';') {
298+
builder.append('\n');
299+
} else if (!PRODUCTION_MODE) {
278300
builder.append('\n');
279301
}
280302
}
@@ -388,10 +410,11 @@ public static String getAllOptimizedContent(final String wsUrl,
388410
"v" + (++variableId));
389411
}
390412

391-
for (final Task task : Task.values()) {
392-
allOptimizedContent = allOptimizedContent
393-
.replace(task.name(), task.getShortName());
394-
}
413+
// there is bug while enabling this, also enable in Task
414+
// for (final Task task : Task.getSortedTasks()) {
415+
// allOptimizedContent = allOptimizedContent
416+
// .replace(task.name(), task.getShortName());
417+
// }
395418

396419
functionNames = null;
397420
variableNames = null;
@@ -447,4 +470,5 @@ private static StringBuilder buildJsContentWithoutHeartbeat(
447470

448471
).append(allOptimizedContent);
449472
}
473+
450474
}

wffweb/src/main/java/com/webfirmframework/wffweb/tag/html/attribute/core/AbstractAttribute.java

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,20 @@ public abstract class AbstractAttribute extends AbstractTagBase {
3535
private static final Security ACCESS_OBJECT;
3636

3737
private String attributeName;
38+
3839
private String attributeValue;
39-
private Map<String, String> attributeValueMap;
40-
private Set<String> attributeValueSet;
40+
41+
private volatile Map<String, String> attributeValueMap;
42+
43+
private volatile Set<String> attributeValueSet;
4144

4245
private transient Set<AbstractHtml> ownerTags;
4346

4447
private StringBuilder tagBuilder;
4548

4649
// private AttributeValueChangeListener valueChangeListener;
4750

48-
private Set<AttributeValueChangeListener> valueChangeListeners;
51+
private volatile Set<AttributeValueChangeListener> valueChangeListeners;
4952

5053
private transient Charset charset = Charset.defaultCharset();
5154

@@ -442,7 +445,11 @@ public String toString() {
442445
*/
443446
protected Map<String, String> getAttributeValueMap() {
444447
if (attributeValueMap == null) {
445-
setAttributeValueMap(new LinkedHashMap<String, String>());
448+
synchronized (this) {
449+
if (attributeValueMap == null) {
450+
setAttributeValueMap(new LinkedHashMap<String, String>());
451+
}
452+
}
446453
}
447454
return attributeValueMap;
448455
}
@@ -457,10 +464,10 @@ protected void setAttributeValueMap(
457464
final Map<String, String> attributeValueMap) {
458465

459466
if (!Objects.equals(attributeValueMap, this.attributeValueMap)) {
467+
this.attributeValueMap = attributeValueMap;
460468
setModified(true);
461469
}
462470

463-
this.attributeValueMap = attributeValueMap;
464471
}
465472

466473
/**
@@ -719,7 +726,11 @@ public void setModified(final boolean modified) {
719726
*/
720727
protected Set<String> getAttributeValueSet() {
721728
if (attributeValueSet == null) {
722-
attributeValueSet = new LinkedHashSet<String>();
729+
synchronized (this) {
730+
if (attributeValueSet == null) {
731+
attributeValueSet = new LinkedHashSet<String>();
732+
}
733+
}
723734
}
724735
return attributeValueSet;
725736
}
@@ -732,9 +743,9 @@ protected Set<String> getAttributeValueSet() {
732743
*/
733744
protected void setAttributeValueSet(final Set<String> attributeValueSet) {
734745
if (!Objects.equals(this.attributeValueSet, attributeValueSet)) {
746+
this.attributeValueSet = attributeValueSet;
735747
setModified(true);
736748
}
737-
this.attributeValueSet = attributeValueSet;
738749
}
739750

740751
/**
@@ -881,7 +892,11 @@ public void setCharset(final Charset charset) {
881892
public void addValueChangeListener(
882893
final AttributeValueChangeListener valueChangeListener) {
883894
if (valueChangeListeners == null) {
884-
valueChangeListeners = new TreeSet<AttributeValueChangeListener>();
895+
synchronized (valueChangeListener) {
896+
if (valueChangeListeners == null) {
897+
valueChangeListeners = new TreeSet<AttributeValueChangeListener>();
898+
}
899+
}
885900
}
886901

887902
valueChangeListeners.add(valueChangeListener);

wffweb/src/main/resources/com/webfirmframework/wffweb/server/page/js/WffClasses.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ var WffBMArray = function(jsArray, outer) {
4040

4141
console.log('outer yes', outer);
4242

43-
if (outer === undefined || outer) {
43+
if (typeof outer === 'undefined' || outer) {
4444
console.log('added outer ');
4545

4646
// nameValue for representing object or array
@@ -130,7 +130,7 @@ var WffBMArray = function(jsArray, outer) {
130130
}
131131
} else if (arrayValType == 9) {
132132
for (var i = 0; i < jsArray.length; i++) {
133-
if (jsArray[i] === undefined || jsArray[i] == null) {
133+
if (typeof jsArray[i] === 'undefined' || jsArray[i] == null) {
134134
values.push([]);
135135
} else {
136136
values.push(new WffBMByteArray(jsArray[i], false)
@@ -170,7 +170,7 @@ var WffBMByteArray = function(int8Array, outer) {
170170

171171
console.log('outer yes', outer);
172172

173-
if (outer === undefined || outer) {
173+
if (typeof outer === 'undefined' || outer) {
174174
console.log('added outer ');
175175

176176
// nameValue for representing object or array
@@ -223,7 +223,7 @@ var WffBMObject = function(jsObject, outer) {
223223

224224
var nameValues = [];
225225

226-
if (outer === undefined || outer) {
226+
if (typeof outer === 'undefined' || outer) {
227227
// nameValue for representing object or array
228228
var typeNameValue = {
229229
name : [ 0 ],
@@ -324,7 +324,7 @@ var JsObjectFromBMBytes = function(wffBMBytes, outer) {
324324
var nameValues = wffBMUtil.parseWffBinaryMessageBytes(wffBMBytes);
325325

326326
var i = 0;
327-
if (outer === undefined || outer) {
327+
if (typeof outer === 'undefined' || outer) {
328328
i = 1;
329329
}
330330

@@ -396,7 +396,7 @@ var JsArrayFromBMBytes = function(wffBMBytes, outer) {
396396
var nameValues = wffBMUtil.parseWffBinaryMessageBytes(wffBMBytes);
397397

398398
var i = 0;
399-
if (outer === undefined || outer) {
399+
if (typeof outer === 'undefined' || outer) {
400400
i = 1;
401401
}
402402

wffweb/src/main/resources/com/webfirmframework/wffweb/server/page/js/wffBMUtil.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ var wffBMUtil = new function() {
185185

186186
/**
187187
* var array1 = [1]; var array2 = [2]; array1.concat(array2); will not work,
188-
* console.log(array1) will print [1]
188+
* console.log(array1); will print [1]
189189
*/
190190
var concatArrayValues = function(appendToArray, valuesToAppend) {
191191
for (var a = 0; a < valuesToAppend.length; a++) {

0 commit comments

Comments
 (0)