@Override public void run(Configuration configuration, Environment environment) { environment.getApplicationContext().addLifeCycleListener(new AbstractLifeCycle.AbstractLifeCycleListener() { @Override public void lifeCycleStarted(LifeCycle event) { final Set<SslReload> reloaders = new HashSet<>(); reloaders.addAll(getReloaders(environment.getApplicationContext())); reloaders.addAll(getReloaders(environment.getAdminContext())); LOGGER.info("{} ssl reloaders registered", reloaders.size()); reloadTask.setReloaders(reloaders); } }); environment.admin().addTask(reloadTask); }
@Override public void run(Configuration configuration, Environment environment) { environment.jersey().register(MultiPartFeature.class); } }
@Override protected void run(Bootstrap<T> bootstrap, Namespace namespace, T configuration) throws Exception { final Environment environment = new Environment(bootstrap.getApplication().getName(), bootstrap.getObjectMapper(), bootstrap.getValidatorFactory(), bootstrap.getMetricRegistry(), bootstrap.getClassLoader(), bootstrap.getHealthCheckRegistry()); configuration.getMetricsFactory().configure(environment.lifecycle(), bootstrap.getMetricRegistry()); configuration.getServerFactory().configure(environment); bootstrap.run(configuration, environment); application.run(configuration, environment); run(environment, namespace, configuration); }
@Override public void run(C configuration, Environment environment) throws Exception { environment.lifecycle().addServerLifecycleListener(server -> jettyServer = server); DropwizardTestSupport.this.configuration = configuration; DropwizardTestSupport.this.environment = environment; super.run(configuration, environment); for (ServiceListener<C> listener : listeners) { try { listener.onRun(configuration, environment, DropwizardTestSupport.this); } catch (Exception ex) { throw new RuntimeException("Error running app rule start listener", ex); } } } };
@Override public void onRun(C configuration, Environment environment, DropwizardTestSupport<C> rule) throws Exception { environment.lifecycle().manage(managed); } });
@Override public void initialize(Bootstrap<BithubServerConfiguration> bootstrap) { bootstrap.addBundle(new ViewBundle()); }
/** * Build a fully configured DBI instance managed by the DropWizard lifecycle * with the configured health check; this method should not be overridden * (instead, override {@link #configure(DBI, PooledDataSourceFactory)} and/or * {@link #newInstance(ManagedDataSource)}) * * @param environment * @param configuration * @param name * @return A fully configured {@link DBI} object using a managed data source * based on the specified environment and configuration * @see #build(Environment, PooledDataSourceFactory, ManagedDataSource, * String) */ public DBI build(Environment environment, PooledDataSourceFactory configuration, String name) { final ManagedDataSource dataSource = configuration.build(environment.metrics(), name); return build(environment, configuration, dataSource, name); }
@Override public void run(Configuration configuration, Environment environment) { LOGGER.info("Registering AssetBundle with name: {} for path {}", assetsName, uriPath + '*'); environment.servlets().addServlet(assetsName, createServlet()).addMapping(uriPath + '*'); }
public ObjectMapper getObjectMapper() { return getEnvironment().getObjectMapper(); }
@Override public void configure(Environment environment) { LOGGER.info("Registering jersey handler with root path prefix: {}", applicationContextPath); environment.getApplicationContext().setContextPath(applicationContextPath); LOGGER.info("Registering admin handler with root path prefix: {}", adminContextPath); environment.getAdminContext().setContextPath(adminContextPath); }
@Override public final void initialize(Bootstrap<?> bootstrap) { bootstrap.getObjectMapper().registerModule(createHibernate5Module()); }
@Override @SuppressWarnings("unchecked") public final void initialize(Bootstrap<?> bootstrap) { final Class<T> klass = (Class<T>) bootstrap.getApplication().getConfigurationClass(); bootstrap.addCommand(new DbCommand<>(name(), this, klass, getMigrationsFileName())); }
/** * Called by {@link #run(String...)} to add the standard "server" and "check" commands * * @param bootstrap the bootstrap instance */ protected void addDefaultCommands(Bootstrap<T> bootstrap) { bootstrap.addCommand(new ServerCommand<>(this)); bootstrap.addCommand(new CheckCommand<>(this)); }
/** * Stop the server * @throws Exception */ public void stop() throws Exception { env.getAdminContext().stop(); }
public SessionFactory build(HibernateBundle<?> bundle, Environment environment, PooledDataSourceFactory dbConfig, List<Class<?>> entities, String name) { final ManagedDataSource dataSource = dbConfig.build(environment.metrics(), name); return build(bundle, environment, dbConfig, dataSource, entities); }
@Override public void configure(Environment environment) { LOGGER.info("Registering jersey handler with root path prefix: {}", applicationContextPath); environment.getApplicationContext().setContextPath(applicationContextPath); LOGGER.info("Registering admin handler with root path prefix: {}", adminContextPath); environment.getAdminContext().setContextPath(adminContextPath); } }
private UnitOfWorkApplicationListener registerUnitOfWorkListenerIfAbsent(Environment environment) { for (Object singleton : environment.jersey().getResourceConfig().getSingletons()) { if (singleton instanceof UnitOfWorkApplicationListener) { return (UnitOfWorkApplicationListener) singleton; } } final UnitOfWorkApplicationListener listener = new UnitOfWorkApplicationListener(); environment.jersey().register(listener); return listener; }