use of org.infinispan.client.hotrod.impl.MarshallerRegistry in project infinispan by infinispan.
the class MarshallerPerCacheTest method testMarshallerPerCache.
@Test
public void testMarshallerPerCache() throws IOException, InterruptedException {
MarshallerRegistry marshallerRegistry = remoteCacheManager.getMarshallerRegistry();
assertMarshallerUsed(CACHE_DEFAULT, marshallerRegistry.getMarshaller(APPLICATION_PROTOSTREAM));
assertMarshallerUsed(CACHE_TEXT, new CustomValueMarshaller());
assertMarshallerUsed(CACHE_JAVA_SERIALIZED, marshallerRegistry.getMarshaller(APPLICATION_SERIALIZED_OBJECT));
}
use of org.infinispan.client.hotrod.impl.MarshallerRegistry in project infinispan by infinispan.
the class SpringRemoteCacheManager method configureMarshallers.
private void configureMarshallers(RemoteCacheManager nativeCacheManager) {
MarshallerRegistry marshallerRegistry = nativeCacheManager.getMarshallerRegistry();
// Java serialization support
JavaSerializationMarshaller serializationMarshaller = (JavaSerializationMarshaller) marshallerRegistry.getMarshaller(MediaType.APPLICATION_SERIALIZED_OBJECT);
if (serializationMarshaller == null) {
// Register a JavaSerializationMarshaller if it doesn't exist yet
// Because some session attributes are always marshalled with Java serialization
serializationMarshaller = new JavaSerializationMarshaller();
marshallerRegistry.registerMarshaller(serializationMarshaller);
}
// Extend deserialization allow list
ClassAllowList serializationAllowList = new ClassAllowList();
serializationAllowList.addClasses(NullValue.class);
serializationAllowList.addRegexps("java.util\\..*", "org.springframework\\..*");
serializationMarshaller.initialize(serializationAllowList);
// Protostream support
ProtoStreamMarshaller protoMarshaller = (ProtoStreamMarshaller) marshallerRegistry.getMarshaller(MediaType.APPLICATION_PROTOSTREAM);
if (protoMarshaller == null) {
try {
protoMarshaller = new ProtoStreamMarshaller();
marshallerRegistry.registerMarshaller(protoMarshaller);
// Apply the serialization context initializers in the configuration first
SerializationContext ctx = protoMarshaller.getSerializationContext();
for (SerializationContextInitializer sci : nativeCacheManager.getConfiguration().getContextInitializers()) {
sci.registerSchema(ctx);
sci.registerMarshallers(ctx);
}
} catch (NoClassDefFoundError e) {
// Ignore the error, the protostream dependency is missing
}
}
if (protoMarshaller != null) {
// Apply our own serialization context initializers
SerializationContext ctx = protoMarshaller.getSerializationContext();
addSessionContextInitializerAndMarshaller(ctx, serializationMarshaller);
}
}
Aggregations