org.glassfish.jersey.inject.hk2.ImmediateHk2InjectionManager Java Examples
The following examples show how to use
org.glassfish.jersey.inject.hk2.ImmediateHk2InjectionManager.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GuiceFeature.java From jrestless-examples with Apache License 2.0 | 6 votes |
@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; }
Example #2
Source File: DefaultContainerLifecycleListener.java From jweb-cms with GNU Affero General Public License v3.0 | 5 votes |
@Override public void onStartup(Container container) { InjectionManager injectionManager = container.getApplicationHandler().getInjectionManager(); if (injectionManager instanceof ImmediateHk2InjectionManager) { app.serviceLocator = ((ImmediateHk2InjectionManager) injectionManager).getServiceLocator(); } else if (injectionManager instanceof DelayedHk2InjectionManager) { app.serviceLocator = ((DelayedHk2InjectionManager) injectionManager).getServiceLocator(); } else { throw new ApplicationException("unknown injection manager"); } app.onStartup(); }
Example #3
Source File: GuiceComponentProvider.java From seed with Mozilla Public License 2.0 | 5 votes |
public void initialize(InjectionManager injectionManager) { if (injectionManager instanceof ImmediateHk2InjectionManager) { initialize(((ImmediateHk2InjectionManager) injectionManager).getServiceLocator()); } else if (injectionManager instanceof DelayedHk2InjectionManager) { initialize(((DelayedHk2InjectionManager) injectionManager).getServiceLocator()); } else { throw SeedException.createNew(Jersey2ErrorCode.UNSUPPORTED_JERSEY_DEPENDENCY_INJECTION); } }