use of org.infinispan.protostream.types.java.CommonTypesSchema in project infinispan by infinispan.
the class SerializationContextRegistryImpl method start.
@Start
public void start() {
user.addContextInitializer(new CommonTypesSchema());
user.addContextInitializer(new CommonContainerTypesSchema());
user.addContextInitializer(new UserContextInitializerImpl());
// Add user configured SCIs
Collection<SerializationContextInitializer> initializers = globalConfig.serialization().contextInitializers();
if (initializers == null || initializers.isEmpty()) {
// If no SCIs have been explicitly configured, then load all available SCI services
initializers = ServiceFinder.load(SerializationContextInitializer.class, globalConfig.classLoader());
}
initializers.forEach(user::addContextInitializer);
String messageName = PersistenceContextInitializer.getFqTypeName(MarshallableUserObject.class);
BaseMarshaller userObjectMarshaller = new MarshallableUserObject.Marshaller(messageName, userMarshaller.wired());
update(GLOBAL, ctx -> ctx.addContextInitializer(new PersistenceContextInitializerImpl()).addContextInitializer(new org.infinispan.commons.GlobalContextInitializerImpl()).addMarshaller(userObjectMarshaller));
update(PERSISTENCE, ctx -> ctx.addContextInitializer(new PersistenceContextInitializerImpl()).addMarshaller(userObjectMarshaller));
}
use of org.infinispan.protostream.types.java.CommonTypesSchema in project infinispan by infinispan.
the class ProtoStreamBackwardsCompatibilityTest method testOldEventLoggerUUIDBytesAreReadable.
public void testOldEventLoggerUUIDBytesAreReadable() throws IOException {
// Initialize SerializationContext like it used to be in the server
SerializationContext oldServerCtx = ProtobufUtil.newSerializationContext();
PersistenceContextManualInitializer serverInitializer = new PersistenceContextManualInitializer();
serverInitializer.registerSchema(oldServerCtx);
serverInitializer.registerMarshallers(oldServerCtx);
// Initialise SerializationContext using the new core initializer
SerializationContext coreCtx = ProtobufUtil.newSerializationContext();
CommonTypesSchema sci = new CommonTypesSchema();
sci.registerSchema(coreCtx);
sci.registerMarshallers(coreCtx);
UUID uuid = Util.threadLocalRandomUUID();
byte[] oldBytes = ProtobufUtil.toWrappedByteArray(oldServerCtx, uuid);
UUID unmarshalled = ProtobufUtil.fromWrappedByteArray(coreCtx, oldBytes);
assertEquals(uuid, unmarshalled);
byte[] newBytes = ProtobufUtil.toWrappedByteArray(coreCtx, uuid);
unmarshalled = ProtobufUtil.fromWrappedByteArray(coreCtx, newBytes);
assertEquals(uuid, unmarshalled);
}
Aggregations