本文整理汇总了Java中com.squarespace.jersey2.guice.JerseyGuiceUtils类的典型用法代码示例。如果您正苦于以下问题:Java JerseyGuiceUtils类的具体用法?Java JerseyGuiceUtils怎么用?Java JerseyGuiceUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JerseyGuiceUtils类属于com.squarespace.jersey2.guice包,在下文中一共展示了JerseyGuiceUtils类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: configureGuice
import com.squarespace.jersey2.guice.JerseyGuiceUtils; //导入依赖的package包/类
private Injector configureGuice(T configuration, Environment environment) throws Exception {
// setup our core modules...
appModules.add(new MetricRegistryModule(environment.metrics()));
appModules.add(new ServletModule());
// ...and add the app's modules
appModules.addAll(addModules(configuration, environment));
final Injector injector = Guice.createInjector(ImmutableList.copyOf(this.appModules));
// Taken from https://github.com/Squarespace/jersey2-guice/wiki#complex-example. HK2 is no fun.
JerseyGuiceUtils.install((name, parent) -> {
if (!name.startsWith("__HK2_Generated_")) {
return null;
}
return injector.createChildInjector(Lists.newArrayList(new JerseyGuiceModule(name)))
.getInstance(ServiceLocator.class);
});
injector.injectMembers(this);
registerWithInjector(environment, injector);
return injector;
}
开发者ID:dehora,项目名称:outland,代码行数:24,代码来源:GuiceApplication.java
示例2: before
import com.squarespace.jersey2.guice.JerseyGuiceUtils; //导入依赖的package包/类
@Override
protected void before() {
metadataTrustStore.create();
countryMetadataTrustStore.create();
clientTrustStore.create();
JerseyGuiceUtils.reset();
try {
InitializationService.initialize();
verifyMetadataServer.reset();
verifyMetadataServer.register(VERIFY_METADATA_PATH, 200, Constants.APPLICATION_SAMLMETADATA_XML, new MetadataFactory().defaultMetadata());
countryMetadataServer.reset();
countryMetadataServer.register(COUNTRY_METADATA_PATH, 200, Constants.APPLICATION_SAMLMETADATA_XML, new MetadataFactory().defaultMetadata());
} catch (Exception e) {
throw new RuntimeException(e);
}
super.before();
}
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:22,代码来源:MatchingServiceAdapterAppRule.java
示例3: getInjector
import com.squarespace.jersey2.guice.JerseyGuiceUtils; //导入依赖的package包/类
@Override
protected Injector getInjector() {
Injector injector = Guice.createInjector(
Stage.PRODUCTION,
new JerseyGuiceModule("__HK2_Generated_0"),
new ServletModule(),
new AppModule()
);
JerseyGuiceUtils.install(injector);
return injector;
}
开发者ID:thingleme,项目名称:java8-jersey2-guice4-webapp,代码行数:14,代码来源:AppServletContextListener.java
示例4: main
import com.squarespace.jersey2.guice.JerseyGuiceUtils; //导入依赖的package包/类
public static void main(String[] args) {
// running this method here stops the odd exceptions/double-initialisation that happens without it
// - it's the same fix that was required in the tests...
JerseyGuiceUtils.reset();
new MatchingServiceAdapterApplication().runRuntimeException(args);
}
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:8,代码来源:MatchingServiceAdapterApplication.java
示例5: setUp
import com.squarespace.jersey2.guice.JerseyGuiceUtils; //导入依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
LOGGER.warn("Starting embedded mongo on port: " + PORT);
_mongodExe = starter.prepare(new MongodConfigBuilder()
.version(Version.Main.PRODUCTION)
.net(new Net(PORT, Network.localhostIsIPv6()))
.build());
_mongod = _mongodExe.start();
// This is needed, for now at least. Remove this when not needed. Without, we currently get:
// java.lang.RuntimeException: java.lang.ClassNotFoundException: Provider org.glassfish.jersey.internal.RuntimeDelegateImpl could not be instantiated: java.lang.IllegalStateException: It appears there is no ServiceLocatorGenerator installed.
// See: https://github.com/dropwizard/dropwizard/issues/1772
JerseyGuiceUtils.install((s, serviceLocator) -> null);
}
开发者ID:researchgate,项目名称:restler,代码行数:15,代码来源:AbstractMongoDBTest.java
示例6: setUp
import com.squarespace.jersey2.guice.JerseyGuiceUtils; //导入依赖的package包/类
@BeforeClass
public void setUp() throws IOException {
JerseyGuiceUtils.install(new ServiceLocatorGenerator() {
@Override
public ServiceLocator create(String name, ServiceLocator parent) {
if (!name.startsWith("__HK2_")) {
return null;
}
List<Module> modules = new ArrayList<>();
modules.add(new JerseyGuiceModule(name));
modules.add(new ServletModule());
modules.add(new AbstractModule() {
@Override
protected void configure() {
bind(HelloResource.class);
bind(HelloService.class).toInstance(new HelloServiceImpl(DEFAULT_HELLO));
bind(HelloService.class).annotatedWith(Names.named("simple")).toInstance(new HelloServiceImpl(NAMED_HELLO));
bind(HelloService.class).annotatedWith(Other.class).toInstance(new HelloServiceImpl(ANNOTATED_HELLO));
}
});
return Guice.createInjector(modules)
.getInstance(ServiceLocator.class);
}
});
SERVER = HttpServerUtils.newHttpServer(HelloResource.class);
}
开发者ID:Squarespace,项目名称:jersey2-guice,代码行数:34,代码来源:ResourceWithNamedInjectionTest.java
示例7: curatorSetup
import com.squarespace.jersey2.guice.JerseyGuiceUtils; //导入依赖的package包/类
@Before
public final void curatorSetup() throws Exception {
JerseyGuiceUtils.reset();
singularityTestModule = new SingularityTestModule(useDBTests);
singularityTestModule.getInjector().injectMembers(this);
singularityTestModule.start();
}
开发者ID:HubSpot,项目名称:Singularity,代码行数:9,代码来源:SingularityCuratorTestBase.java
示例8: tearDown
import com.squarespace.jersey2.guice.JerseyGuiceUtils; //导入依赖的package包/类
@AfterClass
public void tearDown() throws IOException {
SERVER.close();
JerseyGuiceUtils.reset();
}
开发者ID:Squarespace,项目名称:jersey2-guice,代码行数:6,代码来源:ResourceWithNamedInjectionTest.java
示例9: reset
import com.squarespace.jersey2.guice.JerseyGuiceUtils; //导入依赖的package包/类
@AfterTest
public void reset() {
JerseyGuiceUtils.reset();
}
开发者ID:Squarespace,项目名称:jersey2-guice,代码行数:5,代码来源:AopTest.java
示例10: checkAOP
import com.squarespace.jersey2.guice.JerseyGuiceUtils; //导入依赖的package包/类
@Test
public void checkAOP() throws IOException {
final MyInterceptor interceptor = new MyInterceptor();
final AbstractModule aopModule = new AbstractModule() {
@Override
protected void configure() {
// ATTENTION: This is really important. It binds the
// 'MyResource' class to Guice and makes sure that HK2's
// ServiceLocator will use Guice to instantiate it.
bind(MyResource.class);
bindInterceptor(Matchers.any(),
Matchers.annotatedWith(MyAnnotation.class),
interceptor);
}
};
JerseyGuiceUtils.install(new ServiceLocatorGenerator() {
@Override
public ServiceLocator create(String name, ServiceLocator parent) {
if (!name.startsWith("__HK2_")) {
return null;
}
List<Module> modules = new ArrayList<>();
modules.add(new JerseyGuiceModule(name));
modules.add(new ServletModule());
modules.add(aopModule);
return Guice.createInjector(modules)
.getInstance(ServiceLocator.class);
}
});
try (HttpServer server = HttpServerUtils.newHttpServer(MyResource.class)) {
check();
}
assertEquals(interceptor.counter.get(), 1);
}
开发者ID:Squarespace,项目名称:jersey2-guice,代码行数:45,代码来源:AopTest.java
注:本文中的com.squarespace.jersey2.guice.JerseyGuiceUtils类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论