Skip to content

Commit

Permalink
Draft of requestfactory-server jakarta variant
Browse files Browse the repository at this point in the history
  • Loading branch information
niloc132 committed Sep 27, 2023
1 parent 9835498 commit 7df339b
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 8 deletions.
2 changes: 1 addition & 1 deletion maven/lib-gwt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ function maven-gwt() {
# Deploy RequestFactory jars
maven-deploy-file $mavenRepoUrl $mavenRepoId $pomDir/requestfactory/pom.xml $pomDir/requestfactory/pom.xml || die

for i in client server apt
for i in client server apt server-jakarta
do
maven-deploy-file $mavenRepoUrl $mavenRepoId $GWT_EXTRACT_DIR/requestfactory-${i}.jar $pomDir/requestfactory/${i}/pom.xml \
$JAVADOC_FILE_PATH $GWT_EXTRACT_DIR/requestfactory-${i}-src.jar \
Expand Down
27 changes: 27 additions & 0 deletions maven/poms/requestfactory/server-jakarta/pom-template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.gwtproject.web.bindery</groupId>
<artifactId>requestfactory</artifactId>
<version>${gwtVersion}</version>
</parent>
<groupId>org.gwtproject.web.bindery</groupId>
<artifactId>requestfactory-server-jakarta</artifactId>
<packaging>jar</packaging>
<version>${gwtVersion}</version>
<dependencies>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<!-- Used for source-mapping in stacktrace deobfuscation for logging -->
<optional>true</optional>
</dependency>
</dependencies>
</project>
27 changes: 23 additions & 4 deletions requestfactory/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,24 @@
<!-- Build a jar file containing a subset of requestfactory -->
<macrodef name="requestfactory-jar">
<!--
"target" should be one of {client,server,all}[(+|-)src] or test[-src].
"target" should be one of {client,server,all,apt}[(+|-)src] or test[-src].
-src includes .java files only, +src includes .java and .class files
-->
<attribute name="target" default="client"/>
<!--
"main" defaults to the javax.servlet extractor type, but should be set to
the jakarta variant to correctly package jakarta server .class and .java
files.
-->
<attribute name="main" default="com.google.web.bindery.requestfactory.server.RequestFactoryJarExtractor" />
<sequential>
<java failonerror="true" fork="true"
classname="com.google.web.bindery.requestfactory.server.RequestFactoryJarExtractor">
<java failonerror="true" fork="true" classname="@{main}">
<classpath>
<fileset dir="${gwt.build.lib}" includes="gwt-user.jar,gwt-dev.jar" />
<pathelement location="${gwt.tools.lib}/jakarta-servlet/jakarta.servlet-api-5.0.0/jakarta.servlet-api-5.0.0.jar" />
<pathelement location="${gwt.tools.lib}/junit/junit-4.8.2.jar" />
<pathelement path="${gwt.build.out}/user/bin" />
<pathelement path="${gwt.build.out}/user/bin-jakarta" />
<pathelement path="${gwt.build.out}/dev/bin-test" />
<pathelement path="${gwt.build.out}/user/bin-test" />
</classpath>
Expand Down Expand Up @@ -81,6 +88,18 @@
<requestfactory-jar target="server+src"/>
</target>

<target name="requestfactory-server-jakarta" description="Build RequestFactory server jar for jakarta.servlet">
<requestfactory-jar target="server-jakarta" main="com.google.web.bindery.requestfactory.server.jakarta.RequestFactoryJarExtractor"/>
</target>

<target name="requestfactory-server-jakarta-src" description="Build RequestFactory server source jar for jakarta.servlet">
<requestfactory-jar target="server-jakarta-src" main="com.google.web.bindery.requestfactory.server.jakarta.RequestFactoryJarExtractor"/>
</target>

<target name="requestfactory-server-jakarta+src" description="Build RequestFactory server source/class jar for jakarta.servlet">
<requestfactory-jar target="server-jakarta+src" main="com.google.web.bindery.requestfactory.server.jakarta.RequestFactoryJarExtractor"/>
</target>

<!-- This target requires classes from ../build/{dev,user}/bin-test -->
<target name="requestfactory-test"
unless="test.requestfactory.disable"
Expand All @@ -93,7 +112,7 @@
<target name="clientjars" depends="requestfactory-apt,requestfactory-apt-src,requestfactory-client,requestfactory-client-src,requestfactory-client+src" description="Build requestfactory client jars" />

<!-- Build all server jars -->
<target name="serverjars" depends="requestfactory-server,requestfactory-server-src,requestfactory-server+src" description="Build requestfactory server jars" />
<target name="serverjars" depends="requestfactory-server,requestfactory-server-src,requestfactory-server+src,requestfactory-server-jakarta,requestfactory-server-jakarta-src,requestfactory-server-jakarta+src" description="Build requestfactory server jars" />

<!-- Default target, build client and server jars.
Assumes the 'user' target has been built in the trunk directory
Expand Down
21 changes: 18 additions & 3 deletions user/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@
<sequential>
<!-- Start by copying all sources as-is to a new directory - Note that despite the name, there will be a small bit of servlet-specific code left in here, mostly for the junit runner which will not be updated at this time. -->
<copy todir="${project.build}/no-servlet-src" encoding="${javac.encoding}">
<!-- Exclude files for builds or examples -->
<fileset dir="src" excludes="**/RequestFactoryLogHandler.java,**/RequestFactoryJarExtractor.java" />
<fileset dir="src" />
</copy>

<!-- Move any server-side code that uses servlets to a separate directory, and refactor to replace javax with jakarta -->
<move todir="${project.build}/jakarta-src/com/google/gwt/core/server/jakarta">
<filelist dir="${project.build}/no-servlet-src/com/google/gwt/core/server">
Expand Down Expand Up @@ -205,13 +205,17 @@
</move>
<move todir="${project.build}/jakarta-src/com/google/web/bindery/requestfactory/server/jakarta">
<filelist dir="${project.build}/no-servlet-src/com/google/web/bindery/requestfactory/server">
<file name="RequestFactoryServlet.java"/>
<file name="Logging.java"/>
<file name="RequestFactoryJarExtractor.java"/>
<file name="RequestFactoryServlet.java"/>
</filelist>
<filterchain>
<tokenfilter>
<replacestring from="package com.google.web.bindery.requestfactory.server" to="package com.google.web.bindery.requestfactory.server.jakarta"/>
<replacestring from="com.google.gwt.user.server.rpc.RPCServletUtils" to="com.google.gwt.user.server.rpc.jakarta.RPCServletUtils"/>
<replacestring from="com.google.web.bindery.requestfactory.shared.LoggingRequest" to="com.google.web.bindery.requestfactory.shared.jakarta.LoggingRequest"/>
<replacestring from="com.google.web.bindery.requestfactory.gwt.client.RequestFactoryLogHandler" to="com.google.web.bindery.requestfactory.gwt.client.jakarta.RequestFactoryLogHandler"/>
<replaceregex pattern="^/\*\*" replace="import com.google.web.bindery.requestfactory.server.*;${line.separator}${line.separator}/**" />
</tokenfilter>
<tokenfilter>
<replacestring from="javax.servlet" to="jakarta.servlet"/>
Expand All @@ -230,6 +234,17 @@
</tokenfilter>
</filterchain>
</move>
<move todir="${project.build}/jakarta-src/com/google/web/bindery/requestfactory/gwt/client/jakarta">
<filelist dir="${project.build}/no-servlet-src/com/google/web/bindery/requestfactory/gwt/client">
<file name="RequestFactoryLogHandler.java"/>
</filelist>
<filterchain>
<tokenfilter>
<replacestring from="package com.google.web.bindery.requestfactory.gwt.client" to="package com.google.web.bindery.requestfactory.gwt.client.jakarta"/>
<replacestring from="com.google.web.bindery.requestfactory.shared.LoggingRequest" to="com.google.web.bindery.requestfactory.shared.jakarta.LoggingRequest"/>
</tokenfilter>
</filterchain>
</move>

<!-- add an extra wildcard import to relocated rpc/rf classes that need to reference existing types -->
<replace file="${project.build}/jakarta-src/com/google/gwt/user/server/rpc/jakarta/AbstractXsrfProtectedServiceServlet.java" token="${line.separator}/**" value="import com.google.gwt.user.server.rpc.*;${line.separator}${line.separator}/**" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,7 @@ public String toString() {
SEEDS.put("apt", aptClasses);
SEEDS.put("client", Collections.unmodifiableList(clientClasses));
SEEDS.put("server", Collections.unmodifiableList(serverClasses));
SEEDS.put("server-jakarta", Collections.unmodifiableList(serverClasses));

Set<Class<?>> all = new LinkedHashSet<Class<?>>();
for (List<Class<?>> value : SEEDS.values()) {
Expand Down Expand Up @@ -1052,6 +1053,7 @@ private Type processType(String sourceType, Type type) {
assert type.getInternalName().charAt(0) != 'L';
if (type.getInternalName().startsWith("java/") ||
type.getInternalName().startsWith("javax/") ||
type.getInternalName().startsWith("jakarta/") ||
type.getInternalName().startsWith("com/google/gson/")) {
return toReturn;
}
Expand Down

0 comments on commit 7df339b

Please sign in to comment.