Skip to content

Commit

Permalink
WIP Lite on EE10
Browse files Browse the repository at this point in the history
  • Loading branch information
ludoch committed May 14, 2024
1 parent 35b26ab commit d8069e2
Show file tree
Hide file tree
Showing 10 changed files with 2,357 additions and 2 deletions.
1 change: 0 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,6 @@
<groupId>com.google.flogger</groupId>
<artifactId>flogger-system-backend</artifactId>
<version>0.8</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.flogger</groupId>
Expand Down
11 changes: 10 additions & 1 deletion runtime/runtime_impl_jetty12/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@
<dependency>
<groupId>com.google.flogger</groupId>
<artifactId>flogger-system-backend</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.flogger</groupId>
Expand Down Expand Up @@ -157,6 +156,11 @@
<version>${jetty12.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-session</artifactId>
<version>${jetty12.version}</version>
</dependency>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
Expand Down Expand Up @@ -376,6 +380,11 @@
<artifactId>jetty-ee10-annotations</artifactId>
<version>${jetty12.version}</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-logging</artifactId>
</dependency>

</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.google.apphosting.runtime.jetty.lite.ee10;

import com.google.apphosting.api.ApiProxy;
import java.util.concurrent.Callable;

/** A utility to install the thread-local App Engine API proxy context. */
public final class ApiProxyEnvironmentManager {

private final ApiProxy.Environment environment;

public static ApiProxyEnvironmentManager ofCurrentEnvironment() {
return new ApiProxyEnvironmentManager(ApiProxy.getCurrentEnvironment());
}

private ApiProxyEnvironmentManager(ApiProxy.Environment environment) {
this.environment = environment;
}

public void installEnvironmentAndCall(Callable<Void> callable) throws Exception {
try (Installer installer = new Installer()) {
callable.call();
}
}

class Installer implements AutoCloseable {
private final ApiProxy.Environment previousEnvironment;

Installer() {
this.previousEnvironment = ApiProxy.getCurrentEnvironment();
ApiProxy.setEnvironmentForCurrentThread(environment);
}

@Override
public void close() {
ApiProxy.setEnvironmentForCurrentThread(previousEnvironment);
}
}
}

0 comments on commit d8069e2

Please sign in to comment.