use of org.infinispan.protostream.BaseMarshaller in project indy by Commonjava.
the class MetadataCacheProducer method mavenMetadataCacheCfg.
@MavenMetadataCache
@Produces
@ApplicationScoped
public BasicCacheHandle<MetadataKey, MetadataInfo> mavenMetadataCacheCfg() {
if (remoteConfiguration.isEnabled()) {
List<BaseMarshaller> infoMarshallers = new ArrayList<>();
infoMarshallers.add(new MetadataInfoMarshaller());
infoMarshallers.add(new MetadataMarshaller());
infoMarshallers.add(new VersioningMarshaller());
infoMarshallers.add(new SnapshotMarshaller());
infoMarshallers.add(new SnapshotVersionMarshaller());
infoMarshallers.add(new VersioningMarshaller());
cacheProducer.registerProtoAndMarshallers("metadata_info.proto", infoMarshallers);
List<BaseMarshaller> keyMarshallers = new ArrayList<>();
keyMarshallers.add(new MetadataKeyMarshaller());
keyMarshallers.add(new StoreKeyMarshaller());
keyMarshallers.add(new StoreTypeMarshaller());
cacheProducer.registerProtoAndMarshallers("metadata_key.proto", keyMarshallers);
}
return cacheProducer.getBasicCache(METADATA_CACHE);
}
use of org.infinispan.protostream.BaseMarshaller in project indy by Commonjava.
the class MetadataCacheProducer method mavenMetadataKeyCacheCfg.
@MavenMetadataKeyCache
@Produces
@ApplicationScoped
public BasicCacheHandle<MetadataKey, MetadataKey> mavenMetadataKeyCacheCfg() {
if (remoteConfiguration.isEnabled()) {
List<BaseMarshaller> keyMarshallers = new ArrayList<>();
keyMarshallers.add(new MetadataKeyMarshaller());
keyMarshallers.add(new StoreKeyMarshaller());
keyMarshallers.add(new StoreTypeMarshaller());
cacheProducer.registerProtoAndMarshallers("metadata_key.proto", keyMarshallers);
}
BasicCacheHandle<MetadataKey, MetadataKey> handler = cacheProducer.getBasicCache(METADATA_KEY_CACHE);
registerTransformer(handler);
return handler;
}
use of org.infinispan.protostream.BaseMarshaller in project indy by Commonjava.
the class CacheProducer method registerProtoAndMarshallers.
public synchronized void registerProtoAndMarshallers(String protofile, List<BaseMarshaller> marshallers) {
SerializationContext ctx = ProtoStreamMarshaller.getSerializationContext(remoteCacheManager);
try {
ctx.registerProtoFiles(FileDescriptorSource.fromResources(protofile));
} catch (IOException e) {
throw new RuntimeException("Register proto files error, protofile: " + protofile, e);
}
for (BaseMarshaller marshaller : marshallers) {
try {
ctx.registerMarshaller(marshaller);
} catch (Exception e) {
throw new RuntimeException("Register the marshallers error.", e);
}
}
// Retrieve metadata cache and register the new schema on the infinispan server too
RemoteCache<String, String> metadataCache = remoteCacheManager.getCache(PROTOBUF_METADATA_CACHE_NAME);
metadataCache.put(protofile, FileDescriptorSource.getResourceAsString(getClass(), "/" + protofile));
}
use of org.infinispan.protostream.BaseMarshaller in project quarkus by quarkusio.
the class InfinispanClientProducer method handleProtoStreamMarshaller.
private static void handleProtoStreamMarshaller(ProtoStreamMarshaller marshaller, Properties properties, BeanManager beanManager) {
SerializationContext serializationContext = marshaller.getSerializationContext();
Set<SerializationContextInitializer> initializers = (Set) properties.get(InfinispanClientProducer.PROTOBUF_INITIALIZERS);
if (initializers != null) {
for (SerializationContextInitializer initializer : initializers) {
initializer.registerSchema(serializationContext);
initializer.registerMarshallers(serializationContext);
}
}
FileDescriptorSource fileDescriptorSource = null;
for (Map.Entry<Object, Object> property : properties.entrySet()) {
Object key = property.getKey();
if (key instanceof String) {
String keyString = (String) key;
if (keyString.startsWith(InfinispanClientProducer.PROTOBUF_FILE_PREFIX)) {
String fileName = keyString.substring(InfinispanClientProducer.PROTOBUF_FILE_PREFIX.length());
String fileContents = (String) property.getValue();
if (fileDescriptorSource == null) {
fileDescriptorSource = new FileDescriptorSource();
}
fileDescriptorSource.addProtoFile(fileName, fileContents);
}
}
}
if (fileDescriptorSource != null) {
serializationContext.registerProtoFiles(fileDescriptorSource);
}
Set<Bean<FileDescriptorSource>> protoFileBeans = (Set) beanManager.getBeans(FileDescriptorSource.class);
for (Bean<FileDescriptorSource> bean : protoFileBeans) {
CreationalContext<FileDescriptorSource> ctx = beanManager.createCreationalContext(bean);
FileDescriptorSource fds = (FileDescriptorSource) beanManager.getReference(bean, FileDescriptorSource.class, ctx);
serializationContext.registerProtoFiles(fds);
// Register all of the fds so they can be queried
for (Map.Entry<String, char[]> fdEntry : fds.getFileDescriptors().entrySet()) {
properties.put(PROTOBUF_FILE_PREFIX + fdEntry.getKey(), new String(fdEntry.getValue()));
}
}
Set<Bean<BaseMarshaller>> beans = (Set) beanManager.getBeans(BaseMarshaller.class);
for (Bean<BaseMarshaller> bean : beans) {
CreationalContext<BaseMarshaller> ctx = beanManager.createCreationalContext(bean);
BaseMarshaller messageMarshaller = (BaseMarshaller) beanManager.getReference(bean, BaseMarshaller.class, ctx);
serializationContext.registerMarshaller(messageMarshaller);
}
}
use of org.infinispan.protostream.BaseMarshaller in project infinispan by infinispan.
the class SpringRemoteCacheManager method addSessionContextInitializerAndMarshaller.
private void addSessionContextInitializerAndMarshaller(SerializationContext ctx, JavaSerializationMarshaller serializationMarshaller) {
// Skip registering the marshallers if the MapSession class is not available
try {
new MapSession();
} catch (NoClassDefFoundError e) {
Log.CONFIG.debug("spring-session classes not found, skipping the session context initializer registration");
return;
}
org.infinispan.spring.common.session.PersistenceContextInitializerImpl sessionSci = new org.infinispan.spring.common.session.PersistenceContextInitializerImpl();
sessionSci.registerMarshallers(ctx);
sessionSci.registerSchema(ctx);
BaseMarshaller sessionAttributeMarshaller = new MapSessionProtoAdapter.SessionAttributeRawMarshaller(serializationMarshaller);
ctx.registerMarshaller(sessionAttributeMarshaller);
}
Aggregations