Search in sources :

Example 6 with BinaryNameMapper

use of org.apache.ignite.binary.BinaryNameMapper in project ignite by apache.

the class GridBinaryWildcardsSelfTest method checkOverrideNameMapper.

/**
     *
     * @param nameMapper Name mapper.
     * @param mapper Mapper.
     * @throws IgniteCheckedException If failed.
     */
private void checkOverrideNameMapper(BinaryNameMapper nameMapper, BinaryIdMapper mapper) throws IgniteCheckedException {
    BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration();
    typeCfg.setTypeName(CLASS2_FULL_NAME);
    typeCfg.setNameMapper(new BinaryNameMapper() {

        @Override
        public String typeName(String clsName) {
            return "type2";
        }

        @Override
        public String fieldName(String fieldName) {
            return "field2";
        }
    });
    BinaryMarshaller marsh = binaryMarshaller(nameMapper, mapper, Arrays.asList(new BinaryTypeConfiguration("org.apache.ignite.internal.binary.test.*"), typeCfg));
    BinaryContext ctx = binaryContext(marsh);
    ConcurrentMap<Integer, BinaryInternalMapper> types = U.field(ctx, "typeId2Mapper");
    assertEquals(3, types.size());
    assertTrue(types.containsKey(typeId(CLASS1_FULL_NAME, nameMapper, mapper)));
    assertTrue(types.containsKey(typeId(INNER_CLASS_FULL_NAME, nameMapper, mapper)));
    assertTrue(types.containsKey("type2".hashCode()));
    Map<String, org.apache.ignite.internal.binary.BinaryInternalMapper> typeMappers = U.field(ctx, "cls2Mappers");
    assertEquals("type2", typeMappers.get(CLASS2_FULL_NAME).nameMapper().typeName(CLASS2_FULL_NAME));
}
Also used : BinaryTypeConfiguration(org.apache.ignite.binary.BinaryTypeConfiguration) BinaryNameMapper(org.apache.ignite.binary.BinaryNameMapper)

Aggregations

BinaryNameMapper (org.apache.ignite.binary.BinaryNameMapper)6 BinaryIdMapper (org.apache.ignite.binary.BinaryIdMapper)4 BinaryTypeConfiguration (org.apache.ignite.binary.BinaryTypeConfiguration)3 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 IgniteCache (org.apache.ignite.IgniteCache)1 IgniteException (org.apache.ignite.IgniteException)1 BinaryBasicIdMapper (org.apache.ignite.binary.BinaryBasicIdMapper)1 BinaryBasicNameMapper (org.apache.ignite.binary.BinaryBasicNameMapper)1 BinaryObject (org.apache.ignite.binary.BinaryObject)1 BinaryObjectException (org.apache.ignite.binary.BinaryObjectException)1 BinarySerializer (org.apache.ignite.binary.BinarySerializer)1 CacheKeyConfiguration (org.apache.ignite.cache.CacheKeyConfiguration)1 BinaryConfiguration (org.apache.ignite.configuration.BinaryConfiguration)1 PlatformConfiguration (org.apache.ignite.configuration.PlatformConfiguration)1 BinaryMarshaller (org.apache.ignite.internal.binary.BinaryMarshaller)1 IgfsFileMap (org.apache.ignite.internal.processors.igfs.IgfsFileMap)1