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


Java DefaultTyping类代码示例

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


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

示例1: provisionPermissiveAccessControlEntry

import com.fasterxml.jackson.databind.ObjectMapper.DefaultTyping; //导入依赖的package包/类
protected static void provisionPermissiveAccessControlEntry(String domain, String interfaceName) throws Exception {
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.enableDefaultTypingAsProperty(DefaultTyping.JAVA_LANG_OBJECT, "_typeName");
    List<MasterAccessControlEntry> provisionedAccessControlEntries = new ArrayList<MasterAccessControlEntry>();
    String existingAccessControlEntriesJson = System.getProperty(StaticDomainAccessControlProvisioning.PROPERTY_PROVISIONED_MASTER_ACCESSCONTROLENTRIES);
    if (existingAccessControlEntriesJson != null) {
        provisionedAccessControlEntries.addAll(Arrays.asList(objectMapper.readValue(existingAccessControlEntriesJson,
                                                                                    MasterAccessControlEntry[].class)));
    }

    MasterAccessControlEntry newMasterAccessControlEntry = new MasterAccessControlEntry("*",
                                                                                        domain,
                                                                                        interfaceName,
                                                                                        TrustLevel.LOW,
                                                                                        new TrustLevel[]{ TrustLevel.LOW },
                                                                                        TrustLevel.LOW,
                                                                                        new TrustLevel[]{ TrustLevel.LOW },
                                                                                        "*",
                                                                                        Permission.YES,
                                                                                        new Permission[]{ Permission.YES });

    provisionedAccessControlEntries.add(newMasterAccessControlEntry);
    String provisionedAccessControlEntriesAsJson = objectMapper.writeValueAsString(provisionedAccessControlEntries.toArray());
    System.setProperty(StaticDomainAccessControlProvisioning.PROPERTY_PROVISIONED_MASTER_ACCESSCONTROLENTRIES,
                       provisionedAccessControlEntriesAsJson);
}
 
开发者ID:bmwcarit,项目名称:joynr,代码行数:27,代码来源:JoynrEnd2EndTest.java

示例2: getObjectMapper

import com.fasterxml.jackson.databind.ObjectMapper.DefaultTyping; //导入依赖的package包/类
private ObjectMapper getObjectMapper() {
    objectMapper = new ObjectMapper();
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    objectMapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false);
    // objectMapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS,
    // true);
    objectMapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, true);
    objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
    objectMapper.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true);

    objectMapper.enableDefaultTypingAsProperty(DefaultTyping.JAVA_LANG_OBJECT, "_typeName");
    TypeResolverBuilder<?> joynrTypeResolverBuilder = objectMapper.getSerializationConfig()
                                                                  .getDefaultTyper(SimpleType.construct(Object.class));

    SimpleModule module = new SimpleModule("NonTypedModule", new Version(1, 0, 0, "", "", ""));
    module.addSerializer(new JoynrEnumSerializer());
    module.addSerializer(new JoynrListSerializer());

    TypeDeserializer typeDeserializer = joynrTypeResolverBuilder.buildTypeDeserializer(objectMapper.getDeserializationConfig(),
                                                                                       SimpleType.construct(Object.class),
                                                                                       null);

    module.addDeserializer(Object.class, new JoynrUntypedObjectDeserializer(typeDeserializer));
    objectMapper.registerModule(module);
    return objectMapper;
}
 
开发者ID:bmwcarit,项目名称:joynr,代码行数:27,代码来源:AbstractBounceProxyServerTest.java

示例3: getObjectMapper

import com.fasterxml.jackson.databind.ObjectMapper.DefaultTyping; //导入依赖的package包/类
private ObjectMapper getObjectMapper() {
    objectMapper = new ObjectMapper();
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    objectMapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false);
    // objectMapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS,
    // true);
    objectMapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, true);
    objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
    objectMapper.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true);

    objectMapper.enableDefaultTypingAsProperty(DefaultTyping.JAVA_LANG_OBJECT, "_typeName");
    TypeResolverBuilder<?> joynrTypeResolverBuilder = objectMapper.getSerializationConfig()
                                                                  .getDefaultTyper(SimpleType.construct(Object.class));

    return objectMapper;
}
 
开发者ID:bmwcarit,项目名称:joynr,代码行数:17,代码来源:MessagingTest.java

示例4: provisionAccessControl

import com.fasterxml.jackson.databind.ObjectMapper.DefaultTyping; //导入依赖的package包/类
private static void provisionAccessControl(Properties properties, String domain) throws Exception {
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.enableDefaultTypingAsProperty(DefaultTyping.JAVA_LANG_OBJECT, "_typeName");
    MasterAccessControlEntry newMasterAccessControlEntry = new MasterAccessControlEntry("*",
                                                                                        domain,
                                                                                        ProviderAnnotations.getInterfaceName(MyGpsProvider.class),
                                                                                        TrustLevel.LOW,
                                                                                        new TrustLevel[]{ TrustLevel.LOW },
                                                                                        TrustLevel.LOW,
                                                                                        new TrustLevel[]{ TrustLevel.LOW },
                                                                                        "*",
                                                                                        Permission.YES,
                                                                                        new Permission[]{ Permission.YES });

    MasterAccessControlEntry[] provisionedAccessControlEntries = { newMasterAccessControlEntry };
    String provisionedAccessControlEntriesAsJson = objectMapper.writeValueAsString(provisionedAccessControlEntries);
    properties.setProperty(StaticDomainAccessControlProvisioning.PROPERTY_PROVISIONED_MASTER_ACCESSCONTROLENTRIES,
                           provisionedAccessControlEntriesAsJson);
}
 
开发者ID:bmwcarit,项目名称:joynr,代码行数:20,代码来源:MyGpsProviderApplication.java

示例5: provisionAccessControl

import com.fasterxml.jackson.databind.ObjectMapper.DefaultTyping; //导入依赖的package包/类
private static void provisionAccessControl(Properties properties, String domain) throws Exception {
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.enableDefaultTypingAsProperty(DefaultTyping.JAVA_LANG_OBJECT, "_typeName");
    MasterAccessControlEntry newMasterAccessControlEntry = new MasterAccessControlEntry("*",
                                                                                        domain,
                                                                                        ProviderAnnotations.getInterfaceName(MyRadioProvider.class),
                                                                                        TrustLevel.LOW,
                                                                                        new TrustLevel[]{ TrustLevel.LOW },
                                                                                        TrustLevel.LOW,
                                                                                        new TrustLevel[]{ TrustLevel.LOW },
                                                                                        "*",
                                                                                        Permission.YES,
                                                                                        new Permission[]{ Permission.YES });

    MasterAccessControlEntry[] provisionedAccessControlEntries = { newMasterAccessControlEntry };
    String provisionedAccessControlEntriesAsJson = objectMapper.writeValueAsString(provisionedAccessControlEntries);
    properties.setProperty(StaticDomainAccessControlProvisioning.PROPERTY_PROVISIONED_MASTER_ACCESSCONTROLENTRIES,
                           provisionedAccessControlEntriesAsJson);
}
 
开发者ID:bmwcarit,项目名称:joynr,代码行数:20,代码来源:MyRadioProviderApplication.java

示例6: provisionAccessControl

import com.fasterxml.jackson.databind.ObjectMapper.DefaultTyping; //导入依赖的package包/类
private static void provisionAccessControl(Properties properties, String domain) throws Exception {
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.enableDefaultTypingAsProperty(DefaultTyping.JAVA_LANG_OBJECT, "_typeName");
    MasterAccessControlEntry newMasterAccessControlEntry = new MasterAccessControlEntry("*",
                                                                                        domain,
                                                                                        ProviderAnnotations.getInterfaceName(IltProvider.class),
                                                                                        TrustLevel.LOW,
                                                                                        new TrustLevel[]{ TrustLevel.LOW },
                                                                                        TrustLevel.LOW,
                                                                                        new TrustLevel[]{ TrustLevel.LOW },
                                                                                        "*",
                                                                                        Permission.YES,
                                                                                        new Permission[]{ Permission.YES });

    MasterAccessControlEntry[] provisionedAccessControlEntries = { newMasterAccessControlEntry };
    String provisionedAccessControlEntriesAsJson = objectMapper.writeValueAsString(provisionedAccessControlEntries);
    properties.setProperty(StaticDomainAccessControlProvisioning.PROPERTY_PROVISIONED_MASTER_ACCESSCONTROLENTRIES,
                           provisionedAccessControlEntriesAsJson);
}
 
开发者ID:bmwcarit,项目名称:joynr,代码行数:20,代码来源:IltProviderApplication.java

示例7: createAppConfig

import com.fasterxml.jackson.databind.ObjectMapper.DefaultTyping; //导入依赖的package包/类
private static Properties createAppConfig() throws Exception {
    Properties appConfig = new Properties();

    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.enableDefaultTypingAsProperty(DefaultTyping.JAVA_LANG_OBJECT, "_typeName");
    MasterAccessControlEntry newMasterAccessControlEntry = new MasterAccessControlEntry("*",
                                                                                        invocationParams.getDomain(),
                                                                                        ProviderAnnotations.getInterfaceName(EchoProviderImpl.class),
                                                                                        TrustLevel.LOW,
                                                                                        new TrustLevel[]{ TrustLevel.LOW },
                                                                                        TrustLevel.LOW,
                                                                                        new TrustLevel[]{ TrustLevel.LOW },
                                                                                        "*",
                                                                                        Permission.YES,
                                                                                        new Permission[]{ Permission.YES });

    MasterAccessControlEntry[] provisionedAccessControlEntries = { newMasterAccessControlEntry };
    String provisionedAccessControlEntriesAsJson = objectMapper.writeValueAsString(provisionedAccessControlEntries);
    appConfig.setProperty(StaticDomainAccessControlProvisioning.PROPERTY_PROVISIONED_MASTER_ACCESSCONTROLENTRIES,
                          provisionedAccessControlEntriesAsJson);

    return appConfig;
}
 
开发者ID:bmwcarit,项目名称:joynr,代码行数:24,代码来源:EchoProviderApplication.java

示例8: provisionAccessControl

import com.fasterxml.jackson.databind.ObjectMapper.DefaultTyping; //导入依赖的package包/类
private static void provisionAccessControl(Properties properties, String domain) throws Exception {
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.enableDefaultTypingAsProperty(DefaultTyping.JAVA_LANG_OBJECT, "_typeName");
    MasterAccessControlEntry newMasterAccessControlEntry = new MasterAccessControlEntry("*",
                                                                                        domain,
                                                                                        ProviderAnnotations.getInterfaceName(Provider.class),
                                                                                        TrustLevel.LOW,
                                                                                        new TrustLevel[]{ TrustLevel.LOW },
                                                                                        TrustLevel.LOW,
                                                                                        new TrustLevel[]{ TrustLevel.LOW },
                                                                                        "*",
                                                                                        Permission.YES,
                                                                                        new Permission[]{ Permission.YES });

    MasterAccessControlEntry[] provisionedAccessControlEntries = { newMasterAccessControlEntry };
    String provisionedAccessControlEntriesAsJson = objectMapper.writeValueAsString(provisionedAccessControlEntries);
    properties.setProperty(StaticDomainAccessControlProvisioning.PROPERTY_PROVISIONED_MASTER_ACCESSCONTROLENTRIES,
                           provisionedAccessControlEntriesAsJson);
}
 
开发者ID:bmwcarit,项目名称:joynr,代码行数:20,代码来源:ProviderApplication.java

示例9: jsonRedisSerializer

import com.fasterxml.jackson.databind.ObjectMapper.DefaultTyping; //导入依赖的package包/类
private Jackson2JsonRedisSerializer jsonRedisSerializer(JavaType javaType)
{
    Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(javaType);
    ObjectMapper mapper = new ObjectMapper();
    mapper.enableDefaultTyping();
	mapper.enableDefaultTyping(DefaultTyping.NON_FINAL, As.PROPERTY);

	mapper.findAndRegisterModules();
    mapper.registerModule(new Jackson2HalModule());
    mapper.setHandlerInstantiator(new Jackson2HalModule.HalHandlerInstantiator(new DefaultRelProvider(), null, null));        
    jackson2JsonRedisSerializer.setObjectMapper(mapper);        
    return jackson2JsonRedisSerializer;
}
 
开发者ID:Azure,项目名称:CityPower-Build-Sample,代码行数:14,代码来源:CacheConfig.java

示例10: JsonJacksonCodec

import com.fasterxml.jackson.databind.ObjectMapper.DefaultTyping; //导入依赖的package包/类
public JsonJacksonCodec() {
    init(mapObjectMapper);
    // type info inclusion
    TypeResolverBuilder<?> mapTyper = new DefaultTypeResolverBuilder(DefaultTyping.NON_FINAL) {
        public boolean useForType(JavaType t)
        {
            switch (_appliesFor) {
            case NON_CONCRETE_AND_ARRAYS:
                while (t.isArrayType()) {
                    t = t.getContentType();
                }
                // fall through
            case OBJECT_AND_NON_CONCRETE:
                return (t.getRawClass() == Object.class) || !t.isConcrete();
            case NON_FINAL:
                while (t.isArrayType()) {
                    t = t.getContentType();
                }
                // to fix problem with wrong long to int conversion
                if (t.getRawClass() == Long.class) {
                    return true;
                }
                return !t.isFinal(); // includes Object.class
            default:
            //case JAVA_LANG_OBJECT:
                return (t.getRawClass() == Object.class);
            }
        }
    };
    mapTyper.init(JsonTypeInfo.Id.CLASS, null);
    mapTyper.inclusion(JsonTypeInfo.As.PROPERTY);
    mapObjectMapper.setDefaultTyping(mapTyper);
}
 
开发者ID:rollenholt-SourceReading,项目名称:redisson,代码行数:34,代码来源:JsonJacksonCodec.java

示例11: shouldDeserializeWithTypeInformation

import com.fasterxml.jackson.databind.ObjectMapper.DefaultTyping; //导入依赖的package包/类
@Test
public void shouldDeserializeWithTypeInformation() throws IOException {
    final ObjectMapper unit = unit(module())
            .enableDefaultTypingAsProperty(DefaultTyping.OBJECT_AND_NON_CONCRETE, "type")
            .disable(FAIL_ON_UNKNOWN_PROPERTIES);

    final String content = "{\"type\":\"org.javamoney.moneta.Money\",\"amount\":29.95,\"currency\":\"EUR\"}";
    final M amount = unit.readValue(content, type);

    // type information is ignored?!
    assertThat(amount, is(instanceOf(type)));
}
 
开发者ID:zalando,项目名称:jackson-datatype-money,代码行数:13,代码来源:MonetaryAmountDeserializerTest.java

示例12: createJsonFor

import com.fasterxml.jackson.databind.ObjectMapper.DefaultTyping; //导入依赖的package包/类
private static String createJsonFor(String directoriesUrl) throws JsonProcessingException {
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.enableDefaultTypingAsProperty(DefaultTyping.JAVA_LANG_OBJECT, "_typeName");
    setObjectMapperOnCapabilitiesUtils(objectMapper);
    String channelId = "discoverydirectory_channelid";
    String participantId = "capabilitiesdirectory_participantid";
    GlobalDiscoveryEntry discoveryEntry = CapabilityUtils.newGlobalDiscoveryEntry(new Version(0, 1),
                                                                                  "io.joynr",
                                                                                  GlobalCapabilitiesDirectory.INTERFACE_NAME,
                                                                                  participantId,
                                                                                  new ProviderQos(),
                                                                                  System.currentTimeMillis(),
                                                                                  Long.MAX_VALUE,
                                                                                  "",
                                                                                  new ChannelAddress(directoriesUrl,
                                                                                                     channelId));
    String accessParticipantId = "domainaccesscontroller_participantid";
    GlobalDiscoveryEntry accessControlEntry = CapabilityUtils.newGlobalDiscoveryEntry(new Version(0, 1),
                                                                                      "io.joynr",
                                                                                      GlobalDomainAccessController.INTERFACE_NAME,
                                                                                      accessParticipantId,
                                                                                      new ProviderQos(),
                                                                                      System.currentTimeMillis(),
                                                                                      Long.MAX_VALUE,
                                                                                      "",
                                                                                      new InProcessAddress());
    List<DiscoveryEntry> entries = new ArrayList<>();
    entries.add(discoveryEntry);
    entries.add(accessControlEntry);
    return objectMapper.writeValueAsString(entries);
}
 
开发者ID:bmwcarit,项目名称:joynr,代码行数:32,代码来源:ServersUtil.java

示例13: provisionAccessControl

import com.fasterxml.jackson.databind.ObjectMapper.DefaultTyping; //导入依赖的package包/类
private void provisionAccessControl(Properties properties, String domain, String[] interfaceNames) {
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.enableDefaultTypingAsProperty(DefaultTyping.JAVA_LANG_OBJECT, "_typeName");
    List<MasterAccessControlEntry> allEntries = new ArrayList<>();
    for (String interfaceName : interfaceNames) {
        MasterAccessControlEntry newMasterAccessControlEntry = new MasterAccessControlEntry("*",
                                                                                            domain,
                                                                                            interfaceName,
                                                                                            TrustLevel.LOW,
                                                                                            new TrustLevel[]{
                                                                                                    TrustLevel.LOW },
                                                                                            TrustLevel.LOW,
                                                                                            new TrustLevel[]{
                                                                                                    TrustLevel.LOW },
                                                                                            "*",
                                                                                            Permission.YES,
                                                                                            new Permission[]{
                                                                                                    joynr.infrastructure.DacTypes.Permission.YES });
        allEntries.add(newMasterAccessControlEntry);
    }
    MasterAccessControlEntry[] provisionedAccessControlEntries = allEntries.toArray(new MasterAccessControlEntry[allEntries.size()]);
    String provisionedAccessControlEntriesAsJson;
    try {
        provisionedAccessControlEntriesAsJson = objectMapper.writeValueAsString(provisionedAccessControlEntries);
        properties.setProperty(StaticDomainAccessControlProvisioning.PROPERTY_PROVISIONED_MASTER_ACCESSCONTROLENTRIES,
                               provisionedAccessControlEntriesAsJson);
    } catch (JsonProcessingException e) {
        LOG.error("Error parsing JSON.", e);
    }
}
 
开发者ID:bmwcarit,项目名称:joynr,代码行数:31,代码来源:DefaultJoynrRuntimeFactory.java

示例14: setUp

import com.fasterxml.jackson.databind.ObjectMapper.DefaultTyping; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    objectMapper = new ObjectMapper();
    objectMapper.enableDefaultTypingAsProperty(DefaultTyping.JAVA_LANG_OBJECT, "_typeName");
    Field objectMapperField = CapabilityUtils.class.getDeclaredField("objectMapper");
    objectMapperField.setAccessible(true);
    objectMapperField.set(CapabilityUtils.class, objectMapper);
}
 
开发者ID:bmwcarit,项目名称:joynr,代码行数:9,代码来源:StaticCapabilitiesProvisioningTest.java

示例15: setUp

import com.fasterxml.jackson.databind.ObjectMapper.DefaultTyping; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.enableDefaultTypingAsProperty(DefaultTyping.JAVA_LANG_OBJECT, "_typeName");
    Field objectMapperField = CapabilityUtils.class.getDeclaredField("objectMapper");
    objectMapperField.setAccessible(true);
    objectMapperField.set(CapabilityUtils.class, objectMapper);
}
 
开发者ID:bmwcarit,项目名称:joynr,代码行数:9,代码来源:CapabilitiesUtilsTest.java


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