是否有可能以这种方式在gae上设计应用程序 - 管理部分 - gwt,guice - 用户部分 - guice,html,js
出于性能原因,它们应该是独立的。据我所知,可以在每个请求上启动应用程序,因此没有理由每次启动并将管理部分加载到内存中。 正如我所读到的那样,无法在2个应用之间共享数据存储。也许guice支持这样的场景?
修改
抱歉,我会再试一次答案 0 :(得分:0)
我认为你在谈论懒惰的豆子创造。默认情况下是这样(除非您使用toInstance绑定):
package com.sopovs.moradanen;
import javax.inject.Singleton;
import com.google.inject.Guice;
import com.google.inject.Injector;
public class Main {
public static void main(String[] args) {
System.out.println("Creating injector");
Injector injector = Guice.createInjector();
System.out.println("Injector created");
System.out.println("Getting instance of Foo");
injector.getInstance(Foo.class);
System.out.println("Got instance of Foo");
System.out.println("Getting instance of Bar");
injector.getInstance(Bar.class);
System.out.println("Got instance of Bar");
System.out.println("Getting another instance of Foo");
injector.getInstance(Foo.class);
System.out.println("Got another instance of Foor");
}
@Singleton
public static class Foo {
public Foo() {
System.out.println("Foo Created");
}
}
@Singleton
public static class Bar {
public Bar() {
System.out.println("Bar Created");
}
}
}
输出是:
Creating injector
Injector created
Getting instance of Foo
Foo Created
Got instance of Foo
Getting instance of Bar
Bar Created
Got instance of Bar
Getting another instance of Foo
Got another instance of Foor