use of org.infinispan.marshall.protostream.impl.SerializationContextRegistry in project infinispan by infinispan.
the class ServiceLoadSerializationContextInitializerTest method testSCILoaded.
public void testSCILoaded() throws Exception {
try (EmbeddedCacheManager cm = TestCacheManagerFactory.createCacheManager(true)) {
SerializationContextRegistry registry = TestingUtil.extractGlobalComponent(cm, SerializationContextRegistry.class);
assertTrue(registry.getUserCtx().canMarshall(ServiceLoadedClass.class));
assertFalse(registry.getGlobalCtx().canMarshall(ServiceLoadedClass.class));
assertFalse(registry.getPersistenceCtx().canMarshall(ServiceLoadedClass.class));
}
}
use of org.infinispan.marshall.protostream.impl.SerializationContextRegistry in project infinispan by infinispan.
the class CounterModuleLifecycle method cacheManagerStarting.
@Override
public void cacheManagerStarting(GlobalComponentRegistry gcr, GlobalConfiguration globalConfiguration) {
final Map<Integer, AdvancedExternalizer<?>> externalizerMap = globalConfiguration.serialization().advancedExternalizers();
// Only required by GlobalMarshaller
addAdvancedExternalizer(externalizerMap, ResetFunction.EXTERNALIZER);
addAdvancedExternalizer(externalizerMap, ReadFunction.EXTERNALIZER);
addAdvancedExternalizer(externalizerMap, InitializeCounterFunction.EXTERNALIZER);
addAdvancedExternalizer(externalizerMap, AddFunction.EXTERNALIZER);
addAdvancedExternalizer(externalizerMap, CompareAndSwapFunction.EXTERNALIZER);
addAdvancedExternalizer(externalizerMap, CreateAndCASFunction.EXTERNALIZER);
addAdvancedExternalizer(externalizerMap, CreateAndAddFunction.EXTERNALIZER);
addAdvancedExternalizer(externalizerMap, RemoveFunction.EXTERNALIZER);
BasicComponentRegistry bcr = gcr.getComponent(BasicComponentRegistry.class);
EmbeddedCacheManager cacheManager = bcr.getComponent(EmbeddedCacheManager.class).wired();
InternalCacheRegistry internalCacheRegistry = bcr.getComponent(InternalCacheRegistry.class).running();
SerializationContextRegistry ctxRegistry = gcr.getComponent(SerializationContextRegistry.class);
ctxRegistry.addContextInitializer(SerializationContextRegistry.MarshallerType.PERSISTENCE, new PersistenceContextInitializerImpl());
CounterManagerConfiguration counterManagerConfiguration = extractConfiguration(globalConfiguration);
if (gcr.getGlobalConfiguration().isClustered()) {
// only attempts to create the caches if the cache manager is clustered.
registerCounterCache(internalCacheRegistry, counterManagerConfiguration);
} else {
// local only cache manager.
registerLocalCounterCache(internalCacheRegistry);
}
registerCounterNotificationManager(bcr);
registerCounterManager(cacheManager, bcr, globalConfiguration);
}
use of org.infinispan.marshall.protostream.impl.SerializationContextRegistry in project infinispan by infinispan.
the class LifecycleCallbacks method cacheManagerStarting.
@Override
public void cacheManagerStarting(GlobalComponentRegistry gcr, GlobalConfiguration globalConfiguration) {
SerializationContextRegistry ctxRegistry = gcr.getComponent(SerializationContextRegistry.class);
PersistenceContextInitializerImpl sci = new PersistenceContextInitializerImpl();
ctxRegistry.addContextInitializer(SerializationContextRegistry.MarshallerType.PERSISTENCE, sci);
ctxRegistry.addContextInitializer(SerializationContextRegistry.MarshallerType.GLOBAL, sci);
Map<Integer, AdvancedExternalizer<?>> map = globalConfiguration.serialization().advancedExternalizers();
add(map, new SuppliedExternalizer<>(ExternalizerIds.READ_WITH_EXPIRY, ReadWithExpiry.class, ReadWithExpiry::new));
add(map, new SuppliedExternalizer<>(ExternalizerIds.GET_AND_PUT, GetAndPut.class, GetAndPut::new));
add(map, new SuppliedExternalizer<>(ExternalizerIds.GET_AND_REPLACE, GetAndReplace.class, GetAndReplace::new));
add(map, new Invoke.Externalizer());
add(map, new SuppliedExternalizer<>(ExternalizerIds.PUT, Put.class, Put::new));
add(map, new SuppliedExternalizer<>(ExternalizerIds.PUT_IF_ABSENT, PutIfAbsent.class, PutIfAbsent::new));
add(map, new SingletonExternalizer<>(ExternalizerIds.REMOVE, Remove.getInstance()));
add(map, new SuppliedExternalizer<>(ExternalizerIds.REMOVE_CONDITIONALLY, RemoveConditionally.class, RemoveConditionally::new));
add(map, new SuppliedExternalizer<>(ExternalizerIds.REPLACE, Replace.class, Replace::new));
add(map, new SingletonExternalizer<>(ExternalizerIds.GET_AND_REMOVE, GetAndRemove.getInstance()));
add(map, new ReplaceConditionally.Externalizer());
// that cannot be classloaded.
if (canLoad("javax.cache.processor.MutableEntry", MutableEntrySnapshot.Externalizer.class.getClassLoader())) {
add(map, new MutableEntrySnapshot.Externalizer());
}
gcr.getCacheManager().getClassAllowList().addClasses(DefaultCacheKey.class);
}
use of org.infinispan.marshall.protostream.impl.SerializationContextRegistry in project infinispan by infinispan.
the class LifecycleCallbacks method cacheManagerStarting.
@Override
public void cacheManagerStarting(GlobalComponentRegistry gcr, GlobalConfiguration globalConfiguration) {
SerializationContextRegistry ctxRegistry = gcr.getComponent(SerializationContextRegistry.class);
PersistenceContextInitializerImpl sci = new PersistenceContextInitializerImpl();
ctxRegistry.addContextInitializer(SerializationContextRegistry.MarshallerType.PERSISTENCE, sci);
ctxRegistry.addContextInitializer(SerializationContextRegistry.MarshallerType.GLOBAL, sci);
}
use of org.infinispan.marshall.protostream.impl.SerializationContextRegistry in project infinispan by infinispan.
the class ProtobufMetadataCachePreserveStateAcrossRestartsTest method verifySchemas.
private void verifySchemas(CacheContainer manager) {
assertFiles(manager, "A.proto", "B.proto", "C.proto", "D.proto", "E.proto", "F.proto");
assertFilesWithErrors(manager, "E.proto", "F.proto");
SerializationContextRegistry scr = extractGlobalComponent(manager, SerializationContextRegistry.class);
ImmutableSerializationContext serializationContext = scr.getUserCtx();
Descriptor mDescriptor = serializationContext.getMessageDescriptor("D.M");
assertNotNull(mDescriptor);
List<String> fields = mDescriptor.getFields().stream().map(AnnotatedDescriptorImpl::getName).collect(Collectors.toList());
assertEquals(singletonList("s"), fields);
}
Aggregations