Skip to content

Commit fc1d7ff

Browse files
committed
EE11 jetty 12.1.0 WIP. Do not rely on.
1 parent 2485f3b commit fc1d7ff

157 files changed

Lines changed: 28302 additions & 179 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

api/src/main/java/com/google/apphosting/utils/remoteapi/EE10RemoteApiServlet.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
import com.google.protobuf.ByteString;
4343
import com.google.protobuf.ExtensionRegistry;
4444
import com.google.protobuf.Message;
45-
// <internal24>
45+
4646
import com.google.storage.onestore.v3.proto2api.OnestoreEntity;
4747
import com.google.storage.onestore.v3.proto2api.OnestoreEntity.EntityProto;
4848
import com.google.storage.onestore.v3.proto2api.OnestoreEntity.Path.Element;
@@ -452,7 +452,7 @@ static byte[] computeSha1OmittingLastByteForBackwardsCompatibility(EntityProto e
452452
return computeSha1(entityBytes, entityBytes.length - 1);
453453
}
454454

455-
// <internal25>
455+
456456
private static byte[] computeSha1(byte[] bytes, int length) {
457457
MessageDigest md;
458458
try {

api/src/main/java/com/google/apphosting/utils/remoteapi/RemoteApiServlet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ static byte[] computeSha1OmittingLastByteForBackwardsCompatibility(EntityProto e
452452
return computeSha1(entityBytes, entityBytes.length - 1);
453453
}
454454

455-
// <internal25>
455+
456456
private static byte[] computeSha1(byte[] bytes, int length) {
457457
MessageDigest md;
458458
try {

api_dev/src/main/java/com/google/appengine/tools/development/DevAppServerFactory.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,9 @@ private DevAppServer doCreateDevAppServer(
352352
}
353353
new AppEngineWebXmlInitialParse(appEngineWebXmlLocation.getAbsolutePath())
354354
.handleRuntimeProperties();
355-
if (Boolean.getBoolean("appengine.use.EE8") || Boolean.getBoolean("appengine.use.EE10")) {
355+
if (Boolean.getBoolean("appengine.use.EE8")
356+
|| Boolean.getBoolean("appengine.use.EE10")
357+
|| Boolean.getBoolean("appengine.use.EE11")) {
356358
AppengineSdk.resetSdk();
357359
}
358360
if (webXmlLocation.exists()) {

api_dev/src/main/java/com/google/appengine/tools/development/SharedMain.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,18 +229,23 @@ protected void configureRuntime(File appDirectory) {
229229
if (runtime.equals("java7")) {
230230
throw new IllegalArgumentException("the Java7 runtime is not supported anymore.");
231231
}
232-
// Locally set the correct values for all runtimes, for EE8 and EE10 system properties to the
232+
// Locally set the correct values for all runtimes, for EE8 and EE10/11 system properties to the
233233
// process of the devappserver.
234234
Map<String, String> props = appEngineWebXml.getSystemProperties();
235235
if (props.containsKey("appengine.use.EE8")) {
236236
System.setProperty("appengine.use.EE8", props.get("appengine.use.EE8"));
237237
AppengineSdk.resetSdk();
238-
}
239-
if (props.containsKey("appengine.use.EE10")) {
238+
} else if (props.containsKey("appengine.use.EE11")) {
239+
System.setProperty("appengine.use.EE11", props.get("appengine.use.EE11"));
240+
AppengineSdk.resetSdk();
241+
} else if (props.containsKey("appengine.use.EE10")) {
240242
System.setProperty("appengine.use.EE10", props.get("appengine.use.EE10"));
241243
AppengineSdk.resetSdk();
242244
}
243-
245+
if (props.containsKey("appengine.use.jetty121") || runtime.equals("java25")) {
246+
System.setProperty("appengine.use.jetty121", props.get("appengine.use.jetty121"));
247+
AppengineSdk.resetSdk();
248+
}
244249
sharedInit();
245250
}
246251

api_dev/src/main/java/com/google/appengine/tools/development/testing/ee10/FakeHttpServletResponse.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,11 @@ public Collection<String> getHeaderNames() {
358358
return headers.keys();
359359
}
360360

361+
@Override
362+
public void sendRedirect(String string, int i, boolean bln) throws IOException {
363+
throw new UnsupportedOperationException("Not supported yet.");
364+
}
365+
361366
private void checkCommit() {
362367
if (isCommitted()) {
363368
throw new IllegalStateException("Response is already committed");

api_dev/src/main/java/com/google/appengine/tools/info/AppengineSdk.java

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -275,17 +275,40 @@ static File[] listFiles(File dir) {
275275
return files;
276276
}
277277

278-
/** Returns an SDK implementation to use for access jar files and resources. */
279-
public static AppengineSdk getSdk() {
278+
/**
279+
* Returns an SDK implementation to use for access jar files and resources.
280+
*/
281+
public static AppengineSdk getSdk() {
280282
if (currentSdk != null) {
281283
return currentSdk;
282284
}
283-
if (Boolean.getBoolean("appengine.use.EE8")|| Boolean.getBoolean("appengine.use.EE10")) {
284-
return currentSdk = new Jetty12Sdk();
285-
} else {
286-
return currentSdk = new ClassicSdk();
287-
}
285+
286+
boolean useJetty121 = Boolean.getBoolean("appengine.use.jetty121");
287+
boolean useEE8 = Boolean.getBoolean("appengine.use.EE8");
288+
boolean useEE10 = Boolean.getBoolean("appengine.use.EE10");
289+
boolean useEE11 = Boolean.getBoolean("appengine.use.EE11");
290+
291+
if (useJetty121) { // Jetty121 case, supports EE8, EE10, EE11
292+
if (useEE8) {
293+
currentSdk = new Jetty121EE8Sdk();
294+
} else if (useEE10) {
295+
currentSdk = new Jetty121EE10Sdk();
296+
} else if (useEE11) {
297+
currentSdk = new Jetty121EE11Sdk();
298+
} else {
299+
currentSdk = new Jetty121EE11Sdk(); //EE11 is the default for Jetty121
300+
}
301+
} else { // Jetty12 case, supports EE8, EE10 or classic which is Jetty 9.4
302+
if (useEE8 || useEE10) {
303+
currentSdk = new Jetty12Sdk();
304+
} else if (useEE11) {
305+
throw new IllegalArgumentException("appengine.use.EE11 is not supported in Jetty12");
306+
} else {
307+
currentSdk = new ClassicSdk();
308+
}
288309
}
310+
return currentSdk;
311+
}
289312

290313
/**
291314
* Modifies the SDK implementation (Classic or Maven-based). This method is invoked via reflection
Lines changed: 259 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,259 @@
1+
/*
2+
* Copyright 2021 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.appengine.tools.info;
18+
19+
import com.google.common.base.Joiner;
20+
21+
import java.io.File;
22+
import java.io.FileFilter;
23+
import java.net.URL;
24+
import java.util.ArrayList;
25+
import java.util.Arrays;
26+
import java.util.Collections;
27+
import java.util.List;
28+
29+
/**
30+
* Implementation of the SDK abstraction by the existing GAE SDK distribution, which is composed of
31+
* multiple jar directories for both local execution and deployment of applications.
32+
*/
33+
class Jetty121EE10Sdk extends Jetty121EE8Sdk {
34+
35+
private static final String WEB_DEFAULT_LOCATION_DEVAPPSERVERJETTY12EE10 =
36+
"com/google/appengine/tools/development/jetty/ee10/webdefault.xml";
37+
38+
@Override
39+
public List<File> getUserJspLibFiles() {
40+
return Collections.unmodifiableList(getJetty121JspJars());
41+
}
42+
43+
@Override
44+
public String getWebDefaultLocation() {
45+
return WEB_DEFAULT_LOCATION_DEVAPPSERVERJETTY12EE10;
46+
}
47+
48+
@Override
49+
public String getJettyContainerService() {
50+
return "com.google.appengine.tools.development.jetty.ee10.JettyContainerService";
51+
}
52+
53+
@Override
54+
public String getBackendServersClassName() {
55+
return "com.google.appengine.tools.development.ee10.BackendServersEE10";
56+
}
57+
58+
@Override
59+
public String getModulesClassName() {
60+
return "com.google.appengine.tools.development.ee10.ModulesEE10";
61+
}
62+
63+
@Override
64+
public String getDelegatingModulesFilterHelperClassName() {
65+
return "com.google.appengine.tools.development.ee10.DelegatingModulesFilterHelperEE10";
66+
}
67+
68+
@Override
69+
public String getWebDefaultXml() {
70+
return getSdkRoot() + "/docs/jetty12EE10/webdefault.xml";
71+
}
72+
73+
@Override
74+
public List<File> getSharedJspLibFiles() {
75+
return Collections.unmodifiableList(getJetty121JspJars());
76+
}
77+
78+
@Override
79+
public List<URL> getImplLibs() {
80+
return Collections.unmodifiableList(toURLs(getImplLibFiles()));
81+
}
82+
83+
@Override
84+
public String getQuickStartClasspath() {
85+
List<String> list = new ArrayList<>();
86+
File quickstart =
87+
new File(getSdkRoot(), "lib/tools/quickstart/quickstartgenerator-jetty121-ee10.jar");
88+
89+
File jettyDir = new File(getSdkRoot(), JETTY121_HOME_LIB_PATH);
90+
for (File f : jettyDir.listFiles()) {
91+
if (!f.isDirectory()
92+
&& !(f.getName().contains("cdi-")
93+
|| f.getName().contains("ee9")
94+
|| f.getName().contains("ee11")
95+
|| f.getName().contains("-demo-")
96+
|| f.getName().contains("websocket")
97+
|| f.getName().contains("ee8"))) {
98+
list.add(f.getAbsolutePath());
99+
}
100+
}
101+
// Add the API jar, in case it is needed (b/120480580).
102+
list.add(getSdkRoot() + "/lib/impl/appengine-api.jar");
103+
104+
// Note: Do not put the Apache JSP files in the classpath. If needed, they should be part of
105+
// the application itself under WEB-INF/lib.
106+
for (String subdir : new String[] {"ee10-annotations"}) {
107+
for (File f : new File(jettyDir, subdir).listFiles()) {
108+
list.add(f.getAbsolutePath());
109+
}
110+
}
111+
for (String subdir : new String[] {"ee10-jaspi"}) {
112+
for (File f : new File(jettyDir, subdir).listFiles()) {
113+
list.add(f.getAbsolutePath());
114+
}
115+
}
116+
117+
list.add(quickstart.getAbsolutePath());
118+
// Add Jars for logging.
119+
for (File f : new File(jettyDir, "logging").listFiles()) {
120+
list.add(f.getAbsolutePath());
121+
}
122+
123+
return Joiner.on(System.getProperty("path.separator")).join(list);
124+
}
125+
126+
@Override
127+
public File getResourcesDirectory() {
128+
return new File(getSdkRoot(), "docs");
129+
}
130+
131+
private List<File> getImplLibFiles() {
132+
List<File> lf = getJetty121Jars("");
133+
lf.addAll(getJetty121JspJars());
134+
lf.addAll(getJetty121Jars("logging"));
135+
// We also want the devserver to be able to handle annotated servlet, via ASM:
136+
lf.addAll(getJetty121Jars("ee10-annotations"));
137+
lf.addAll(getJetty121Jars("ee10-apache-jsp"));
138+
lf.addAll(getJetty121Jars("ee10-glassfish-jstl"));
139+
140+
lf.addAll(getLibs(sdkRoot, "impl"));
141+
lf.addAll(getLibs(sdkRoot, "impl/jetty121"));
142+
return Collections.unmodifiableList(lf);
143+
}
144+
145+
/**
146+
* Returns the full paths of all JSP libraries that need to be treated as shared libraries in the
147+
* SDK.
148+
*/
149+
public List<URL> getSharedJspLibs() {
150+
return Collections.unmodifiableList(toURLs(getSharedJspLibFiles()));
151+
}
152+
153+
protected File getJetty121Jar(String fileNamePattern) {
154+
File path = new File(sdkRoot, JETTY121_HOME_LIB_PATH + File.separator);
155+
156+
if (!path.exists()) {
157+
throw new IllegalArgumentException("Unable to find " + path.getAbsolutePath());
158+
}
159+
for (File f : listFiles(path)) {
160+
if (f.getName().endsWith(".jar")) {
161+
// All but CDI jar. All the tests are still passing without CDI that should not be exposed
162+
// in our runtime (private Jetty dependency we do not want to expose to the customer).
163+
if (f.getName().contains(fileNamePattern)) {
164+
return f;
165+
}
166+
}
167+
}
168+
throw new IllegalArgumentException(
169+
"Unable to find " + fileNamePattern + " at " + path.getAbsolutePath());
170+
}
171+
172+
protected List<File> getJetty121Jars(String subDir) {
173+
File path = new File(sdkRoot, JETTY121_HOME_LIB_PATH + File.separator + subDir);
174+
175+
if (!path.exists()) {
176+
throw new IllegalArgumentException("Unable to find " + path.getAbsolutePath());
177+
}
178+
List<File> jars = new ArrayList<>();
179+
for (File f : listFiles(path)) {
180+
if (f.getName().endsWith(".jar")) {
181+
// All but CDI jar. All the tests are still passing without CDI that should not be exposed
182+
// in our runtime (private Jetty dependency we do not want to expose to the customer).
183+
if (!(f.getName().contains("-cdi-")
184+
|| f.getName().contains("jetty-servlet-api-") // no javax. if needed should be in shared
185+
|| f.getName().contains("ee9") // we want ee10 only. jakarta apis should be in shared
186+
|| f.getName().contains("jetty-jakarta-servlet-api") // old
187+
)) {
188+
jars.add(f);
189+
}
190+
}
191+
}
192+
return jars;
193+
}
194+
195+
List<File> getJetty121JspJars() {
196+
197+
List<File> lf = getJetty121Jars("ee10-apache-jsp");
198+
lf.addAll(getJetty121Jars("ee10-glassfish-jstl"));
199+
lf.add(getJetty121Jar("ee10-servlet-"));
200+
return lf;
201+
}
202+
203+
List<File> getJetty121SharedLibFiles() {
204+
List<File> sharedLibs;
205+
sharedLibs = new ArrayList<>();
206+
sharedLibs.add(new File(sdkRoot, "lib/shared/jetty12/appengine-local-runtime-shared.jar"));// keep 12 not 121
207+
File jettyHomeLib = new File(sdkRoot, JETTY121_HOME_LIB_PATH);
208+
209+
sharedLibs.add(new File(jettyHomeLib, "jetty-servlet-api-4.0.6.jar")); // this is javax.servlet
210+
sharedLibs.add(new File(jettyHomeLib, "jakarta.servlet-api-6.0.0.jar")); // contains schemas.
211+
/////////
212+
213+
// We want to match this file: "jetty-util-9.3.8.v20160314.jar"
214+
// but without hardcoding the Jetty version which is changing from time to time.
215+
class JettyVersionFilter implements FileFilter {
216+
@Override
217+
public boolean accept(File file) {
218+
return file.getName().startsWith("jetty-util-");
219+
}
220+
}
221+
File[] files = jettyHomeLib.listFiles(new JettyVersionFilter());
222+
sharedLibs.addAll(Arrays.asList(files));
223+
sharedLibs.addAll(getJetty121JspJars());
224+
return sharedLibs;
225+
}
226+
227+
@Override
228+
public List<URL> getSharedLibs() {
229+
return Collections.unmodifiableList(toURLs(getSharedLibFiles()));
230+
}
231+
232+
@Override
233+
public List<URL> getUserJspLibs() {
234+
return Collections.unmodifiableList(toURLs(getJetty121JspJars()));
235+
}
236+
237+
/** Returns the paths of all shared libraries for the SDK. */
238+
@Override
239+
public List<File> getSharedLibFiles() {
240+
List<File> sharedLibs = getJetty121SharedLibFiles();
241+
242+
if (isDevAppServerTest) {
243+
// If we're running the dev appserver as part of a test, add the testing
244+
// jar to the shared classpath. This will allow things like
245+
// ApiProxyLocalImpl to be on the application classpath (necessary
246+
// because the application classpath includes the test, and the test
247+
// uses LocalServiceTestHelper, which interacts directly with
248+
// ApiProxyLocalImpl) but to make privileged calls like accessing the
249+
// service loader.
250+
sharedLibs.addAll(getLibsRecursive(sdkRoot, "testing"));
251+
}
252+
return Collections.unmodifiableList(sharedLibs);
253+
}
254+
255+
@Override
256+
public String getJSPCompilerClassName() {
257+
return "com.google.appengine.tools.development.jetty.ee10.LocalJspC";
258+
}
259+
}

0 commit comments

Comments
 (0)