Java Code Examples for io.github.bucket4j.Bucket4j#getSerializationHandles()
The following examples show how to use
io.github.bucket4j.Bucket4j#getSerializationHandles() .
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: Bucket4jProtobufContextInitializer.java From bucket4j with Apache License 2.0 | 5 votes |
@Override public void registerSchema(SerializationContext serCtx) { StringBuilder protoBuilder = new StringBuilder(FOOTER); for (SerializationHandle<?> serializationHandle : Bucket4j.getSerializationHandles()) { String typeName = "Bucket4jType_" + serializationHandle.getTypeId(); String typeDefinition = TYPE_TEMPLATE.replace("[type_name]", typeName); protoBuilder.append(typeDefinition); } String generatedProtoFile = protoBuilder.toString(); FileDescriptorSource protoSource = FileDescriptorSource.fromString(getProtoFileName(), generatedProtoFile); serCtx.registerProtoFiles(protoSource); }
Example 2
Source File: Bucket4jProtobufContextInitializer.java From bucket4j with Apache License 2.0 | 5 votes |
@Override public void registerMarshallers(SerializationContext serCtx) { for (SerializationHandle<?> serializationHandle : Bucket4j.getSerializationHandles()) { String protoTypeId = "bucket4j.Bucket4jType_" + serializationHandle.getTypeId(); serCtx.registerMarshaller(new ProtobufMessageMarshaller<>(serializationHandle, protoTypeId)); } }
Example 3
Source File: InfinispanSerializerTest.java From bucket4j with Apache License 2.0 | 5 votes |
@Before public void setup() { for (SerializationHandle<?> serializationHandle : Bucket4j.getSerializationHandles()) { String protoTypeId = "bucket4j.Bucket4jType_" + serializationHandle.getTypeId(); serializerByClass.put(serializationHandle.getSerializedType(), new ProtobufMessageMarshaller<>(serializationHandle, protoTypeId)); } }
Example 4
Source File: HazelcastSerializer.java From bucket4j with Apache License 2.0 | 3 votes |
/** * Returns the list custom Hazelcast serializers for all classes from Bucket4j library which can be transferred over network. * Each serializer will have different typeId, and this id will not be changed in the feature releases. * * <p> * <strong>Note:</strong> it would be better to leave an empty space in the Ids in order to handle the extension of Bucket4j library when new classes can be added to library. * For example if you called {@code getAllSerializers(10000)} then it would be reasonable to avoid registering your custom types in the interval 10000-10100. * </p> * * @param typeIdBase a starting number from for typeId sequence * * @return */ public static List<HazelcastSerializer<?>> getAllSerializers(final int typeIdBase) { List<HazelcastSerializer<?>> serializers = new ArrayList<>(); for (SerializationHandle<?> serializationHandle : Bucket4j.getSerializationHandles()) { serializers.add(new HazelcastSerializer<>(serializationHandle.getTypeId() + typeIdBase, serializationHandle)); } return serializers; }
Example 5
Source File: HazelcastSerializer.java From bucket4j with Apache License 2.0 | 3 votes |
/** * Returns the list custom Hazelcast serializers for all classes from Bucket4j library which can be transferred over network. * Each serializer will have different typeId, and this id will not be changed in the feature releases. * * <p> * <strong>Note:</strong> it would be better to leave an empty space in the Ids in order to handle the extension of Bucket4j library when new classes can be added to library. * For example if you called {@code getAllSerializers(10000)} then it would be reasonable to avoid registering your custom types in the interval 10000-10100. * </p> * * @param typeIdBase a starting number from for typeId sequence * * @return */ public static List<HazelcastSerializer<?>> getAllSerializers(final int typeIdBase) { List<HazelcastSerializer<?>> serializers = new ArrayList<>(); for (SerializationHandle<?> serializationHandle : Bucket4j.getSerializationHandles()) { serializers.add(new HazelcastSerializer<>(serializationHandle.getTypeId() + typeIdBase, serializationHandle)); } return serializers; }