Java Code Examples for com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider#setMapper()

The following examples show how to use com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider#setMapper() . 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: JacksonFeature.java    From micro-server with Apache License 2.0 6 votes vote down vote up
@Override
  public boolean configure(final FeatureContext context) {
      
  	PluginLoader.INSTANCE.plugins.get().stream()
.filter(module -> module.jacksonFeatureProperties()!=null)
.map(Plugin::jacksonFeatureProperties)
.map(fn->fn.apply(context))
.forEach(map -> {
	addAll(map,context);
});
     
      
      JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
   		provider.setMapper(JacksonUtil.getMapper());
          context.register(provider, new Class[]{MessageBodyReader.class, MessageBodyWriter.class});
   
      return true;
  }
 
Example 2
Source File: WebClient.java    From dremio-oss with Apache License 2.0 6 votes vote down vote up
private WebTarget getWebClient(
  DACConfig dacConfig) throws IOException, GeneralSecurityException {
  final JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
  provider.setMapper(JSONUtil.prettyMapper());
  ClientBuilder clientBuilder = ClientBuilder.newBuilder()
    .register(provider)
    .register(MultiPartFeature.class);

  if (dacConfig.webSSLEnabled()) {
    this.setTrustStore(clientBuilder, dacConfig);
  }

  final Client client = clientBuilder.build();
  return client.target(format("%s://%s:%d", dacConfig.webSSLEnabled() ? "https" : "http", dacConfig.thisNode,
    dacConfig.getHttpPort())).path("apiv2");
}
 
Example 3
Source File: TestUIServer.java    From dremio-oss with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void init() throws Exception {
  try (TimedBlock b = Timer.time("TestUIServer.@BeforeClass")) {
    dremioDaemon = DACDaemon.newDremioDaemon(
      DACConfig
        .newDebugConfig(DremioTest.DEFAULT_SABOT_CONFIG)
        .autoPort(true)
        .allowTestApis(true)
        .writePath(folder.getRoot().getAbsolutePath())
        .clusterMode(ClusterMode.LOCAL)
        .serveUI(true),
        DremioTest.CLASSPATH_SCAN_RESULT);
    dremioDaemon.init();
    JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
    provider.setMapper(JSONUtil.prettyMapper());
    client = ClientBuilder.newBuilder().register(provider).register(MultiPartFeature.class).build();
    rootTarget = client.target("http://localhost:" + dremioDaemon.getWebServer().getPort());
  }
}
 
Example 4
Source File: TestMasterDown.java    From dremio-oss with Apache License 2.0 6 votes vote down vote up
private static void initClient() {
  JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
  ObjectMapper objectMapper = JSONUtil.prettyMapper();
  JSONUtil.registerStorageTypes(objectMapper, DremioTest.CLASSPATH_SCAN_RESULT,
      ConnectionReader.of(DremioTest.CLASSPATH_SCAN_RESULT, DremioTest.DEFAULT_SABOT_CONFIG));
  objectMapper.registerModule(
    new SimpleModule()
      .addDeserializer(JobDataFragment.class,
        new JsonDeserializer<JobDataFragment>() {
          @Override
          public JobDataFragment deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
            return jsonParser.readValueAs(DataPOJO.class);
          }
        }
      )
  );
  provider.setMapper(objectMapper);
  client = ClientBuilder.newBuilder().register(provider).register(MultiPartFeature.class).build();
  WebTarget rootTarget = client.target("http://localhost:" + currentDremioDaemon.getWebServer().getPort());
  currentApiV2 = rootTarget.path(API_LOCATION);
}
 
Example 5
Source File: TestMasterDown.java    From dremio-oss with Apache License 2.0 6 votes vote down vote up
private static void initMasterClient() {
  JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
  ObjectMapper objectMapper = JSONUtil.prettyMapper();
  JSONUtil.registerStorageTypes(objectMapper, DremioTest.CLASSPATH_SCAN_RESULT,
      ConnectionReader.of(DremioTest.CLASSPATH_SCAN_RESULT, DremioTest.DEFAULT_SABOT_CONFIG));
  objectMapper.registerModule(
    new SimpleModule()
      .addDeserializer(JobDataFragment.class,
        new JsonDeserializer<JobDataFragment>() {
          @Override
          public JobDataFragment deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
            return jsonParser.readValueAs(DataPOJO.class);
          }
        }
      )
  );
  provider.setMapper(objectMapper);
  masterClient = ClientBuilder.newBuilder().register(provider).register(MultiPartFeature.class).build();
  WebTarget rootTarget = masterClient.target("http://localhost:" + masterDremioDaemon.getWebServer().getPort());
  masterApiV2 = rootTarget.path(API_LOCATION);
}
 
Example 6
Source File: TestMultiMaster.java    From dremio-oss with Apache License 2.0 6 votes vote down vote up
private static Client newClient() {
  JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
  ObjectMapper objectMapper = JSONUtil.prettyMapper();
  JSONUtil.registerStorageTypes(objectMapper, DremioTest.CLASSPATH_SCAN_RESULT,
    ConnectionReader.of(DremioTest.CLASSPATH_SCAN_RESULT, DremioTest.DEFAULT_SABOT_CONFIG));
  objectMapper.registerModule(
    new SimpleModule()
      .addDeserializer(JobDataFragment.class,
        new JsonDeserializer<JobDataFragment>() {
          @Override
          public JobDataFragment deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
            return jsonParser.readValueAs(DataPOJO.class);
          }
        }
      )
  );
  provider.setMapper(objectMapper);
  return ClientBuilder.newBuilder().register(provider).register(MultiPartFeature.class).build();
}
 
Example 7
Source File: ShopifySdk.java    From shopify-sdk with Apache License 2.0 5 votes vote down vote up
private static Client buildClient() {
	final ObjectMapper mapper = ShopifySdkObjectMapper.buildMapper();
	final JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
	provider.setMapper(mapper);

	return ClientBuilder.newClient().register(JacksonFeature.class).register(provider);
}
 
Example 8
Source File: AsyncRestClient.java    From micro-server with Apache License 2.0 5 votes vote down vote up
protected Client initClient(int rt, int ct) {

		ClientConfig clientConfig = new ClientConfig();
		clientConfig.property(ClientProperties.CONNECT_TIMEOUT, ct);
		clientConfig.property(ClientProperties.READ_TIMEOUT, rt);

		ClientBuilder.newBuilder().register(JacksonFeature.class);
		Client client = ClientBuilder.newClient(clientConfig);
		client.register(JacksonFeature.class);
		JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
		provider.setMapper(JacksonUtil.getMapper());
		client.register(provider);
		return client;

	}
 
Example 9
Source File: RestClient.java    From micro-server with Apache License 2.0 5 votes vote down vote up
protected Client initClient(int rt, int ct) {

		ClientConfig clientConfig = new ClientConfig();
		clientConfig.property(ClientProperties.CONNECT_TIMEOUT, ct);
		clientConfig.property(ClientProperties.READ_TIMEOUT, rt);

		ClientBuilder.newBuilder().register(JacksonFeature.class);
		Client client = ClientBuilder.newClient(clientConfig);
		client.register(JacksonFeature.class);
		JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
		provider.setMapper(JacksonUtil.getMapper());
		client.register(provider);
		return client;

	}
 
Example 10
Source File: SpringBootJerseyRestApplication.java    From micro-server with Apache License 2.0 5 votes vote down vote up
@Autowired(required=false)
public SpringBootJerseyRestApplication(ApplicationContext context,Module module){
	ModuleDataExtractor extractor = new ModuleDataExtractor(module);
	
	LinkedListX allResources = extractor.getRestResources(context);
	
	System.out.println("Resources " + allResources);
	Map<String, Object> serverProperties = module.getServerProperties();
	if (allResources != null) {
		for (Object next : allResources) {
			if(isSingleton(next))
				register(next);
			else
				register(next.getClass());
		}
	}
			
	if (serverProperties.isEmpty()) {
		property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true);
        //http://stackoverflow.com/questions/25755773/bean-validation-400-errors-are-returning-default-error-page-html-instead-of-re
        property(ServerProperties.RESPONSE_SET_STATUS_OVER_SEND_ERROR, "true");
	} else {
		for (Map.Entry<String, Object> entry : serverProperties.entrySet()) {
			property(entry.getKey(), entry.getValue());
		}
	}

	
	context.getBeansOfType(AbstractBinder.class).forEach((n,e)->register(e));

       JacksonJaxbJsonProvider p = new JacksonJaxbJsonProvider();
       p.setMapper(JacksonUtil.getMapper());
	register(p);
	module.getDefaultJaxRsPackages().stream().forEach( e -> packages(e));
	module.getDefaultResources().stream().forEach( e -> register(e));
	
	
	module.getResourceConfigManager().accept(new JaxRsProvider<>(this));
}
 
Example 11
Source File: ExecutionContainerModule.java    From flux with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the Jetty server instance for the Flux Execution API endpoint.
 * @return Jetty Server instance
 */
@Named("ExecutionAPIJettyServer")
@Provides
@Singleton
Server getExecutionAPIJettyServer(@Named("Execution.Node.Api.service.port") int port,
                         @Named("ExecutionAPIResourceConfig")ResourceConfig resourceConfig,
                         @Named("Execution.Node.Api.service.acceptors") int acceptorThreads,
                         @Named("Execution.Node.Api.service.selectors") int selectorThreads,
                         @Named("Execution.Node.Api.service.workers") int maxWorkerThreads,
                         ObjectMapper objectMapper, MetricRegistry metricRegistry) throws URISyntaxException, UnknownHostException {
    JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
    provider.setMapper(objectMapper);
    resourceConfig.register(provider);
    QueuedThreadPool threadPool = new QueuedThreadPool();
    threadPool.setMaxThreads(maxWorkerThreads);
    Server server = new Server(threadPool);
    ServerConnector http = new ServerConnector(server, acceptorThreads, selectorThreads);
    http.setPort(port);
    server.addConnector(http);
    ServletContextHandler context = new ServletContextHandler(server, "/*");
    ServletHolder servlet = new ServletHolder(new ServletContainer(resourceConfig));
    context.addServlet(servlet, "/*");

    final InstrumentedHandler handler = new InstrumentedHandler(metricRegistry);
    handler.setHandler(context);
    server.setHandler(handler);

    server.setStopAtShutdown(true);
    return server;
}
 
Example 12
Source File: ContainerModule.java    From flux with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the Jetty server instance for the Flux API endpoint.
 * @param port where the service is available.
 * @return Jetty Server instance
 */
@Named("APIJettyServer")
@Provides
@Singleton
Server getAPIJettyServer(@Named("Api.service.port") int port,
						 @Named("APIResourceConfig")ResourceConfig resourceConfig,
						 @Named("Api.service.acceptors") int acceptorThreads,
						 @Named("Api.service.selectors") int selectorThreads,
						 @Named("Api.service.workers") int maxWorkerThreads,
						 ObjectMapper objectMapper, MetricRegistry metricRegistry) throws URISyntaxException, UnknownHostException {
	JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
	provider.setMapper(objectMapper);
	resourceConfig.register(provider);
	QueuedThreadPool threadPool = new QueuedThreadPool();
	threadPool.setMaxThreads(maxWorkerThreads);
	Server server = new Server(threadPool);
	ServerConnector http = new ServerConnector(server, acceptorThreads, selectorThreads);
	http.setPort(port);
	server.addConnector(http);
	ServletContextHandler context = new ServletContextHandler(server, "/*");
	ServletHolder servlet = new ServletHolder(new ServletContainer(resourceConfig));
	context.addServlet(servlet, "/*");

	final InstrumentedHandler handler = new InstrumentedHandler(metricRegistry);
	handler.setHandler(context);
	server.setHandler(handler);

	server.setStopAtShutdown(true);
	return server;
}
 
Example 13
Source File: BaseTestServer.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
private static void initClient(ObjectMapper mapper) throws Exception {
  setBinder(createBinder(currentDremioDaemon.getBindingProvider()));

  if (!Files.exists(new File(folder0.getRoot().getAbsolutePath() + "/testplugins").toPath())) {
    TestUtilities.addDefaultTestPlugins(l(CatalogService.class), folder0.newFolder("testplugins").toString());
  }

  setPopulator(new SampleDataPopulator(
    l(SabotContext.class),
    newSourceService(),
    newDatasetVersionMutator(),
    l(UserService.class),
    newNamespaceService(),
    DEFAULT_USERNAME
  ));

  final JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
  provider.setMapper(mapper);

  client = ClientBuilder.newBuilder()
    .property(FEATURE_AUTO_DISCOVERY_DISABLE, true)
    .register(provider)
    .register(MultiPartFeature.class)
    .build();
  rootTarget = client.target("http://localhost:" + currentDremioDaemon.getWebServer().getPort());
  final WebTarget livenessServiceTarget = client.target("http://localhost:" + currentDremioDaemon.getLivenessService().getLivenessPort());
  metricsEndpoint = livenessServiceTarget.path("metrics");
  apiV2 = rootTarget.path(API_LOCATION);
  publicAPI = rootTarget.path(PUBLIC_API_LOCATION);
  if (isMultinode()) {
    masterApiV2 = client.target("http://localhost:" + masterDremioDaemon.getWebServer().getPort()).path(API_LOCATION);
    masterPublicAPI = client.target("http://localhost:" + masterDremioDaemon.getWebServer().getPort()).path(PUBLIC_API_LOCATION);
  } else {
    masterApiV2 = apiV2;
    masterPublicAPI = publicAPI;
  }
}
 
Example 14
Source File: TestHdfs.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void init() throws Exception {
  assumeNonMaprProfile();
  startMiniDfsCluster(TestHdfs.class.getName());
  String[] hostPort = dfsCluster.getNameNode().getHostAndPort().split(":");
  host = hostPort[0];
  port = Integer.parseInt(hostPort[1]);
  fs.mkdirs(new Path("/dir1/"), new FsPermission(FsAction.ALL, FsAction.ALL, FsAction.ALL));
  fs.mkdirs(new Path("/dir1/json"), new FsPermission(FsAction.ALL, FsAction.ALL, FsAction.ALL));
  fs.mkdirs(new Path("/dir1/text"), new FsPermission(FsAction.ALL, FsAction.ALL, FsAction.ALL));
  fs.mkdirs(new Path("/dir1/parquet"), new FsPermission(FsAction.ALL, FsAction.ALL, FsAction.ALL));
  fs.mkdirs(new Path("/dir2"), new FsPermission(FsAction.ALL, FsAction.ALL, FsAction.ALL));
  fs.copyFromLocalFile(false, true, new Path(FileUtils.getResourceAsFile("/datasets/users.json").getAbsolutePath()),
    new Path("/dir1/json/users.json"));
  fs.setPermission(new Path("/dir1/json/users.json"), new FsPermission(FsAction.ALL, FsAction.ALL, FsAction.ALL));
  try (Timer.TimedBlock b = Timer.time("TestHdfs.@BeforeClass")) {
    dremioDaemon = DACDaemon.newDremioDaemon(
      DACConfig
        .newDebugConfig(DremioTest.DEFAULT_SABOT_CONFIG)
        .autoPort(true)
        .allowTestApis(true)
        .writePath(folder.getRoot().getAbsolutePath())
        .clusterMode(ClusterMode.LOCAL)
        .serveUI(true),
      DremioTest.CLASSPATH_SCAN_RESULT,
      new DACDaemonModule());
    dremioDaemon.init();
    dremioBinder = BaseTestServer.createBinder(dremioDaemon.getBindingProvider());
    JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
    provider.setMapper(JSONUtil.prettyMapper());
    client = ClientBuilder.newBuilder().register(provider).register(MultiPartFeature.class).build();
  }
}
 
Example 15
Source File: TestHdfsAsyncParquet.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void init() throws Exception {
  assumeNonMaprProfile();
  startMiniDfsCluster(TestHdfsAsyncParquet.class.getName());
  String[] hostPort = dfsCluster.getNameNode().getHostAndPort().split(":");
  host = hostPort[0];
  port = Integer.parseInt(hostPort[1]);
  setupSchemaLearnTest();
  setupIntUnionTest();
  setupStructSchemaChangeTest();
  setupStructWithDifferentCaseTest();
  try (Timer.TimedBlock b = Timer.time("TestHdfsAsyncParquet.@BeforeClass")) {
    dremioDaemon = DACDaemon.newDremioDaemon(
      DACConfig
        .newDebugConfig(DremioTest.DEFAULT_SABOT_CONFIG)
        .autoPort(true)
        .allowTestApis(true)
        .writePath(folder.getRoot().getAbsolutePath())
        .clusterMode(ClusterMode.LOCAL)
        .serveUI(true),
      DremioTest.CLASSPATH_SCAN_RESULT,
      new DACDaemonModule());
    dremioDaemon.init();
    dremioBinder = BaseTestServer.createBinder(dremioDaemon.getBindingProvider());
    JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
    provider.setMapper(JSONUtil.prettyMapper());
    client = ClientBuilder.newBuilder().register(provider).register(MultiPartFeature.class).build();
  }
}
 
Example 16
Source File: Jackson.java    From barge with Apache License 2.0 4 votes vote down vote up
/**
 * @return a suitable provider with configured deserialization objects.
 */
public static JacksonJaxbJsonProvider customJacksonProvider() {
  JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
  provider.setMapper(objectMapper());
  return provider;
}
 
Example 17
Source File: JerseyServletProvider.java    From vespa with Apache License 2.0 4 votes vote down vote up
private static JacksonJaxbJsonProvider jacksonDatatypeJdk8Provider() {
    JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
    provider.setMapper(new ObjectMapper().registerModule(new Jdk8Module()).registerModule(new JavaTimeModule()));
    return provider;
}
 
Example 18
Source File: ElasticConnectionPool.java    From dremio-oss with Apache License 2.0 4 votes vote down vote up
public void connect() throws IOException {
  final ClientConfig configuration = new ClientConfig();
  configuration.property(ClientProperties.READ_TIMEOUT, readTimeoutMillis);
  final AWSCredentialsProvider awsCredentialsProvider = elasticsearchAuthentication.getAwsCredentialsProvider();
  if (awsCredentialsProvider != null) {
    configuration.property(REGION_NAME, elasticsearchAuthentication.getRegionName());
    configuration.register(ElasticsearchRequestClientFilter.class);
    configuration.register(new InjectableAWSCredentialsProvider(awsCredentialsProvider), InjectableAWSCredentialsProvider.class);
  }

  final ClientBuilder builder = ClientBuilder.newBuilder()
      .withConfig(configuration);

  switch(sslMode) {
  case UNSECURE:
    builder.sslContext(SSLHelper.newAllTrustingSSLContext("SSL"));
    // fall-through
  case VERIFY_CA:
    builder.hostnameVerifier(SSLHelper.newAllValidHostnameVerifier());
    // fall-through
  case STRICT:
    break;

  case OFF:
    // no TLS/SSL configuration
  }

  client = builder.build();
  client.register(GZipEncoder.class);
  client.register(DeflateEncoder.class);
  client.register(EncodingFilter.class);

  if (REQUEST_LOGGER.isDebugEnabled()) {
    java.util.logging.Logger julLogger = java.util.logging.Logger.getLogger(REQUEST_LOGGER_NAME);
    client.register(new LoggingFeature(
        julLogger,
        Level.FINE,
        REQUEST_LOGGER.isTraceEnabled() ? LoggingFeature.Verbosity.PAYLOAD_TEXT : LoggingFeature.Verbosity.HEADERS_ONLY,
        65536));
  }

  final JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
  provider.setMapper(ElasticMappingSet.MAPPER);

  // Disable other JSON providers.
  client.property(
    PropertiesHelper.getPropertyNameForRuntime(InternalProperties.JSON_FEATURE, client.getConfiguration().getRuntimeType()),
    JacksonJaxbJsonProvider.class.getSimpleName());

  client.register(provider);

  HttpAuthenticationFeature httpAuthenticationFeature = elasticsearchAuthentication.getHttpAuthenticationFeature();
  if (httpAuthenticationFeature != null) {
    client.register(httpAuthenticationFeature);
  }

  updateClients();
}
 
Example 19
Source File: SpringBootJerseyRestApplication.java    From micro-server with Apache License 2.0 4 votes vote down vote up
@Autowired(required=false)
public SpringBootJerseyRestApplication(ApplicationContext context,Module module){
	ModuleDataExtractor extractor = new ModuleDataExtractor(module);
	
	LinkedListX allResources = extractor.getRestResources(context);
	
	System.out.println("Resources " + allResources);
	Map<String, Object> serverProperties = module.getServerProperties();
	if (allResources != null) {
		for (Object next : allResources) {
			if(isSingleton(next))
				register(next);
			else
				register(next.getClass());
		}
	}
			
	if (serverProperties.isEmpty()) {
		property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true);
        //http://stackoverflow.com/questions/25755773/bean-validation-400-errors-are-returning-default-error-page-html-instead-of-re
        property(ServerProperties.RESPONSE_SET_STATUS_OVER_SEND_ERROR, "true");
	} else {
		for (Map.Entry<String, Object> entry : serverProperties.entrySet()) {
			property(entry.getKey(), entry.getValue());
		}
	}

	
	context.getBeansOfType(AbstractBinder.class).forEach((n,e)->register(e));

       JacksonJaxbJsonProvider p = new JacksonJaxbJsonProvider();
       p.setMapper(JacksonUtil.getMapper());
       register(p);
       module.getDefaultJaxRsPackages()
             .stream()
             .forEach(e -> packages(e));
       module.getDefaultResources()
             .stream()
             .forEach(e -> register(e));
	
	
	module.getResourceConfigManager().accept(new JaxRsProvider<>(this));
}
 
Example 20
Source File: DrillRestServer.java    From Bats with Apache License 2.0 4 votes vote down vote up
public DrillRestServer(final WorkManager workManager, final ServletContext servletContext, final Drillbit drillbit) {
  register(DrillRoot.class);
  register(StatusResources.class);
  register(StorageResources.class);
  register(ProfileResources.class);
  register(QueryResources.class);
  register(MetricsResources.class);
  register(ThreadsResources.class);
  register(LogsResources.class);

  property(FreemarkerMvcFeature.TEMPLATE_OBJECT_FACTORY, getFreemarkerConfiguration(servletContext));
  register(FreemarkerMvcFeature.class);

  register(MultiPartFeature.class);
  property(ServerProperties.METAINF_SERVICES_LOOKUP_DISABLE, true);

  final boolean isAuthEnabled =
      workManager.getContext().getConfig().getBoolean(ExecConstants.USER_AUTHENTICATION_ENABLED);

  if (isAuthEnabled) {
    register(LogInLogOutResources.class);
    register(AuthDynamicFeature.class);
    register(RolesAllowedDynamicFeature.class);
  }

  //disable moxy so it doesn't conflict with jackson.
  final String disableMoxy = PropertiesHelper.getPropertyNameForRuntime(CommonProperties.MOXY_JSON_FEATURE_DISABLE,
      getConfiguration().getRuntimeType());
  property(disableMoxy, true);

  register(JsonParseExceptionMapper.class);
  register(JsonMappingExceptionMapper.class);
  register(GenericExceptionMapper.class);

  JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
  provider.setMapper(workManager.getContext().getLpPersistence().getMapper());
  register(provider);

  // Get an EventExecutor out of the BitServer EventLoopGroup to notify listeners for WebUserConnection. For
  // actual connections between Drillbits this EventLoopGroup is used to handle network related events. Though
  // there is no actual network connection associated with WebUserConnection but we need a CloseFuture in
  // WebSessionResources, so we are using EvenExecutor from network EventLoopGroup pool.
  final EventExecutor executor = workManager.getContext().getBitLoopGroup().next();

  register(new AbstractBinder() {
    @Override
    protected void configure() {
      bind(drillbit).to(Drillbit.class);
      bind(workManager).to(WorkManager.class);
      bind(executor).to(EventExecutor.class);
      bind(workManager.getContext().getLpPersistence().getMapper()).to(ObjectMapper.class);
      bind(workManager.getContext().getStoreProvider()).to(PersistentStoreProvider.class);
      bind(workManager.getContext().getStorage()).to(StoragePluginRegistry.class);
      bind(new UserAuthEnabled(isAuthEnabled)).to(UserAuthEnabled.class);
      if (isAuthEnabled) {
        bindFactory(DrillUserPrincipalProvider.class).to(DrillUserPrincipal.class);
        bindFactory(AuthWebUserConnectionProvider.class).to(WebUserConnection.class);
      } else {
        bindFactory(AnonDrillUserPrincipalProvider.class).to(DrillUserPrincipal.class);
        bindFactory(AnonWebUserConnectionProvider.class).to(WebUserConnection.class);
      }
    }
  });
}