/** * Configures a {@link com.google.inject.Binder} via the exposed methods. */ @Override protected void configure() { install(new GuiceJerseyBinder()); }
/** * Configures a {@link com.google.inject.Binder} via the exposed methods. */ @Override protected void configure() { // Create HK2 service locator and bind jersey injections ServiceLocator locator = ServiceLocatorFactory.getInstance().create(null); bind(ServiceLocator.class).toInstance(locator); bind(JerseyServer.class).to(GuiceJerseyServer.class); bind(JerseyHandler.class).to(DefaultJerseyHandler.class); bind(JerseyConfigurator.class).to(DefaultJerseyConfigurator.class); bind(ContainerResponseWriterProvider.class).to(VertxResponseWriterProvider.class); bind(MessageBodyWriter.class).to(WriteStreamBodyWriter.class).in(Singleton.class); Multibinder.newSetBinder(binder(), VertxRequestProcessor.class); Multibinder.newSetBinder(binder(), VertxResponseProcessor.class); Multibinder.newSetBinder(binder(), VertxPostResponseProcessor.class); Multibinder.newSetBinder(binder(), ContainerRequestFilter.class); Multibinder.newSetBinder(binder(), ContainerResponseFilter.class); Multibinder.newSetBinder(binder(), ReaderInterceptor.class); Multibinder.newSetBinder(binder(), WriterInterceptor.class); Multibinder.newSetBinder(binder(), ModelProcessor.class); }
@Test public void testProviders() throws Exception { List<?> list; list = binder.provideVertxRequestProcessorList(Sets.newHashSet(mock(VertxRequestProcessor.class), mock(VertxRequestProcessor.class))); assertEquals(2, list.size()); list = binder.provideVertxResponseProcessorList(Sets.newHashSet(mock(VertxResponseProcessor.class), mock(VertxResponseProcessor.class))); assertEquals(2, list.size()); list = binder.provideVertxPostResponseProcessorList(Sets.newHashSet(mock(VertxPostResponseProcessor.class), mock(VertxPostResponseProcessor.class))); assertEquals(2, list.size()); }
@Test public void testConfigure() throws Exception { binder.configure(builder); // 9 types are explicitly bound verify(builder, times(9)).bind((Class<?>) any(Class.class)); // 11 multi-bindings are installed verify(builder, times(11)).install(any(Module.class)); }
/** * Configures a {@link com.google.inject.Binder} via the exposed methods. */ @Override protected void configure() { install(new GuiceJerseyBinder()); }
/** * Configures a {@link com.google.inject.Binder} via the exposed methods. */ @Override protected void configure() { // Create HK2 service locator and bind jersey injections ServiceLocator locator = ServiceLocatorFactory.getInstance().create(null); bind(ServiceLocator.class).toInstance(locator); bind(VertxContainer.class).to(DefaultVertxContainer.class); bind(JerseyServer.class).to(GuiceJerseyServer.class); bind(JerseyHandler.class).to(DefaultJerseyHandler.class); bind(JerseyOptions.class).to(DefaultJerseyOptions.class); bind(JerseyServerOptions.class).to(DefaultJerseyOptions.class); bind(ContainerResponseWriterProvider.class).to(VertxResponseWriterProvider.class); bind(MessageBodyWriter.class).to(WriteStreamBodyWriter.class).in(Singleton.class); bind(ApplicationConfigurator.class).toProvider(Providers.of(null)); Multibinder.newSetBinder(binder(), VertxRequestProcessor.class); Multibinder.newSetBinder(binder(), VertxResponseProcessor.class); Multibinder.newSetBinder(binder(), VertxPostResponseProcessor.class); Multibinder.newSetBinder(binder(), ContainerRequestFilter.class); Multibinder.newSetBinder(binder(), ContainerResponseFilter.class); Multibinder.newSetBinder(binder(), ReaderInterceptor.class); Multibinder.newSetBinder(binder(), WriterInterceptor.class); Multibinder.newSetBinder(binder(), ModelProcessor.class); Multibinder.newSetBinder(binder(), ContainerLifecycleListener.class); Multibinder.newSetBinder(binder(), ApplicationEventListener.class); Multibinder.newSetBinder(binder(), ExceptionMapper.class); }
/** * Configures a {@link com.google.inject.Binder} via the exposed methods. */ @Override protected void configure() { install(new GuiceJerseyBinder()); }
/** * Configures a {@link com.google.inject.Binder} via the exposed methods. */ @Override protected void configure() { // Create HK2 service locator and bind jersey injections ServiceLocator locator = ServiceLocatorFactory.getInstance().create(null); bind(ServiceLocator.class).toInstance(locator); bind(VertxContainer.class).to(DefaultVertxContainer.class); bind(JerseyServer.class).to(GuiceJerseyServer.class); bind(JerseyHandler.class).to(DefaultJerseyHandler.class); bind(JerseyOptions.class).to(DefaultJerseyOptions.class); bind(JerseyServerOptions.class).to(DefaultJerseyOptions.class); bind(ContainerResponseWriterProvider.class).to(VertxResponseWriterProvider.class); bind(MessageBodyWriter.class).to(WriteStreamBodyWriter.class).in(Singleton.class); bind(ApplicationConfigurator.class).toProvider(Providers.of(null)); Multibinder.newSetBinder(binder(), VertxRequestProcessor.class); Multibinder.newSetBinder(binder(), VertxResponseProcessor.class); Multibinder.newSetBinder(binder(), VertxPostResponseProcessor.class); Multibinder.newSetBinder(binder(), ContainerRequestFilter.class); Multibinder.newSetBinder(binder(), ContainerResponseFilter.class); Multibinder.newSetBinder(binder(), ReaderInterceptor.class); Multibinder.newSetBinder(binder(), WriterInterceptor.class); Multibinder.newSetBinder(binder(), ModelProcessor.class); Multibinder.newSetBinder(binder(), ContainerLifecycleListener.class); Multibinder.newSetBinder(binder(), ApplicationEventListener.class); Multibinder.newSetBinder(binder(), ExceptionMapper.class); }
/** * Configures a {@link com.google.inject.Binder} via the exposed methods. */ @Override protected void configure() { install(new GuiceJerseyBinder()); bind(WhenJerseyServer.class).to(DefaultWhenJerseyServer.class); } }
/** * Configures a {@link com.google.inject.Binder} via the exposed methods. */ @Override protected void configure() { install(new GuiceJerseyBinder()); bind(WhenJerseyServer.class).to(DefaultWhenJerseyServer.class); } }
/** * Configures a {@link com.google.inject.Binder} via the exposed methods. */ @Override protected void configure() { install(new GuiceJerseyBinder()); bind(WhenJerseyServer.class).to(DefaultWhenJerseyServer.class); } }
/** * Configures a {@link com.google.inject.Binder} via the exposed methods. */ @Override protected void configure() { install(new GuiceJerseyBinder()); // POJOs bind(MyDependency.class).to(DefaultMyDependency.class); // vertx-mod-jersey interfaces Multibinder.newSetBinder(binder(), VertxRequestProcessor.class).addBinding().to(GuiceRequestProcessor.class); Multibinder.newSetBinder(binder(), VertxResponseProcessor.class).addBinding().to(GuiceResponseProcessor.class); Multibinder.newSetBinder(binder(), VertxPostResponseProcessor.class).addBinding().to(GuicePostResponseProcessor.class); // Jersey interfaces Multibinder.newSetBinder(binder(), ContainerRequestFilter.class).addBinding().to(GuiceRequestFilter.class); Multibinder.newSetBinder(binder(), ContainerResponseFilter.class).addBinding().to(GuiceResponseFilter.class); Multibinder.newSetBinder(binder(), ExceptionMapper.class).addBinding().to(GuiceExceptionMapper.class); }
@Before @SuppressWarnings("unchecked") public void setUp() throws Exception { when(builder.skipSources(Matchers.<Class[]>anyVararg())).thenReturn(builder); when(builder.bind((Class<?>) any(Class.class))).thenReturn(annotatedBindingBuilder); when(annotatedBindingBuilder.to(any(Class.class))).thenReturn(mock(ScopedBindingBuilder.class)); binder = new GuiceJerseyBinder(); }