Google App Engine 等同于 Android 的 'Application' class?用于依赖注入

What is the Google App Engine equivalent of Android's 'Application' class? for dependency injection

Android 让我们扩展 Application,这是存储单例的好地方,因此它们可以在应用程序的不同页面(活动)中轻松重复使用。

什么是 Google App-Engine 的等价物?

我正在使用 Dagger,我不想为每个端点创建一个新的对象图。

一个选项(尽管我不确定它是最好的)就是自我注入您的 Cloud Endpoints class(通过静态字段注入)。

大概您正在 ServletContextListener 中初始化对象图,这样您就可以在端点方法被调用之前在那里这样做。

Dagger 1.x 支持模块注释上的 staticInjections(为您做到这一点),但这显然在 2.x.

中不再受支持