Skip to content

Commit 620ce26

Browse files
Merge pull request #102 from webfirmframework/dev-12.x.x
wffweb-12.0.9 release changes
2 parents 714cbd4 + 9715847 commit 620ce26

File tree

29 files changed

+1236
-339
lines changed

29 files changed

+1236
-339
lines changed

.circleci/config.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,23 @@ jobs:
127127
name: Test
128128
command: mvn test
129129

130+
build-and-test-openjdk-25:
131+
docker:
132+
- image: cimg/openjdk:25.0
133+
working_directory: ~/wff/wffweb
134+
steps:
135+
# Checkout the code as the first step.
136+
- checkout:
137+
path: ~/wff
138+
# Use mvn clean and package as the standard maven build phase
139+
- run:
140+
name: Build
141+
command: mvn -B -DskipTests clean package
142+
# Then run your tests!
143+
- run:
144+
name: Test
145+
command: mvn test
146+
130147
workflows:
131148
# Below is the definition of your workflow.
132149
# Inside the workflow, you provide the jobs you want to run, e.g this workflow runs the build-and-test job above.
@@ -141,3 +158,4 @@ workflows:
141158
- build-and-test-openjdk-21
142159
- build-and-test-openjdk-23
143160
- build-and-test-openjdk-24
161+
- build-and-test-openjdk-25

wffweb/pom.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>com.webfirmframework</groupId>
66
<artifactId>wffweb</artifactId>
7-
<version>12.0.8</version>
7+
<version>12.0.9</version>
88

99
<properties>
1010
<maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format>
@@ -49,7 +49,7 @@
4949
<plugin>
5050
<groupId>org.sonatype.central</groupId>
5151
<artifactId>central-publishing-maven-plugin</artifactId>
52-
<version>0.8.0</version>
52+
<version>0.9.0</version>
5353
<extensions>true</extensions>
5454
<configuration>
5555
<publishingServerId>central</publishingServerId>
@@ -59,7 +59,7 @@
5959
<plugin>
6060
<groupId>org.apache.maven.plugins</groupId>
6161
<artifactId>maven-gpg-plugin</artifactId>
62-
<version>3.2.7</version>
62+
<version>3.2.8</version>
6363
<configuration>
6464
<arguments>-Dgpg.passphrase=${gpg.passphrase}</arguments>
6565
</configuration>
@@ -76,7 +76,7 @@
7676
<plugin>
7777
<groupId>org.apache.maven.plugins</groupId>
7878
<artifactId>maven-compiler-plugin</artifactId>
79-
<version>3.14.0</version>
79+
<version>3.14.1</version>
8080
</plugin>
8181

8282
<plugin>
@@ -102,7 +102,7 @@
102102
<plugin>
103103
<groupId>org.apache.maven.plugins</groupId>
104104
<artifactId>maven-javadoc-plugin</artifactId>
105-
<version>3.11.3</version>
105+
<version>3.12.0</version>
106106
<executions>
107107
<execution>
108108
<id>attach-javadocs</id>
@@ -140,9 +140,9 @@
140140
<scope>test</scope>
141141
</dependency>
142142
<dependency>
143-
<groupId>com.fasterxml.jackson.core</groupId>
143+
<groupId>tools.jackson.core</groupId>
144144
<artifactId>jackson-databind</artifactId>
145-
<version>2.20.0</version>
145+
<version>3.0.2</version>
146146
<scope>test</scope>
147147
</dependency>
148148
<dependency>

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

Lines changed: 50 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ public enum WffJsFile {
8282
// should be static final
8383
public static final boolean PRODUCTION_MODE = true;
8484

85+
static final boolean DEV_MODE = false;
86+
8587
public static final boolean COMPRESSED_WFF_DATA = true;
8688

8789
private static final String allOptimizedContent;
@@ -93,7 +95,9 @@ public enum WffJsFile {
9395
private static String[][] minifiableParts = { { "else {", "else{" }, { "} else", "}else" }, { "if (", "if(" },
9496
{ ") {", "){" } };
9597

96-
private static final String HEART_BEAT_JS = "setInterval(function(){try{wffWS.send([]);}catch(e){wffWS.closeSocket();}},\"${HEARTBEAT_INTERVAL}\");";
98+
private static final String HEART_BEAT_JS = """
99+
setInterval(function(){wffWS.checkCon();},"${HEARTBEAT_INTERVAL}");
100+
""".trim();
97101

98102
/**
99103
* INDEXED_TAGS_ARRAY
@@ -555,43 +559,75 @@ private String buildOptimizedFileContent() {
555559
* @param losslessCommunication
556560
* @param onPayloadLossJS
557561
* @return the js string for the client
558-
* @author WFF
562+
* @deprecated since 12.0.9. It will be removed in future version as there
563+
* another overloading method available for the same purpose.
559564
*/
565+
@Deprecated(forRemoval = true, since = "12.0.9")
560566
public static String getAllOptimizedContent(final String wsUrl, final String instanceId,
561567
final boolean removePrevBPOnInitTab, final boolean removePrevBPOnClosetTab, final int heartbeatInterval,
562568
final int wsReconnectInterval, final boolean autoremoveParentScript, final boolean losslessCommunication,
563569
final String onPayloadLossJS) {
570+
return getAllOptimizedContent(wsUrl, instanceId, removePrevBPOnInitTab, removePrevBPOnClosetTab,
571+
heartbeatInterval, 5000, wsReconnectInterval, autoremoveParentScript, losslessCommunication,
572+
onPayloadLossJS);
573+
}
574+
575+
/**
576+
* NB :- This method is only for internal use.
577+
*
578+
* @param wsUrl the complete websocket url
579+
* @param instanceId the instanceId of browserPage
580+
* @param removePrevBPOnInitTab true or false
581+
* @param removePrevBPOnClosetTab true or false
582+
* @param heartbeatInterval in milliseconds
583+
* @param wsHeartbeatTimeout
584+
* @param wsReconnectInterval in milliseconds
585+
* @param autoremoveParentScript true or false
586+
* @param losslessCommunication
587+
* @param onPayloadLossJS
588+
* @return the js string for the client
589+
* @since 12.0.9 Added heartbeat timeout.
590+
*/
591+
public static String getAllOptimizedContent(final String wsUrl, final String instanceId,
592+
final boolean removePrevBPOnInitTab, final boolean removePrevBPOnClosetTab, final int heartbeatInterval,
593+
final int wsHeartbeatTimeout, final int wsReconnectInterval, final boolean autoremoveParentScript,
594+
final boolean losslessCommunication, final String onPayloadLossJS) {
564595

565596
if (heartbeatInterval > 0) {
566597
if (autoremoveParentScript) {
567598
return buildJsContentWithHeartbeat(wsUrl, instanceId, removePrevBPOnInitTab, removePrevBPOnClosetTab,
568-
heartbeatInterval, wsReconnectInterval, losslessCommunication, onPayloadLossJS)
569-
.append(AUTOREMOVE_PARENT_SCRIPT).toString();
599+
heartbeatInterval, wsHeartbeatTimeout, wsReconnectInterval, losslessCommunication,
600+
onPayloadLossJS).append(AUTOREMOVE_PARENT_SCRIPT).toString();
570601
}
571602
return buildJsContentWithHeartbeat(wsUrl, instanceId, removePrevBPOnInitTab, removePrevBPOnClosetTab,
572-
heartbeatInterval, wsReconnectInterval, losslessCommunication, onPayloadLossJS).toString();
603+
heartbeatInterval, wsHeartbeatTimeout, wsReconnectInterval, losslessCommunication, onPayloadLossJS)
604+
.toString();
573605
}
574606

575607
if (autoremoveParentScript) {
576608
return buildJsContentWithoutHeartbeat(wsUrl, instanceId, removePrevBPOnInitTab, removePrevBPOnClosetTab,
577-
heartbeatInterval, wsReconnectInterval, losslessCommunication, onPayloadLossJS)
609+
heartbeatInterval, wsHeartbeatTimeout, wsReconnectInterval, losslessCommunication, onPayloadLossJS)
578610
.append(AUTOREMOVE_PARENT_SCRIPT).toString();
579611
}
580612
return buildJsContentWithoutHeartbeat(wsUrl, instanceId, removePrevBPOnInitTab, removePrevBPOnClosetTab,
581-
heartbeatInterval, wsReconnectInterval, losslessCommunication, onPayloadLossJS).toString();
613+
heartbeatInterval, wsHeartbeatTimeout, wsReconnectInterval, losslessCommunication, onPayloadLossJS)
614+
.toString();
582615
}
583616

584617
private static StringBuilder buildJsContentWithHeartbeat(final String wsUrl, final String instanceId,
585618
final boolean removePrevBPOnInitTab, final boolean removePrevBPOnClosetTab, final int heartbeatInterval,
586-
final int wsReconnectInterval, final boolean losslessCommunication, final String onPayloadLossJS) {
619+
final int wsHeartbeatTimeout, final int wsReconnectInterval, final boolean losslessCommunication,
620+
final String onPayloadLossJS) {
587621
return buildJsContentWithoutHeartbeat(wsUrl, instanceId, removePrevBPOnInitTab, removePrevBPOnClosetTab,
588-
heartbeatInterval, wsReconnectInterval, losslessCommunication, onPayloadLossJS).append(
589-
HEART_BEAT_JS.replace("\"${HEARTBEAT_INTERVAL}\"", Integer.toString(heartbeatInterval)));
622+
heartbeatInterval, wsHeartbeatTimeout, wsReconnectInterval, losslessCommunication, onPayloadLossJS)
623+
.append(HEART_BEAT_JS.replace("\"${HEARTBEAT_INTERVAL}\"",
624+
Integer.toString(heartbeatInterval)));
590625
}
591626

592627
private static StringBuilder buildJsContentWithoutHeartbeat(final String wsUrl, final String instanceId,
593628
final boolean removePrevBPOnInitTab, final boolean removePrevBPOnClosetTab, final int heartbeatInterval,
594-
final int wsReconnectInterval, final boolean losslessCommunication, final String onPayloadLossJS) {
629+
final int wsHeartbeatTimeout, final int wsReconnectInterval, final boolean losslessCommunication,
630+
final String onPayloadLossJS) {
595631

596632
final StringBuilder globalContentBuider = new StringBuilder(WFF_GLOBAL.optimizedFileContent);
597633

@@ -626,6 +662,7 @@ private static StringBuilder buildJsContentWithoutHeartbeat(final String wsUrl,
626662

627663
StringBuilderUtil.replaceFirst(globalContentBuider, "\"${WS_RECON}\"", String.valueOf(wsReconnectInterval));
628664
StringBuilderUtil.replaceFirst(globalContentBuider, "\"${WS_HRTBT}\"", String.valueOf(heartbeatInterval));
665+
StringBuilderUtil.replaceFirst(globalContentBuider, "\"${WS_HRTBT_TMT}\"", String.valueOf(wsHeartbeatTimeout));
629666
StringBuilderUtil.replaceFirst(globalContentBuider, "\"${LOSSLESS_COMM}\"",
630667
String.valueOf(losslessCommunication));
631668
String onLossyCommJS = onPayloadLossJS != null ? onPayloadLossJS.strip() : "";
@@ -634,8 +671,8 @@ private static StringBuilder buildJsContentWithoutHeartbeat(final String wsUrl,
634671

635672
final String globalContent = globalContentBuider.toString();
636673

637-
return new StringBuilder("var wffLog = console.log;").append(JS_WORK_AROUND.optimizedFileContent)
638-
.append(globalContent).append(allOptimizedContent);
674+
return new StringBuilder(DEV_MODE ? "\"use strict\"\nvar wffLog = console.log;" : "var wffLog = console.log;")
675+
.append(JS_WORK_AROUND.optimizedFileContent).append(globalContent).append(allOptimizedContent);
639676
}
640677

641678
}

wffweb/src/main/java/com/webfirmframework/wffweb/json/JsonBaseNode.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
*/
1616
package com.webfirmframework.wffweb.json;
1717

18+
import java.io.IOException;
19+
import java.io.OutputStream;
20+
import java.nio.charset.Charset;
21+
1822
/**
1923
* @since 12.0.4
2024
*/
@@ -27,4 +31,30 @@ public sealed interface JsonBaseNode extends JsonPart permits JsonMapNode, JsonL
2731
@Override
2832
String toJsonString();
2933

34+
/**
35+
* @return the JSON string.
36+
* @since 12.0.9
37+
*/
38+
String toBigJsonString();
39+
40+
/**
41+
* @param outputStream the OutputStream to write the json.
42+
* @param charset the charset
43+
* @param flushOnWrite true to flush after each write operation otherwise false.
44+
* @throws IOException if writing to OutputStream throws an exception.
45+
* @since 12.0.9
46+
*/
47+
void toOutputStream(final OutputStream outputStream, final Charset charset, final boolean flushOnWrite)
48+
throws IOException;
49+
50+
/**
51+
* @param outputStream the OutputStream to write the json.
52+
* @param charset the charset
53+
* @throws IOException if writing to OutputStream throws an exception.
54+
* @since 12.0.9
55+
*/
56+
default void toOutputStream(final OutputStream outputStream, final Charset charset) throws IOException {
57+
toOutputStream(outputStream, charset, false);
58+
}
59+
3060
}

wffweb/src/main/java/com/webfirmframework/wffweb/json/JsonListNode.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@
1515
*/
1616
package com.webfirmframework.wffweb.json;
1717

18+
import java.io.IOException;
19+
import java.io.OutputStream;
1820
import java.math.BigDecimal;
1921
import java.math.BigInteger;
22+
import java.nio.charset.Charset;
2023
import java.util.List;
2124
import java.util.stream.Collectors;
2225

@@ -168,6 +171,45 @@ default String toJsonString() {
168171
return stream().map(JsonStringUtil::buildJsonValue).collect(Collectors.joining(",", "[", "]"));
169172
}
170173

174+
/**
175+
* @return the JSON array string.
176+
* @since 12.0.9
177+
*/
178+
@Override
179+
default String toBigJsonString() {
180+
// Note: never use parallel stream as its index order of values should be
181+
// unchanged.
182+
return stream().map(JsonStringUtil::buildBigJsonValue).collect(Collectors.joining(",", "[", "]"));
183+
}
184+
185+
/**
186+
* @param outputStream the OutputStream to write the json.
187+
* @param charset the charset
188+
* @param flushOnWrite true to flush after each write operation otherwise false.
189+
* @throws IOException if writing to OutputStream throws an exception.
190+
* @since 12.0.9
191+
*/
192+
@Override
193+
default void toOutputStream(final OutputStream outputStream, final Charset charset, final boolean flushOnWrite)
194+
throws IOException {
195+
final byte squareBracketOpen = "[".getBytes(charset)[0];
196+
final byte squareBracketClose = "]".getBytes(charset)[0];
197+
final byte comma = ",".getBytes(charset)[0];
198+
outputStream.write(squareBracketOpen);
199+
boolean first = true;
200+
for (final Object value : this) {
201+
if (!first) {
202+
outputStream.write(comma);
203+
}
204+
JsonStringUtil.writeJsonValue(outputStream, charset, flushOnWrite, value);
205+
first = false;
206+
}
207+
outputStream.write(squareBracketClose);
208+
if (flushOnWrite) {
209+
outputStream.flush();
210+
}
211+
}
212+
171213
/**
172214
* NB: The array should not contain null values.
173215
*

wffweb/src/main/java/com/webfirmframework/wffweb/json/JsonMapNode.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@
1515
*/
1616
package com.webfirmframework.wffweb.json;
1717

18+
import java.io.IOException;
19+
import java.io.OutputStream;
1820
import java.math.BigDecimal;
1921
import java.math.BigInteger;
22+
import java.nio.charset.Charset;
2023
import java.util.Map;
2124
import java.util.stream.Collectors;
2225

@@ -191,6 +194,34 @@ default String toJsonString() {
191194
return entrySet().stream().map(JsonStringUtil::buildJsonKeyValue).collect(Collectors.joining(",", "{", "}"));
192195
}
193196

197+
/**
198+
* @param outputStream the OutputStream to write the json.
199+
* @param charset the charset
200+
* @param flushOnWrite true to flush after each write operation otherwise false.
201+
* @throws IOException if writing to OutputStream throws an exception.
202+
* @since 12.0.9
203+
*/
204+
@Override
205+
default void toOutputStream(final OutputStream outputStream, final Charset charset, final boolean flushOnWrite)
206+
throws IOException {
207+
final byte curlyBraceOpen = "{".getBytes(charset)[0];
208+
final byte curlyBraceClose = "}".getBytes(charset)[0];
209+
final byte comma = ",".getBytes(charset)[0];
210+
outputStream.write(curlyBraceOpen);
211+
boolean first = true;
212+
for (final Map.Entry<String, Object> entry : entrySet()) {
213+
if (!first) {
214+
outputStream.write(comma);
215+
}
216+
JsonStringUtil.writeJsonKeyValue(outputStream, charset, flushOnWrite, entry);
217+
first = false;
218+
}
219+
outputStream.write(curlyBraceClose);
220+
if (flushOnWrite) {
221+
outputStream.flush();
222+
}
223+
}
224+
194225
/**
195226
* It internally utilizes parallel stream to build json string. The order of
196227
* json object entries will be unpredictable but the json array will maintain
@@ -199,6 +230,7 @@ default String toJsonString() {
199230
* @return the JSON object string.
200231
* @since 12.0.4
201232
*/
233+
@Override
202234
default String toBigJsonString() {
203235
return entrySet().stream().parallel().map(JsonStringUtil::buildBigJsonKeyValue)
204236
.collect(Collectors.joining(",", "{", "}"));

0 commit comments

Comments
 (0)