Refine search
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; }
protected Handler createAppServlet(Server server, JerseyEnvironment jersey, ObjectMapper objectMapper, Validator validator, MutableServletContextHandler handler, @Nullable Servlet jerseyContainer, MetricRegistry metricRegistry) { configureSessionsAndSecurity(handler, server); final String allowedMethodsParam = allowedMethods.stream() .collect(Collectors.joining(",")); handler.addFilter(AllowedMethodsFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST)) .setInitParameter(AllowedMethodsFilter.ALLOWED_METHODS_PARAM, allowedMethodsParam); if (enableThreadNameFilter) { handler.addFilter(ThreadNameFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST)); } serverPush.addFilter(handler); if (jerseyContainer != null) { jerseyRootPath.ifPresent(jersey::setUrlPattern); jersey.register(new JacksonFeature(objectMapper)); jersey.register(new HibernateValidationBinder(validator)); if (registerDefaultExceptionMappers == null || registerDefaultExceptionMappers) { jersey.register(new ExceptionMapperBinder(detailedJsonProcessingExceptionMapper)); } handler.addServlet(new NonblockingServletHolder(jerseyContainer), jersey.getUrlPattern()); } final InstrumentedHandler instrumented = new InstrumentedHandler(metricRegistry); instrumented.setServer(server); instrumented.setHandler(handler); return instrumented; }
private void runRegularGraphHopper(CmdArgs configuration, Environment environment) { final GraphHopperManaged graphHopperManaged = new GraphHopperManaged(configuration, environment.getObjectMapper()); environment.lifecycle().manage(graphHopperManaged); environment.jersey().register(new AbstractBinder() { @Override protected void configure() { bind(configuration).to(CmdArgs.class); bind(graphHopperManaged).to(GraphHopperManaged.class); bind(graphHopperManaged.getGraphHopper()).to(GraphHopper.class); bind(graphHopperManaged.getGraphHopper()).to(GraphHopperAPI.class); bindFactory(HasElevation.class).to(Boolean.class).named("hasElevation"); bindFactory(LocationIndexFactory.class).to(LocationIndex.class); bindFactory(TranslationMapFactory.class).to(TranslationMap.class); bindFactory(EncodingManagerFactory.class).to(EncodingManager.class); bindFactory(GraphHopperStorageFactory.class).to(GraphHopperStorage.class); bindFactory(RasterHullBuilderFactory.class).to(DelaunayTriangulationIsolineBuilder.class); } }); if (configuration.getBool("web.change_graph.enabled", false)) { environment.jersey().register(ChangeGraphResource.class); } environment.jersey().register(NearestResource.class); environment.jersey().register(RouteResource.class); environment.jersey().register(IsochroneResource.class); environment.jersey().register(I18NResource.class); environment.jersey().register(InfoResource.class); environment.healthChecks().register("graphhopper", new GraphHopperHealthCheck(graphHopperManaged.getGraphHopper())); }
@Override public void run(Configuration configuration, Environment environment) { final SimpleServerFactory serverConfig = new SimpleServerFactory(); configuration.setServerFactory(serverConfig); final HttpConnectorFactory connectorConfig = (HttpConnectorFactory) serverConfig.getConnector(); connectorConfig.setPort(0); environment.healthChecks().register("dummy", new DummyHealthCheck()); for (Object resource : resources) { if (resource instanceof Class<?>) { environment.jersey().register((Class<?>) resource); } else { environment.jersey().register(resource); } } } }
@Override public void init(Environment environment, Injector injector) { environment.jersey().register(injector.getInstance(SynchronousLdapAuthenticationService.class)); if (conf.isAwsUserIdentificationEnabled()) { environment.lifecycle().manage(injector.getInstance(AwsCredentialRefreshService.class)); } }
@Override public void run(T configuration, Environment environment) throws Exception { final Map<String, Map<String, String>> options = getViewConfiguration(configuration); for (ViewRenderer viewRenderer : viewRenderers) { final Map<String, String> viewOptions = options.get(viewRenderer.getConfigurationKey()); viewRenderer.configure(viewOptions == null ? Collections.emptyMap() : viewOptions); } environment.jersey().register(new ViewMessageBodyWriter(environment.metrics(), viewRenderers)); } }
@Override public void run(GraphHopperServerConfiguration configuration, Environment environment) { environment.jersey().register(new RootResource()); environment.servlets().addFilter("cors", CORSFilter.class).addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), false, "*"); environment.servlets().addFilter("ipfilter", new IPFilter(configuration.getGraphHopperConfiguration().get("jetty.whiteips", ""), configuration.getGraphHopperConfiguration().get("jetty.blackips", ""))).addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), false, "*"); } }
@Override public void run(HelloWorldConfiguration configuration, Environment environment) { final PersonDAO dao = new PersonDAO(hibernateBundle.getSessionFactory()); final Template template = configuration.buildTemplate(); environment.healthChecks().register("template", new TemplateHealthCheck(template)); environment.admin().addTask(new EchoTask()); environment.jersey().register(DateRequiredFeature.class); environment.jersey().register(new AuthDynamicFeature(new BasicCredentialAuthFilter.Builder<User>() .setAuthenticator(new ExampleAuthenticator()) .setAuthorizer(new ExampleAuthorizer()) .setRealm("SUPER SECRET STUFF") .buildAuthFilter())); environment.jersey().register(new AuthValueFactoryProvider.Binder<>(User.class)); environment.jersey().register(RolesAllowedDynamicFeature.class); environment.jersey().register(new HelloWorldResource(template)); environment.jersey().register(new ViewResource()); environment.jersey().register(new ProtectedResource()); environment.jersey().register(new PeopleResource(dao)); environment.jersey().register(new PersonResource(dao)); environment.jersey().register(new FilteredResource()); } }
@Override public void run(Environment environment) { ResourceConfig resourceConfig = environment.jersey().getResourceConfig(); resourceConfig.register(BaragonAuthFeature.class); } }
@Override public void run(final ExampleConfiguration configuration, final Environment environment) { // JAX-RS are all under /api environment.jersey().setUrlPattern("/api/*"); // Register each JAX-RS resoruce environment.jersey().register(ProfileResource.class); } }
@Override public void run(BithubServerConfiguration config, Environment environment) throws Exception { String githubUser = config.getGithubConfiguration().getUser(); String githubToken = config.getGithubConfiguration().getToken(); String githubWebhookUser = config.getGithubConfiguration().getWebhookConfiguration().getUsername(); String githubWebhookPwd = config.getGithubConfiguration().getWebhookConfiguration().getPassword(); List<RepositoryConfiguration> githubRepositories = config.getGithubConfiguration().getRepositories(); BigDecimal payoutRate = config.getBithubConfiguration().getPayoutRate(); String organizationName = config.getOrganizationConfiguration().getName(); String donationUrl = config.getOrganizationConfiguration().getDonationUrl().toExternalForm(); String coinbaseApiKey = config.getCoinbaseConfiguration().getApiKey(); String coinbaseApiSecret = config.getCoinbaseConfiguration().getApiSecret(); GithubClient githubClient = new GithubClient(githubUser, githubToken); CoinbaseClient coinbaseClient = new CoinbaseClient(coinbaseApiKey, coinbaseApiSecret); CacheManager cacheManager = new CacheManager(coinbaseClient, githubClient, githubRepositories, payoutRate); environment.servlets().addFilter("CORS", CrossOriginFilter.class) .addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/*"); environment.lifecycle().manage(cacheManager); environment.jersey().register(new GithubController(githubRepositories, githubClient, coinbaseClient, payoutRate)); environment.jersey().register(new StatusController(cacheManager, githubRepositories)); environment.jersey().register(new DashboardController(organizationName, donationUrl, cacheManager)); environment.jersey().register(new IOExceptionMapper()); environment.jersey().register(new UnauthorizedHookExceptionMapper()); environment.jersey().register(new BasicAuthProvider<>(new GithubWebhookAuthenticator(githubWebhookUser, githubWebhookPwd), GithubWebhookAuthenticator.REALM)); }
private void registerServlet(final String path, final Environment environment) { environment.admin() .addServlet("adminRest", new AdminRestServlet(environment.getJerseyServletContainer())) .addMapping(path); environment.jersey().register(AdminResourceFilter.class); logger.info("Admin REST registered on path: {}", path); }
@Override public void run(final T configuration, final Environment environment) throws Exception { assert configuration instanceof AlchemyServiceConfiguration; final AlchemyModule module = new AlchemyModule(configuration, environment); environment.lifecycle().manage(module); final Injector injector = Guice.createInjector(module); runInjected(injector, configuration, environment); environment.jersey().getResourceConfig().getContainerResponseFilters().add(new SparseFieldSetFilter(environment.getObjectMapper())); environment.jersey().register(new RuntimeExceptionMapper()); environment.lifecycle().manage(new JmxMetricsManaged(environment)); registerIdentitySubTypes(configuration, environment); }
private void evaluateWeb() throws Exception { if (!runPerServiceMode(web)) { return; } // Load balancers should hit the ping servlet, exposed on the main port to reflect main connection pool issues _environment.servlets().addServlet("/ping", new PingServlet()); // Serve static assets _environment.jersey().register(FaviconResource.class); // Add a filter to provide finer 5xx metrics than the default DropWizard metrics include. //noinspection unchecked _environment.jersey().getResourceConfig().getContainerResponseFilters() .add(new ServerErrorResponseMetricsFilter(_environment.metrics())); }
@Override public void run(TimeLockServerConfiguration configuration, Environment environment) { environment.getObjectMapper().registerModule(new Jdk8Module()); environment.jersey().register(HttpRemotingJerseyFeature.INSTANCE); MetricsManager metricsManager = MetricsManagers.of(environment.metrics(), new DefaultTaggedMetricRegistry()); CombinedTimeLockServerConfiguration combined = TimeLockConfigMigrator.convert(configuration, environment); Consumer<Object> registrar = component -> environment.jersey().register(component); TimeLockAgent.create( metricsManager, combined.install(), combined::runtime, // this won't actually live reload combined.deprecated(), registrar); } }
@Override public void run(MacroBaseConf configuration, Environment environment) throws Exception { configuration.loadSystemProperties(); environment.jersey().register(new AnalyzeResource(configuration)); environment.jersey().register(new SchemaResource(configuration)); environment.jersey().register(new RowSetResource(configuration)); environment.jersey().register(new FormattedRowSetResource(configuration)); environment.jersey().register(new MultipleRowSetResource(configuration)); environment.healthChecks().register("basic", new HealthCheck() { @Override protected Result check() throws Exception { return null; } }); environment.jersey().setUrlPattern("/api/*"); } }
private void evaluateDeltaMigrator() throws Exception { if (!runPerServiceMode(delta_migrator)) { return; } _environment.jersey().register(new BlockMigratorResource1(_injector.getInstance(DeltaMigrator.class))); // No admin tasks are registered automatically in DELTA_MIGRATOR ServiceMode _environment.admin().addTask(_injector.getInstance(LeaderServiceTask.class)); }
@Override public void run(DropwizardConfiguration dropwizardConfiguration, Environment environment) throws Exception { environment.jersey().property(KatharsisProperties.RESOURCE_SEARCH_PACKAGE, dropwizardConfiguration.katharsis.searchPackage); KatharsisFeature katharsisFeature = new KatharsisFeature(); environment.jersey().register(katharsisFeature); }
@Override public void run(T configuration, Environment environment) { ShiroConfiguration shiroConfig = narrow(configuration); ResourceConfig resourceConfig = environment.jersey().getResourceConfig(); resourceConfig.register(new AuthorizationFilterFeature()); resourceConfig.register(new SubjectFactory()); resourceConfig.register(new AuthInjectionBinder()); Filter shiroFilter = createFilter(configuration); environment.servlets() .addFilter("ShiroFilter", shiroFilter) .addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), false, shiroConfig.filterUrlPattern()); }