/** * @param clsName Class name. * @return Type name. */ public String userTypeName(String clsName) { BinaryInternalMapper mapper = userTypeMapper(clsName); return mapper.typeName(clsName); }
/** * @param typeName Type name. * @return Type ID. */ public int typeId(String typeName) { Integer id = predefinedTypeNames.get(SIMPLE_NAME_LOWER_CASE_MAPPER.typeName(typeName)); if (id != null) return id; if (marshCtx.isSystemType(typeName)) return typeName.hashCode(); BinaryInternalMapper mapper = userTypeMapper(typeName); return mapper.typeId(typeName); }
@Override public int typeId(String clsName) { String typeName = BinaryContext.SIMPLE_NAME_LOWER_CASE_MAPPER.typeName(clsName); return typeName.toLowerCase().hashCode(); }
/** * Register "type ID to class name" mapping on all nodes to allow for mapping requests resolution form client. * Other {@link BinaryContext}'s "register" methods and method * {@link BinaryContext#descriptorForClass(Class, boolean, boolean)} already call this functionality * so use this method only when registering class names whose {@link Class} is unknown. * * @param typeId Type ID. * @param clsName Class Name. * @return {@code True} if the mapping was registered successfully. */ public boolean registerUserClassName(int typeId, String clsName) { IgniteCheckedException e = null; boolean res = false; try { res = marshCtx.registerClassName(JAVA_ID, typeId, clsName); } catch (DuplicateTypeIdException dupEx) { // Ignore if trying to register mapped type name of the already registered class name and vise versa BinaryInternalMapper mapper = userTypeMapper(typeId); String oldName = dupEx.getRegisteredClassName(); if (!(mapper.typeName(oldName).equals(clsName) || mapper.typeName(clsName).equals(oldName))) e = dupEx; } catch (IgniteCheckedException igniteEx) { e = igniteEx; } if (e != null) throw new BinaryObjectException("Failed to register class.", e); return res; }
/** * @param cls Class. * @param id Type ID. * @param affFieldName Affinity field name. * @return GridBinaryClassDescriptor. */ public BinaryClassDescriptor registerPredefinedType(Class<?> cls, int id, String affFieldName, boolean registered) { String simpleClsName = SIMPLE_NAME_LOWER_CASE_MAPPER.typeName(cls.getName()); if (id == 0) id = SIMPLE_NAME_LOWER_CASE_MAPPER.typeId(simpleClsName); BinaryClassDescriptor desc = new BinaryClassDescriptor( this, cls, false, id, simpleClsName, affFieldName, SIMPLE_NAME_LOWER_CASE_MAPPER, new BinaryReflectiveSerializer(), false, registered /* registered */ ); predefinedTypeNames.put(simpleClsName, id); predefinedTypes.put(id, desc); descByCls.put(cls, desc); if (affFieldName != null) affKeyFieldNames.putIfAbsent(id, affFieldName); return desc; }
String typeName = mapper.typeName(clsName);
final String typeName = mapper.typeName(clsName);
/** * @param clsName Class name. * @return Type name. */ public String userTypeName(String clsName) { BinaryInternalMapper mapper = userTypeMapper(clsName); return mapper.typeName(clsName); }
/** * @param typeName Type name. * @return Type ID. */ public int typeId(String typeName) { Integer id = predefinedTypeNames.get(SIMPLE_NAME_LOWER_CASE_MAPPER.typeName(typeName)); if (id != null) return id; if (marshCtx.isSystemType(typeName)) return typeName.hashCode(); BinaryInternalMapper mapper = userTypeMapper(typeName); return mapper.typeId(typeName); }
/** * Register "type ID to class name" mapping on all nodes to allow for mapping requests resolution form client. * Other {@link BinaryContext}'s "register" methods and method * {@link BinaryContext#descriptorForClass(Class, boolean, boolean)} already call this functionality * so use this method only when registering class names whose {@link Class} is unknown. * * @param typeId Type ID. * @param clsName Class Name. * @return {@code True} if the mapping was registered successfully. */ public boolean registerUserClassName(int typeId, String clsName) { IgniteCheckedException e = null; boolean res = false; try { res = marshCtx.registerClassName(JAVA_ID, typeId, clsName); } catch (DuplicateTypeIdException dupEx) { // Ignore if trying to register mapped type name of the already registered class name and vise versa BinaryInternalMapper mapper = userTypeMapper(typeId); String oldName = dupEx.getRegisteredClassName(); if (!(mapper.typeName(oldName).equals(clsName) || mapper.typeName(clsName).equals(oldName))) e = dupEx; } catch (IgniteCheckedException igniteEx) { e = igniteEx; } if (e != null) throw new BinaryObjectException("Failed to register class.", e); return res; }
/** * @param cls Class. * @param id Type ID. * @param affFieldName Affinity field name. * @return GridBinaryClassDescriptor. */ public BinaryClassDescriptor registerPredefinedType(Class<?> cls, int id, String affFieldName, boolean registered) { String simpleClsName = SIMPLE_NAME_LOWER_CASE_MAPPER.typeName(cls.getName()); if (id == 0) id = SIMPLE_NAME_LOWER_CASE_MAPPER.typeId(simpleClsName); BinaryClassDescriptor desc = new BinaryClassDescriptor( this, cls, false, id, simpleClsName, affFieldName, SIMPLE_NAME_LOWER_CASE_MAPPER, new BinaryReflectiveSerializer(), false, registered /* registered */ ); predefinedTypeNames.put(simpleClsName, id); predefinedTypes.put(id, desc); descByCls.put(cls, desc); if (affFieldName != null) affKeyFieldNames.putIfAbsent(id, affFieldName); return desc; }
String typeName = mapper.typeName(clsName);
final String typeName = mapper.typeName(clsName);