@Inject public GuiceJerseyServer(JerseyHandler jerseyHandler, VertxContainer container, Provider<JerseyServerOptions> optionsProvider, ServiceLocator locator, Injector injector) { super(jerseyHandler, container, optionsProvider); initBridge(locator, injector); }
/** * This is a workaround for the hk2 bridge limitations * * @param locator the HK2 locator * @param injector the Guice injector */ protected void injectMultibindings(ServiceLocator locator, Injector injector) { injectMultiBindings(locator, injector, new Key<Set<ContainerRequestFilter>>() { }, ContainerRequestFilter.class); injectMultiBindings(locator, injector, new Key<Set<ContainerResponseFilter>>() { }, ContainerResponseFilter.class); injectMultiBindings(locator, injector, new Key<Set<ReaderInterceptor>>() { }, ReaderInterceptor.class); injectMultiBindings(locator, injector, new Key<Set<WriterInterceptor>>() { }, WriterInterceptor.class); injectMultiBindings(locator, injector, new Key<Set<ModelProcessor>>() { }, ModelProcessor.class); }
/** * Initialize the hk2 bridge * * @param locator the HK2 locator * @param injector the Guice injector */ protected void initBridge(ServiceLocator locator, Injector injector) { GuiceBridge.getGuiceBridge().initializeGuiceBridge(locator); GuiceIntoHK2Bridge guiceBridge = locator.getService(GuiceIntoHK2Bridge.class); guiceBridge.bridgeGuiceInjector(injector); injectMultibindings(locator, injector); }
@Before @SuppressWarnings("unchecked") public void setUp() throws Exception { when(locator.getService(eq(GuiceIntoHK2Bridge.class))).thenReturn(bridge); when(locator.getService(eq(DynamicConfigurationService.class))).thenReturn(dcs); when(dcs.createDynamicConfiguration()).thenReturn(dc); Key<Set<ContainerRequestFilter>> key = Key.get(new TypeLiteral<Set<ContainerRequestFilter>>() { }); Set<ContainerRequestFilter> set = new LinkedHashSet<>(); set.add(mock(ContainerRequestFilter.class)); when(injector.getInstance(Matchers.any(key.getClass()))).thenReturn(set); server = new GuiceJerseyServer(handler, container, () -> options, locator, injector); }
/** * Initialize the hk2 bridge * * @param locator the HK2 locator * @param injector the Guice injector */ protected void initBridge(ServiceLocator locator, Injector injector) { // Set up bridge GuiceBridge.getGuiceBridge().initializeGuiceBridge(locator); GuiceIntoHK2Bridge guiceBridge = locator.getService(GuiceIntoHK2Bridge.class); guiceBridge.bridgeGuiceInjector(injector); injectMultibindings(locator, injector); // Bind guice scope context ServiceLocatorUtilities.bind(locator, new AbstractBinder() { @Override protected void configure() { bind(GuiceScopeContext.class).to(new TypeLiteral<Context<GuiceScope>>() { }).in(Singleton.class); } }); }
/** * Initialize the hk2 bridge * * @param locator the HK2 locator * @param injector the Guice injector */ protected void initBridge(ServiceLocator locator, Injector injector) { // Set up bridge GuiceBridge.getGuiceBridge().initializeGuiceBridge(locator); GuiceIntoHK2Bridge guiceBridge = locator.getService(GuiceIntoHK2Bridge.class); guiceBridge.bridgeGuiceInjector(injector); injectMultibindings(locator, injector); // Bind guice scope context ServiceLocatorUtilities.bind(locator, new AbstractBinder() { @Override protected void configure() { bind(GuiceScopeContext.class).to(new TypeLiteral<Context<GuiceScope>>() { }).in(Singleton.class); } }); }
@Inject public GuiceJerseyServer(Provider<JerseyHandler> jerseyHandlerProvider, ServiceLocator locator, Injector injector) { super(jerseyHandlerProvider); initBridge(locator, injector); }
/** * This is a workaround for the hk2 bridge limitations * * @param locator the HK2 locator * @param injector the Guice injector */ protected void injectMultibindings(ServiceLocator locator, Injector injector) { injectMultiBindings(locator, injector, new Key<Set<ContainerRequestFilter>>() { }, ContainerRequestFilter.class); injectMultiBindings(locator, injector, new Key<Set<ContainerResponseFilter>>() { }, ContainerResponseFilter.class); injectMultiBindings(locator, injector, new Key<Set<ReaderInterceptor>>() { }, ReaderInterceptor.class); injectMultiBindings(locator, injector, new Key<Set<WriterInterceptor>>() { }, WriterInterceptor.class); injectMultiBindings(locator, injector, new Key<Set<ModelProcessor>>() { }, ModelProcessor.class); injectMultiBindings(locator, injector, new Key<Set<ContainerLifecycleListener>>() { }, ContainerLifecycleListener.class); injectMultiBindings(locator, injector, new Key<Set<ApplicationEventListener>>() { }, ApplicationEventListener.class); injectMultiBindings(locator, injector, new Key<Set<ExceptionMapper>>() { }, ExceptionMapper.class); }
@Inject public GuiceJerseyServer(JerseyHandler jerseyHandler, VertxContainer container, Provider<JerseyServerOptions> optionsProvider, ServiceLocator locator, Injector injector) { super(jerseyHandler, container, optionsProvider); initBridge(locator, injector); }
/** * This is a workaround for the hk2 bridge limitations * * @param locator the HK2 locator * @param injector the Guice injector */ protected void injectMultibindings(ServiceLocator locator, Injector injector) { injectMultiBindings(locator, injector, new Key<Set<ContainerRequestFilter>>() { }, ContainerRequestFilter.class); injectMultiBindings(locator, injector, new Key<Set<ContainerResponseFilter>>() { }, ContainerResponseFilter.class); injectMultiBindings(locator, injector, new Key<Set<ReaderInterceptor>>() { }, ReaderInterceptor.class); injectMultiBindings(locator, injector, new Key<Set<WriterInterceptor>>() { }, WriterInterceptor.class); injectMultiBindings(locator, injector, new Key<Set<ModelProcessor>>() { }, ModelProcessor.class); injectMultiBindings(locator, injector, new Key<Set<ContainerLifecycleListener>>() { }, ContainerLifecycleListener.class); injectMultiBindings(locator, injector, new Key<Set<ApplicationEventListener>>() { }, ApplicationEventListener.class); injectMultiBindings(locator, injector, new Key<Set<ExceptionMapper>>() { }, ExceptionMapper.class); }