com.squarespace.jersey2.guice.JerseyGuiceUtils Java Examples
The following examples show how to use
com.squarespace.jersey2.guice.JerseyGuiceUtils.
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: SingularityCuratorTestBase.java From Singularity with Apache License 2.0 | 5 votes |
@BeforeAll public void setup() throws Exception { JerseyGuiceUtils.reset(); singularityTestModule = new SingularityTestModule(useDBTests, customConfigSetup); singularityTestModule.getInjector().injectMembers(this); singularityTestModule.start(); leaderCacheCoordinator.activateLeaderCache(); configuration.setThreadpoolShutdownDelayInSeconds(0); if (useDBTests) { Handle handle = dbiProvider.get().open(); handle.getConnection().setAutoCommit(true); Database database = DatabaseFactory .getInstance() .findCorrectDatabaseImplementation(new JdbcConnection(handle.getConnection())); Liquibase liquibase = new Liquibase( "singularity_test.sql", new FileSystemResourceAccessor(), database ); liquibase.update((String) null); try { database.close(); handle.close(); } catch (Throwable t) {} } }
Example #2
Source File: GuiceBundle.java From dropwizard-guicier with Apache License 2.0 | 4 votes |
@Override public void run(final T configuration, final Environment environment) throws Exception { for (DropwizardAwareModule<T> dropwizardAwareModule : dropwizardAwareModules) { dropwizardAwareModule.setBootstrap(bootstrap); dropwizardAwareModule.setConfiguration(configuration); dropwizardAwareModule.setEnvironment(environment); } final DropwizardModule dropwizardModule = new DropwizardModule(environment); // We assume that the next service locator will be the main application one final String serviceLocatorName = getNextServiceLocatorName(); ImmutableSet.Builder<Module> modulesBuilder = ImmutableSet.<Module>builder() .addAll(guiceModules) .addAll(dropwizardAwareModules) .add(new ServletModule()) .add(dropwizardModule) .add(new JerseyGuiceModule(serviceLocatorName)) .add(new JerseyGuicierModule()) .add(binder -> { binder.bind(Environment.class).toInstance(environment); binder.bind(configClass).toInstance(configuration); }); if (enableGuiceEnforcer) { modulesBuilder.add(new GuiceEnforcerModule()); } this.injector = injectorFactory.create(guiceStage, modulesBuilder.build()); JerseyGuiceUtils.install((name, parent) -> { if (!name.startsWith("__HK2_")) { return null; } else if (serviceLocatorName.equals(name)) { return injector.getInstance(ServiceLocator.class); } else { LOG.debug("Returning a new ServiceLocator for name '{}'", name); return JerseyGuiceUtils.newServiceLocator(name, parent); } }); dropwizardModule.register(injector); environment.servlets().addFilter("Guice Filter", GuiceFilter.class).addMappingForUrlPatterns(null, false, "/*"); environment.servlets().addServletListeners(new GuiceServletContextListener() { @Override protected Injector getInjector() { return injector; } }); }
Example #3
Source File: HK2LinkerTest.java From dropwizard-guicier with Apache License 2.0 | 4 votes |
@AfterClass public static void tearDown() { JerseyGuiceUtils.reset(); }
Example #4
Source File: GuiceBundleTest.java From dropwizard-guicier with Apache License 2.0 | 4 votes |
@After public void tearDown() { JerseyGuiceUtils.reset(); }
Example #5
Source File: InjectedIntegrationTest.java From dropwizard-guicier with Apache License 2.0 | 4 votes |
@AfterClass public static void tearDown() { JerseyGuiceUtils.reset(); }
Example #6
Source File: BaragonServiceTestBase.java From Baragon with Apache License 2.0 | 4 votes |
@BeforeAll public void setup() throws Exception { JerseyGuiceUtils.reset(); new BaragonServiceTestModule().getInjector().injectMembers(this); }