本文整理汇总了Java中org.jvnet.hk2.guice.bridge.api.GuiceIntoHK2Bridge类的典型用法代码示例。如果您正苦于以下问题:Java GuiceIntoHK2Bridge类的具体用法?Java GuiceIntoHK2Bridge怎么用?Java GuiceIntoHK2Bridge使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GuiceIntoHK2Bridge类属于org.jvnet.hk2.guice.bridge.api包,在下文中一共展示了GuiceIntoHK2Bridge类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: JerseyApplication
import org.jvnet.hk2.guice.bridge.api.GuiceIntoHK2Bridge; //导入依赖的package包/类
@Inject
public JerseyApplication(ServiceLocator serviceLocator) {
GuiceBridge.getGuiceBridge().initializeGuiceBridge(serviceLocator);
GuiceIntoHK2Bridge guiceBridge = serviceLocator.getService(GuiceIntoHK2Bridge.class);
guiceBridge.bridgeGuiceInjector(AppLoader.injector);
String disableMoxy = PropertiesHelper.getPropertyNameForRuntime(
CommonProperties.MOXY_JSON_FEATURE_DISABLE,
getConfiguration().getRuntimeType());
property(disableMoxy, true);
property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true);
// add the default Jackson exception mappers
register(JsonParseExceptionMapper.class);
register(JsonMappingExceptionMapper.class);
register(JacksonJsonProvider.class, MessageBodyReader.class, MessageBodyWriter.class);
packages(JerseyApplication.class.getPackage().getName());
for (JerseyConfigurator configurator: AppLoader.getExtensions(JerseyConfigurator.class)) {
configurator.configure(this);
}
}
示例2: configure
import org.jvnet.hk2.guice.bridge.api.GuiceIntoHK2Bridge; //导入依赖的package包/类
@Override
public boolean configure(FeatureContext context) {
InjectionManager injectionManager = InjectionManagerProvider.getInjectionManager(context);
ServiceLocator locator;
if (injectionManager instanceof ImmediateHk2InjectionManager) {
locator = ((ImmediateHk2InjectionManager) injectionManager).getServiceLocator();
} else if (injectionManager instanceof DelayedHk2InjectionManager) {
locator = ((DelayedHk2InjectionManager) injectionManager).getServiceLocator();
} else {
throw new IllegalStateException("expected an hk2 injection manager");
}
GuiceBridge.getGuiceBridge().initializeGuiceBridge(locator);
// register all your modules, here
Injector injector = Guice.createInjector(new GreetingModule());
GuiceIntoHK2Bridge guiceBridge = locator.getService(GuiceIntoHK2Bridge.class);
guiceBridge.bridgeGuiceInjector(injector);
return true;
}
示例3: Application
import org.jvnet.hk2.guice.bridge.api.GuiceIntoHK2Bridge; //导入依赖的package包/类
@Inject
public Application(ServiceLocator serviceLocator) {
//Since Jersey doesn't support Guice, setup a bridge so that Guice will work
GuiceBridge.getGuiceBridge().initializeGuiceBridge(serviceLocator);
GuiceIntoHK2Bridge guiceBridge = serviceLocator.getService(GuiceIntoHK2Bridge.class);
guiceBridge.bridgeGuiceInjector(Main.injector);
//Gets Jackson all squared away with Jersey
register(Jackson1Feature.class);
register(DefaultObjectMapperProvider.class);
//Register apis and other Jersey things here
register(TestApi.class);
register(TestExceptionMapper.class);
}
示例4: MyApplication
import org.jvnet.hk2.guice.bridge.api.GuiceIntoHK2Bridge; //导入依赖的package包/类
@Inject
public MyApplication(ServiceLocator serviceLocator) {
packages(Resource.class.getPackage().getName()); // todo: try class
// todo: test!
Injector injector = Guice.createInjector(new AbstractModule() {
@Override
protected void configure() {
bind(Service.class);
}
});
// todo: auth intercept (will not work with Guice - make dual mapping or use jersey interceptors or try jersey2-guice)
GuiceBridge.getGuiceBridge().initializeGuiceBridge(serviceLocator);
GuiceIntoHK2Bridge guiceBridge = serviceLocator.getService(GuiceIntoHK2Bridge.class);
guiceBridge.bridgeGuiceInjector(injector);
}
示例5: DashAppConfig
import org.jvnet.hk2.guice.bridge.api.GuiceIntoHK2Bridge; //导入依赖的package包/类
@Inject
public DashAppConfig(ServiceLocator serviceLocator) {
logger.info("Registering packages on {}", DashContants.DASH_REST_PACKAGE);
// Register package for rest endpoints and fasterxml for JSON support
packages(DashContants.DASH_REST_PACKAGE, DashContants.FASTERXML_PACKAGE);
logger.info("Building Injectors");
Injector injector = Guice.createInjector(
new ConfigurationInjection(),
new DashGuiceH4ServletModule(),
new DashH4ServiceInjection(),
//new DashGuiceH4Module(),
new JSONInjection()
);
// PersistentInit persistenceInit = new PersistentInit();
PersistenceInit persistenceInit = new PersistenceInit();
GuiceBridge.getGuiceBridge().initializeGuiceBridge(serviceLocator);
GuiceIntoHK2Bridge guiceBridge = serviceLocator.getService(GuiceIntoHK2Bridge.class);
guiceBridge.bridgeGuiceInjector(injector);
}
示例6: ApiConfig
import org.jvnet.hk2.guice.bridge.api.GuiceIntoHK2Bridge; //导入依赖的package包/类
@Inject
public ApiConfig(ServiceLocator serviceLocator) {
register(JacksonFeature.class);
register(ValidationFeature.class);
property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, "true");
register(AuthenticationRequestFilter.class);
register(AdminNecessaryRequestFilter.class);
register(RepositoryControllRequestFilter.class);
register(HttpCacheControlFilter.class);
register(ApiForbiddenExceptionMapper.class);
register(ApiNotFoundExceptionMapper.class);
register(ApiLoginRequiredExceptionMapper.class);
register(AjaxValidationErrorExceptionMapper.class);
register(PostErrorResponseFilter.class);
GuiceBridge.getGuiceBridge().initializeGuiceBridge(serviceLocator);
GuiceIntoHK2Bridge guiceBridge = serviceLocator.getService(GuiceIntoHK2Bridge.class);
guiceBridge.bridgeGuiceInjector(GuiceListener.get());
packages(false, this.getClass().getPackage() + ".rs");
}
示例7: AppConfig
import org.jvnet.hk2.guice.bridge.api.GuiceIntoHK2Bridge; //导入依赖的package包/类
@Inject
public AppConfig(ServiceLocator serviceLocator) {
register(FreemarkerMvcFeature.class);
property(FreemarkerMvcFeature.TEMPLATES_BASE_PATH, "/WEB-INF/templates");
property(FreemarkerMvcFeature.TEMPLATE_OBJECT_FACTORY, FlexibleConfiguration.class);
register(AttachContextInterceptor.class);
register(ValidationFeature.class);
property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, "true");
register(AuthenticationRequestFilter.class);
register(AdminNecessaryRequestFilter.class);
register(RepositoryControllRequestFilter.class);
register(HtmlLoginRequiredExceptionMapper.class);
register(HttpCacheControlFilter.class);
GuiceBridge.getGuiceBridge().initializeGuiceBridge(serviceLocator);
GuiceIntoHK2Bridge guiceBridge = serviceLocator.getService(GuiceIntoHK2Bridge.class);
guiceBridge.bridgeGuiceInjector(GuiceListener.get());
packages(false, this.getClass().getPackage() + ".html");
}
示例8: WebApp
import org.jvnet.hk2.guice.bridge.api.GuiceIntoHK2Bridge; //导入依赖的package包/类
@Inject
public WebApp(Injector injector, ServiceLocator serviceLocator) {
log.info("Setting up Web Application");
register(SseFeature.class);
register(MultiPartFeature.class);
register(ExposrExceptionMapper.class);
// Resources.
register(BuildResource.class);
register(ExposrResource.class);
register(ProjectResource.class);
register(SyncResource.class);
register(TaskResource.class);
GuiceBridge.getGuiceBridge().initializeGuiceBridge(serviceLocator);
final GuiceIntoHK2Bridge bridge = serviceLocator
.getService(GuiceIntoHK2Bridge.class);
bridge.bridgeGuiceInjector(injector);
}
示例9: onStartup
import org.jvnet.hk2.guice.bridge.api.GuiceIntoHK2Bridge; //导入依赖的package包/类
@Override
public void onStartup(Container container) {
logger.trace("Setting up Guice bridge {}", container);
ServiceLocator locator = container.getApplicationHandler()
.getServiceLocator();
GuiceBridge.getGuiceBridge().initializeGuiceBridge(locator);
GuiceIntoHK2Bridge guiceBridge = locator
.getService(GuiceIntoHK2Bridge.class);
guiceBridge.bridgeGuiceInjector(injector);
logger.trace("Finished setting up Guice bridge {}", container);
logger.trace("Starting up catalogue synchroniser");
backgroundSync = injector.getInstance(BackgroundSync.class);
backgroundSync.start();
logger.trace("Started up catalogue synchroniser");
}
示例10: Hk2GuiceBridgeFeature
import org.jvnet.hk2.guice.bridge.api.GuiceIntoHK2Bridge; //导入依赖的package包/类
@Inject
public Hk2GuiceBridgeFeature(final ServiceLocator serviceLocator) {
GuiceBridge.getGuiceBridge().initializeGuiceBridge(serviceLocator);
final GuiceIntoHK2Bridge g2h = serviceLocator.getService(GuiceIntoHK2Bridge.class);
final Injector injector = Guice.createInjector(new AppModule());
g2h.bridgeGuiceInjector(injector);
}
示例11: createBiDirectionalGuiceBridge
import org.jvnet.hk2.guice.bridge.api.GuiceIntoHK2Bridge; //导入依赖的package包/类
private Injector createBiDirectionalGuiceBridge(ServiceLocator serviceLocator) {
GuiceBridge.getGuiceBridge().initializeGuiceBridge(serviceLocator);
Injector injector = RestApiServerImpl.injector;
GuiceIntoHK2Bridge g2h = serviceLocator.getService(GuiceIntoHK2Bridge.class);
g2h.bridgeGuiceInjector(injector);
return injector;
}
示例12: setupGuiceBridge
import org.jvnet.hk2.guice.bridge.api.GuiceIntoHK2Bridge; //导入依赖的package包/类
/**
* Adds the binding between guice and hk2. This binding is one directional.
* You can add guice services into hk2 (jersey) resources. You cannot add
* a hk2 service into guice.
* <p>
* <a href="https://hk2.java.net/guice-bridge/">about the bridge</a>
* </p>
*
* @param resourceConfig the jersey resource configuration
*/
protected void setupGuiceBridge(ResourceConfig resourceConfig) {
LogManager.getLogger().info("Initialize hk2 - guice bridge...");
resourceConfig.register(new AbstractContainerLifecycleListener() {
@Override
public void onStartup(Container container) {
ServiceLocator serviceLocator = container.getApplicationHandler().getServiceLocator();
Injector injector = MCRInjectorConfig.injector();
GuiceBridge.getGuiceBridge().initializeGuiceBridge(serviceLocator);
GuiceIntoHK2Bridge guiceBridge = serviceLocator.getService(GuiceIntoHK2Bridge.class);
guiceBridge.bridgeGuiceInjector(injector);
}
});
}
示例13: configure
import org.jvnet.hk2.guice.bridge.api.GuiceIntoHK2Bridge; //导入依赖的package包/类
@Override
public boolean configure(FeatureContext context) {
ServiceLocator serviceLocator = ServiceLocatorProvider.getServiceLocator(context);
GuiceBridge.getGuiceBridge().initializeGuiceBridge(serviceLocator);
GuiceIntoHK2Bridge guiceBridge = serviceLocator.getService(GuiceIntoHK2Bridge.class);
guiceBridge.bridgeGuiceInjector(injector);
return true;
}
示例14: configure
import org.jvnet.hk2.guice.bridge.api.GuiceIntoHK2Bridge; //导入依赖的package包/类
@Override
public boolean configure(FeatureContext fc) {
GuiceBridge.getGuiceBridge().initializeGuiceBridge(hk2);
Injector guice = (Injector) fc.getConfiguration().getProperty(KEY_INJECTOR);
hk2.getService(GuiceIntoHK2Bridge.class).bridgeGuiceInjector(guice);
return true;
}
示例15: WidowAnalyzeResourceConfig
import org.jvnet.hk2.guice.bridge.api.GuiceIntoHK2Bridge; //导入依赖的package包/类
@Inject
public WidowAnalyzeResourceConfig(ServiceLocator serviceLocator) {
// Set package to look for resources in
packages("com.widowcrawler.analyze");
GuiceBridge.getGuiceBridge().initializeGuiceBridge(serviceLocator);
GuiceIntoHK2Bridge guiceBridge = serviceLocator.getService(GuiceIntoHK2Bridge.class);
guiceBridge.bridgeGuiceInjector(WidowAnalyzeServletContextListener.getCachedInjector());
}