public ObjectMapper getObjectMapper() { return getEnvironment().getObjectMapper(); }
/** * Builds the {@link Client} instance. * * @return a fully-configured {@link Client} */ public Client build(String name) { if ((environment == null) && ((executorService == null) || (objectMapper == null))) { throw new IllegalStateException("Must have either an environment or both " + "an executor service and an object mapper"); } if (executorService == null) { // Create an ExecutorService based on the provided // configuration. The DisposableExecutorService decorator // is used to ensure that the service is shut down if the // Jersey client disposes of it. executorService = requireNonNull(environment).lifecycle() .executorService("jersey-client-" + name + "-%d") .minThreads(configuration.getMinThreads()) .maxThreads(configuration.getMaxThreads()) .workQueue(new ArrayBlockingQueue<>(configuration.getWorkQueueSize())) .build(); } if (objectMapper == null) { objectMapper = requireNonNull(environment).getObjectMapper(); } if (environment != null) { validator = environment.getValidator(); } return build(name, executorService, objectMapper, validator); }
environment.getObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
String[] users = namespace.getString("user").split(","); environment.getObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
environment.getObjectMapper(), environment.getValidator(), environment.getApplicationContext(),
@Override public Server build(Environment environment) { printBanner(environment.getName()); final ThreadPool threadPool = createThreadPool(environment.metrics()); final Server server = buildServer(environment.lifecycle(), threadPool); final Handler applicationHandler = createAppServlet(server, environment.jersey(), environment.getObjectMapper(), environment.getValidator(), environment.getApplicationContext(), environment.getJerseyServletContainer(), environment.metrics()); final Handler adminHandler = createAdminServlet(server, environment.getAdminContext(), environment.metrics(), environment.healthChecks()); final RoutingHandler routingHandler = buildRoutingHandler(environment.metrics(), server, applicationHandler, adminHandler); final Handler gzipHandler = buildGzipHandler(routingHandler); server.setHandler(addStatsHandler(addRequestLog(server, gzipHandler, environment.getName()))); return server; }
environment.getObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
@Override public ObjectMapper get() { return environment.getObjectMapper().copy(); } }
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())); }
environment.getObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); environment.getObjectMapper().setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE); environment.getObjectMapper().setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
@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); } }
private static TimeLockDeprecatedConfiguration createDeprecatedConfiguration(TimeLockServerConfiguration config, Environment environment) { ImmutableTimeLockDeprecatedConfiguration.Builder deprecatedBuilder = ImmutableTimeLockDeprecatedConfiguration.builder(); if (config.timeLimiterConfiguration().enableTimeLimiting()) { deprecatedBuilder.useLockTimeLimiter(true); deprecatedBuilder.blockingTimeoutInMs( BlockingTimeouts.getBlockingTimeout(environment.getObjectMapper(), config)); } if (config.useClientRequestLimit()) { deprecatedBuilder.useClientRequestLimit(true); deprecatedBuilder.availableThreads(config.availableThreads()); } return deprecatedBuilder.build(); } }
environment.getObjectMapper(), environment.getValidator(), environment.getApplicationContext(),
@Override public ObjectMapper get() { return environment.getObjectMapper().copy(); } }
@Override public Server build(Environment environment) { printBanner(environment.getName()); final ThreadPool threadPool = createThreadPool(environment.metrics()); final Server server = buildServer(environment.lifecycle(), threadPool); final Handler applicationHandler = createAppServlet(server, environment.jersey(), environment.getObjectMapper(), environment.getValidator(), environment.getApplicationContext(), environment.getJerseyServletContainer(), environment.metrics()); final Handler adminHandler = createAdminServlet(server, environment.getAdminContext(), environment.metrics(), environment.healthChecks()); final RoutingHandler routingHandler = buildRoutingHandler(environment.metrics(), server, applicationHandler, adminHandler); final Handler gzipHandler = buildGzipHandler(routingHandler); server.setHandler(addStatsHandler(addRequestLog(server, gzipHandler, environment.getName()))); return server; }
private static void configureObjectMapper(Environment environment) { ObjectMapper mapper = environment.getObjectMapper(); mapper.findAndRegisterModules(); SimpleModule module = new SimpleModule(); module.addSerializer(ID.class, new IDSerializer()); mapper.registerModule(module); mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); } }
private static void configureObjectMapper(Environment environment) { ObjectMapper mapper = environment.getObjectMapper(); mapper.findAndRegisterModules(); SimpleModule module = new SimpleModule(); module.addSerializer(ID.class, new IDSerializer()); mapper.registerModule(module); mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); }
private void registerIdentitySubTypes(T configuration, Environment environment) { for (final IdentityMapping identity : configuration.getIdentities().values()) { environment.getObjectMapper().registerSubtypes(identity.getDtoType()); } } }
public CommandListener build(Environment environment, EventPublisher applicationEventPublisher, Class aggregateRoot) { KafkaCommandListener listener = new KafkaCommandListener(boostrap, environment.getName(), environment.getObjectMapper(), applicationEventPublisher, aggregateRoot.getSimpleName()); environment.lifecycle().manage(listener); return listener; } }
@Override public void run(WazeConfig conf, Environment env) throws IOException { env.getObjectMapper().configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); final WazeRouteService wazeRouteService = new WazeRouteService(); final WazeNotificationService wazeNotificationService = new WazeNotificationService(); final WazeEndPoint wazeEndPoint = new WazeEndPoint(wazeRouteService, wazeNotificationService); final WazeHealthCheck wazeHealthCheck = new WazeHealthCheck(wazeRouteService); env.healthChecks().register("waze", wazeHealthCheck); env.jersey().register(wazeEndPoint); }