当前位置: 首页>>代码示例>>Java>>正文


Java InjectableValues类代码示例

本文整理汇总了Java中com.fasterxml.jackson.databind.InjectableValues的典型用法代码示例。如果您正苦于以下问题:Java InjectableValues类的具体用法?Java InjectableValues怎么用?Java InjectableValues使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


InjectableValues类属于com.fasterxml.jackson.databind包,在下文中一共展示了InjectableValues类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getXmlMapper

import com.fasterxml.jackson.databind.InjectableValues; //导入依赖的package包/类
protected XmlMapper getXmlMapper() {
    final XmlMapper xmlMapper = new XmlMapper(
            new XmlFactory(new InputFactoryImpl(), new OutputFactoryImpl()), new JacksonXmlModule());
    xmlMapper.setInjectableValues(new InjectableValues.Std().addValue(ODataClient.class, client));
    xmlMapper.addHandler(new DeserializationProblemHandler() {

        @Override
        public boolean handleUnknownProperty(final DeserializationContext ctxt, final JsonParser jp,
                final JsonDeserializer<?> deserializer, final Object beanOrClass, final String propertyName)
                throws IOException, JsonProcessingException {

            // skip any unknown property
            LOG.warn("Skipping unknown property {}", propertyName);
            ctxt.getParser().skipChildren();
            return true;
        }
    });
    return xmlMapper;
}
 
开发者ID:ashank,项目名称:Office-365-SDK-for-Android,代码行数:20,代码来源:AbstractODataDeserializer.java

示例2: getXmlMapper

import com.fasterxml.jackson.databind.InjectableValues; //导入依赖的package包/类
protected XmlMapper getXmlMapper() {
  final XmlMapper xmlMapper = new XmlMapper(
      new XmlFactory(new InputFactoryImpl(), new OutputFactoryImpl()), new JacksonXmlModule());

  xmlMapper.setInjectableValues(new InjectableValues.Std().addValue(Boolean.class, Boolean.FALSE));

  xmlMapper.addHandler(new DeserializationProblemHandler() {
    @Override
    public boolean handleUnknownProperty(final DeserializationContext ctxt, final JsonParser jp,
        final com.fasterxml.jackson.databind.JsonDeserializer<?> deserializer,
        final Object beanOrClass, final String propertyName)
        throws IOException, JsonProcessingException {

      // skip any unknown property
      ctxt.getParser().skipChildren();
      return true;
    }
  });
  return xmlMapper;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:21,代码来源:ClientODataDeserializerImpl.java

示例3: PhysicalPlanReader

import com.fasterxml.jackson.databind.InjectableValues; //导入依赖的package包/类
public PhysicalPlanReader(DrillConfig config, ObjectMapper mapper, final DrillbitEndpoint endpoint,
                          final StoragePluginRegistry pluginRegistry) {

  // Endpoint serializer/deserializer.
  SimpleModule deserModule = new SimpleModule("PhysicalOperatorModule") //
      .addSerializer(DrillbitEndpoint.class, new DrillbitEndpointSerDe.Se()) //
      .addDeserializer(DrillbitEndpoint.class, new DrillbitEndpointSerDe.De()) //
      .addSerializer(MajorType.class, new MajorTypeSerDe.Se())
      .addDeserializer(MajorType.class, new MajorTypeSerDe.De());


  mapper.registerModule(deserModule);
  mapper.registerSubtypes(PhysicalOperatorUtil.getSubTypes(config));
  InjectableValues injectables = new InjectableValues.Std() //
          .addValue(StoragePluginRegistry.class, pluginRegistry) //
      .addValue(DrillbitEndpoint.class, endpoint); //

  this.mapper = mapper;
  this.physicalPlanReader = mapper.reader(PhysicalPlan.class).with(injectables);
  this.operatorReader = mapper.reader(PhysicalOperator.class).with(injectables);
  this.logicalPlanReader = mapper.reader(LogicalPlan.class).with(injectables);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:23,代码来源:PhysicalPlanReader.java

示例4: initialize

import com.fasterxml.jackson.databind.InjectableValues; //导入依赖的package包/类
@Override
public void initialize(Bootstrap<?> bootstrap)
{
    final InjectableValues injectableValues = new InjectableValues()
    {
        @Override
        public Object findInjectableValue(Object valueId, DeserializationContext ctxt, BeanProperty forProperty, Object beanInstance)
        {
            return null;
        }
    };
    final ConfigurationFactoryFactory<? extends Configuration> configurationFactoryFactory = bootstrap.getConfigurationFactoryFactory();
    ConfigurationFactoryFactory factoryFactory = new ConfigurationFactoryFactory()
    {
        @Override
        public ConfigurationFactory create(Class klass, Validator validator, ObjectMapper objectMapper, String propertyPrefix)
        {
            objectMapper.setInjectableValues(injectableValues);
            //noinspection unchecked
            return configurationFactoryFactory.create(klass, validator, objectMapper, propertyPrefix);
        }
    };
    //noinspection unchecked
    bootstrap.setConfigurationFactoryFactory(factoryFactory);
}
 
开发者ID:soabase,项目名称:soabase,代码行数:26,代码来源:GuiceBundle.java

示例5: jacksonObjectMapper

import com.fasterxml.jackson.databind.InjectableValues; //导入依赖的package包/类
@SuppressWarnings("SpringJavaAutowiringInspection")
@Bean
@Autowired
@Primary
public ObjectMapper jacksonObjectMapper(
        final Jackson2ObjectMapperBuilder builder,
        final AuthenticationInformationRetriever<?, ?> authenticationInformationRetriever
) {
    final ObjectMapper mapper = builder
            .createXmlMapper(false)
            .mixIn(Authentication.class, IdolAuthenticationMixins.class)
            .mixIn(Widget.class, WidgetMixins.class)
            .mixIn(WidgetDatasource.class, WidgetDatasourceMixins.class)
            .mixIn(QueryRestrictions.class, IdolQueryRestrictionsMixin.class)
            .mixIn(IdolQueryRestrictions.class, IdolQueryRestrictionsMixin.class)
            .featuresToEnable(SerializationFeature.INDENT_OUTPUT)
            .build();

    mapper.setInjectableValues(new InjectableValues.Std().addValue(AuthenticationInformationRetriever.class, authenticationInformationRetriever));

    return mapper;
}
 
开发者ID:hpe-idol,项目名称:find,代码行数:23,代码来源:IdolConfiguration.java

示例6: shouldLoadConfigWithIPv6

import com.fasterxml.jackson.databind.InjectableValues; //导入依赖的package包/类
@Test
public void shouldLoadConfigWithIPv6() throws Exception {
    assumeFalse(NetworkAddress.FORCE_IPV4);

    String raw = Resources.read("memcached_with_ipv6.json", getClass());
    InjectableValues inject = new InjectableValues.Std()
            .addValue("env", environment);
    MemcachedBucketConfig config = JSON_MAPPER.readerFor(MemcachedBucketConfig.class).with(inject).readValue(raw);

    assertEquals(2, config.nodes().size());
    for (Map.Entry<Long, NodeInfo> node : config.ketamaNodes().entrySet()) {
        String hostname = node.getValue().hostname().address();
        assertTrue(hostname.equals("fd63:6f75:6368:2068:1471:75ff:fe25:a8be")
            || hostname.equals("fd63:6f75:6368:2068:c490:b5ff:fe86:9cf7"));
        assertTrue(node.getValue().services().containsKey(ServiceType.BINARY));
    }
}
 
开发者ID:couchbase,项目名称:couchbase-jvm-core,代码行数:18,代码来源:DefaultMemcachedBucketConfigTest.java

示例7: main

import com.fasterxml.jackson.databind.InjectableValues; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
  final Nexus nexus = new Nexus();
  ObjectMapper mapper = new XmlMapper();
  mapper.setInjectableValues(new InjectableValues() {
    @Override
    public Object findInjectableValue(Object valueId, DeserializationContext ctxt, BeanProperty forProperty,
        Object beanInstance) {
      if (Nexus.class.getName().equals(valueId)) {
        return nexus;
      }
      return null;
    }
  });
  File src = new File(args[0]).getCanonicalFile();
  System.out.format("Using test configuration %s\n", src);
  PerformanceTest test = mapper.readValue(src, PerformanceTest.class);
  test.run();
  System.out.println("Exit");
  System.exit(0);
}
 
开发者ID:sonatype,项目名称:nexus-perf,代码行数:21,代码来源:PerformanceTestRunner.java

示例8: handleResponse

import com.fasterxml.jackson.databind.InjectableValues; //导入依赖的package包/类
private <T> T handleResponse(CloseableHttpResponse response, URL url, Class<T> cls)
        throws GeoIp2Exception, IOException {
    int status = response.getStatusLine().getStatusCode();
    if (status >= 400 && status < 500) {
        this.handle4xxStatus(response, url);
    } else if (status >= 500 && status < 600) {
        throw new HttpException("Received a server error (" + status
                + ") for " + url, status, url);
    } else if (status != 200) {
        throw new HttpException("Received an unexpected HTTP status ("
                + status + ") for " + url, status, url);
    }

    InjectableValues inject = new JsonInjector(locales, null);

    HttpEntity entity = response.getEntity();
    try {
        return mapper.readerFor(cls).with(inject).readValue(entity.getContent());
    } catch (IOException e) {
        throw new GeoIp2Exception(
                "Received a 200 response but could not decode it as JSON", e);
    } finally {
        EntityUtils.consume(entity);
    }
}
 
开发者ID:maxmind,项目名称:GeoIP2-java,代码行数:26,代码来源:WebServiceClient.java

示例9: getObjectMapperInstance

import com.fasterxml.jackson.databind.InjectableValues; //导入依赖的package包/类
/**
 * Get the standard {@link ObjectMapper} instance used for parsing {@code index-v1.json}.
 * This ignores unknown properties so that old releases won't crash when new things are
 * added to {@code index-v1.json}.  This is required for both forward compatibility,
 * but also because ignoring such properties when coming from a malicious server seems
 * reasonable anyway.
 */
public static ObjectMapper getObjectMapperInstance(long repoId) {
    ObjectMapper mapper = new ObjectMapper();
    mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
    mapper.setInjectableValues(new InjectableValues.Std().addValue("repoId", repoId));
    mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE);
    mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.PUBLIC_ONLY);
    return mapper;
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:16,代码来源:IndexV1Updater.java

示例10: PhysicalPlanReader

import com.fasterxml.jackson.databind.InjectableValues; //导入依赖的package包/类
public PhysicalPlanReader(SabotConfig config, ScanResult scanResult, LogicalPlanPersistence lpPersistance, final NodeEndpoint endpoint,
                          final StoragePluginRegistry pluginRegistry, SabotContext context) {

  this.lpPersistance = lpPersistance;
  // Endpoint serializer/deserializer.
  final SimpleModule deserModule = new SimpleModule("PhysicalOperatorModule")
      .addSerializer(NodeEndpoint.class, new NodeEndpointSerDe.Se())
      .addDeserializer(NodeEndpoint.class, new NodeEndpointSerDe.De())
      .addSerializer(MajorType.class, new MajorTypeSerDe.Se())
      .addSerializer(ByteString.class, new ByteStringSer())
      .addDeserializer(ByteString.class, new ByteStringDeser())
      .addDeserializer(MajorType.class, new MajorTypeSerDe.De());



  final ObjectMapper lpMapper = lpPersistance.getMapper();
  lpMapper.registerModule(deserModule);
  Set<Class<? extends PhysicalOperator>> subTypes = PhysicalOperatorUtil.getSubTypes(scanResult);
  for (Class<? extends PhysicalOperator> subType : subTypes) {
    lpMapper.registerSubtypes(subType);
  }
  final InjectableValues injectables = new InjectableValues.Std()
      .addValue(StoragePluginRegistry.class, pluginRegistry)
      .addValue(SabotContext.class, context)
      .addValue(NodeEndpoint.class, endpoint);

  this.mapper = lpMapper;
  this.physicalPlanReader = mapper.readerFor(PhysicalPlan.class).with(injectables);
  this.optionListReader = mapper.readerFor(OptionList.class).with(injectables);
  this.operatorReader = mapper.readerFor(PhysicalOperator.class).with(injectables);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:32,代码来源:PhysicalPlanReader.java

示例11: check

import com.fasterxml.jackson.databind.InjectableValues; //导入依赖的package包/类
private <X> X check(final InputStream stream, final Class<X> type)
    throws IOException,
    JsonParseException,
    JsonMappingException,
    JsonProcessingException {
  final InjectableValues.Std injectableValues = new InjectableValues.Std();
  for (final String key : this.injectionValues.keySet()) {
    injectableValues.addValue(key, this.injectionValues.get(key));
  }
  return this.mapper.readerFor(type).with(injectableValues).readValue(stream);
}
 
开发者ID:AndreasWBartels,项目名称:libraries,代码行数:12,代码来源:AbstractJsonUnmarshaller.java

示例12: read

import com.fasterxml.jackson.databind.InjectableValues; //导入依赖的package包/类
private <X> X read(final InputStream stream, final Class<X> type)
    throws IOException,
    JsonParseException,
    JsonMappingException,
    JsonProcessingException {
  final InjectableValues.Std injectableValues = new InjectableValues.Std();
  for (final String key : this.injectionValues.keySet()) {
    injectableValues.addValue(key, this.injectionValues.get(key));
  }
  return this.mapper.readerFor(type).with(injectableValues).readValue(stream);
}
 
开发者ID:AndreasWBartels,项目名称:libraries,代码行数:12,代码来源:AbstractJsonObjectUnmarshaller.java

示例13: from

import com.fasterxml.jackson.databind.InjectableValues; //导入依赖的package包/类
/**
 * Reads config from a location
 *
 * @param location location of config
 * @return this
 * @throws IOException
 */
public ConfigBuilder from(URI location) throws IOException {
	InjectableValues inject = new InjectableValues.Std()
			.addValue("location", location);
	addConfig(new ObjectMapper().configure(JsonParser.Feature.ALLOW_COMMENTS, true)
			.setInjectableValues(inject).readValue(location.toURL(), Config.class));
	return this;
}
 
开发者ID:turn,项目名称:camino,代码行数:15,代码来源:ConfigBuilder.java

示例14: applyInternal

import com.fasterxml.jackson.databind.InjectableValues; //导入依赖的package包/类
private static LineMessagingException applyInternal(final String requestId, final Response<?> response)
        throws IOException {
    final int code = response.code();
    final ResponseBody responseBody = response.errorBody();

    final ErrorResponse errorResponse = OBJECT_READER
            .with(new InjectableValues.Std(singletonMap("requestId", requestId)))
            .readValue(responseBody.byteStream());

    switch (code) {
        case 400:
            return new BadRequestException(
                    errorResponse.getMessage(), errorResponse);
        case 401:
            return new UnauthorizedException(
                    errorResponse.getMessage(), errorResponse);
        case 403:
            return new ForbiddenException(
                    errorResponse.getMessage(), errorResponse);
        case 404:
            return new NotFoundException(
                    errorResponse.getMessage(), errorResponse);
        case 429:
            return new TooManyRequestsException(
                    errorResponse.getMessage(), errorResponse);
        case 500:
            return new LineServerException(
                    errorResponse.getMessage(), errorResponse);
    }

    return new GeneralLineMessagingException(errorResponse.getMessage(), errorResponse, null);
}
 
开发者ID:line,项目名称:line-bot-sdk-java,代码行数:33,代码来源:ExceptionConverter.java

示例15: PhysicalPlanReader

import com.fasterxml.jackson.databind.InjectableValues; //导入依赖的package包/类
public PhysicalPlanReader(DrillConfig config, ScanResult scanResult, LogicalPlanPersistence lpPersistance, final DrillbitEndpoint endpoint,
                          final StoragePluginRegistry pluginRegistry) {

  ObjectMapper lpMapper = lpPersistance.getMapper();

  // Endpoint serializer/deserializer.
  SimpleModule deserModule = new SimpleModule("PhysicalOperatorModule") //
      .addSerializer(DrillbitEndpoint.class, new DrillbitEndpointSerDe.Se()) //
      .addDeserializer(DrillbitEndpoint.class, new DrillbitEndpointSerDe.De()) //
      .addSerializer(MajorType.class, new MajorTypeSerDe.Se())
      .addDeserializer(MajorType.class, new MajorTypeSerDe.De())
      .addDeserializer(DynamicPojoRecordReader.class,
          new StdDelegatingDeserializer<>(new DynamicPojoRecordReader.Converter(lpMapper)));

  lpMapper.registerModule(deserModule);
  Set<Class<? extends PhysicalOperator>> subTypes = PhysicalOperatorUtil.getSubTypes(scanResult);
  for (Class<? extends PhysicalOperator> subType : subTypes) {
    lpMapper.registerSubtypes(subType);
  }
  lpMapper.registerSubtypes(DynamicPojoRecordReader.class);
  InjectableValues injectables = new InjectableValues.Std() //
          .addValue(StoragePluginRegistry.class, pluginRegistry) //
      .addValue(DrillbitEndpoint.class, endpoint); //

  this.mapper = lpMapper;
  this.physicalPlanReader = mapper.reader(PhysicalPlan.class).with(injectables);
  this.operatorReader = mapper.reader(PhysicalOperator.class).with(injectables);
  this.logicalPlanReader = mapper.reader(LogicalPlan.class).with(injectables);
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:30,代码来源:PhysicalPlanReader.java


注:本文中的com.fasterxml.jackson.databind.InjectableValues类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。