Package org.infinispan.query.remote.impl
Class ProtobufMetadataManagerImpl
- java.lang.Object
-
- org.infinispan.query.remote.impl.ProtobufMetadataManagerImpl
-
- All Implemented Interfaces:
ProtobufMetadataManagerConstants
,ProtobufMetadataManagerMBean
,ProtobufMetadataManager
public final class ProtobufMetadataManagerImpl extends Object implements ProtobufMetadataManager
- Since:
- 7.0
- Author:
- anistor@redhat.com
-
-
Field Summary
-
Fields inherited from interface org.infinispan.query.remote.ProtobufMetadataManager
SCHEMA_MANAGER_ROLE
-
Fields inherited from interface org.infinispan.query.remote.client.ProtobufMetadataManagerConstants
ERRORS_KEY_SUFFIX, OBJECT_NAME, PROTO_KEY_SUFFIX, PROTOBUF_METADATA_CACHE_NAME
-
-
Constructor Summary
Constructors Constructor Description ProtobufMetadataManagerImpl()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addCacheDependency(String dependantCacheName)
Starts the ___protobuf_metadata when needed.String
getFileErrors(String fileName)
Gets the error messages (caused by parsing, linking, etc) associated to a *.proto schema file.String[]
getFilesWithErrors()
Get the full names of all files with errors.ObjectName
getObjectName()
String
getProtofile(String fileName)
Gets the contents of a registered *.proto schema file.String[]
getProtofileNames()
Get the full names of all registered schema files.static org.infinispan.protostream.SerializationContext
getSerializationContext(EmbeddedCacheManager cacheManager)
Obtains the protobuf serialization context of the ProtobufMetadataManager instance associated to a cache manager.protected void
init(EmbeddedCacheManager cacheManager, InternalCacheRegistry internalCacheRegistry)
Defines the configuration of the ___protobuf_metadata internal cache.void
registerMarshaller(org.infinispan.protostream.BaseMarshaller<?> marshaller)
void
registerProtofile(String fileName, String contents)
Register a *.proto schema file.void
registerProtofiles(String[] fileNames, String[] contents)
Registers multiple *.proto schema files.void
unregisterMarshaller(org.infinispan.protostream.BaseMarshaller<?> marshaller)
void
unregisterProtofile(String fileName)
Unregister a *.proto schema file.void
unregisterProtofiles(String[] fileNames)
Unregisters multiple *.proto schema files.
-
-
-
Method Detail
-
init
protected void init(EmbeddedCacheManager cacheManager, InternalCacheRegistry internalCacheRegistry)
Defines the configuration of the ___protobuf_metadata internal cache.
-
addCacheDependency
protected void addCacheDependency(String dependantCacheName)
Starts the ___protobuf_metadata when needed. This method must be invoked for each cache that uses protobuf.- Parameters:
dependantCacheName
- the name of the cache depending on the protobuf metadata cache
-
getObjectName
public ObjectName getObjectName()
- Specified by:
getObjectName
in interfaceProtobufMetadataManager
-
registerMarshaller
public void registerMarshaller(org.infinispan.protostream.BaseMarshaller<?> marshaller)
- Specified by:
registerMarshaller
in interfaceProtobufMetadataManager
-
unregisterMarshaller
public void unregisterMarshaller(org.infinispan.protostream.BaseMarshaller<?> marshaller)
- Specified by:
unregisterMarshaller
in interfaceProtobufMetadataManager
-
registerProtofile
public void registerProtofile(String fileName, String contents)
Description copied from interface:ProtobufMetadataManagerMBean
Register a *.proto schema file. If there are any syntax or semantic errors a *.proto.errors key will be created in the underlying cache and its value will be the actual error message. The error message, if any, can be retrieved usingProtobufMetadataManagerMBean.getFileErrors(String fileName)
method. The list of offending files can be retrieved usingProtobufMetadataManagerMBean.getFilesWithErrors()
method.- Specified by:
registerProtofile
in interfaceProtobufMetadataManagerMBean
- Parameters:
fileName
- the full name of the file (name can contain '/'); must end with ".proto" suffixcontents
- the file contents
-
registerProtofiles
public void registerProtofiles(String[] fileNames, String[] contents) throws Exception
Description copied from interface:ProtobufMetadataManagerMBean
Registers multiple *.proto schema files. If there are any syntax or semantic errors a *.proto.errors key will be created in the underlying cache for each offending file and its value will be the actual error message. The error message, if any, can be retrieved usingProtobufMetadataManagerMBean.getFileErrors(String fileName)
method. The list of offending files can be retrieved usingProtobufMetadataManagerMBean.getFilesWithErrors()
method.- Specified by:
registerProtofiles
in interfaceProtobufMetadataManagerMBean
- Parameters:
fileNames
- the full names of the files (name can contain '/'); names must end with ".proto" suffixcontents
- the contents of each file; this array must have the same length asfileNames
- Throws:
Exception
- in case of failure
-
unregisterProtofile
public void unregisterProtofile(String fileName)
Description copied from interface:ProtobufMetadataManagerMBean
Unregister a *.proto schema file.- Specified by:
unregisterProtofile
in interfaceProtobufMetadataManagerMBean
- Parameters:
fileName
- the full name of the file (name can contain '/'); must end with ".proto" suffix
-
unregisterProtofiles
public void unregisterProtofiles(String[] fileNames)
Description copied from interface:ProtobufMetadataManagerMBean
Unregisters multiple *.proto schema files.- Specified by:
unregisterProtofiles
in interfaceProtobufMetadataManagerMBean
- Parameters:
fileNames
- the full names of the files (name can contain '/'); names must end with ".proto" suffix
-
getProtofileNames
public String[] getProtofileNames()
Description copied from interface:ProtobufMetadataManagerMBean
Get the full names of all registered schema files.- Specified by:
getProtofileNames
in interfaceProtobufMetadataManagerMBean
- Returns:
- the array of all registered schema file names or an empty array if there are no files (never null)
-
getProtofile
public String getProtofile(String fileName)
Description copied from interface:ProtobufMetadataManagerMBean
Gets the contents of a registered *.proto schema file.- Specified by:
getProtofile
in interfaceProtobufMetadataManagerMBean
- Parameters:
fileName
- the name of the file; must end with ".proto" suffix- Returns:
- the file contents or
null
if the file does not exist
-
getFilesWithErrors
public String[] getFilesWithErrors()
Description copied from interface:ProtobufMetadataManagerMBean
Get the full names of all files with errors.- Specified by:
getFilesWithErrors
in interfaceProtobufMetadataManagerMBean
- Returns:
- the array of all file names with errors or an empty array if there are no files with errors (never null)
-
getFileErrors
public String getFileErrors(String fileName)
Description copied from interface:ProtobufMetadataManagerMBean
Gets the error messages (caused by parsing, linking, etc) associated to a *.proto schema file.- Specified by:
getFileErrors
in interfaceProtobufMetadataManagerMBean
- Parameters:
fileName
- the name of the file; must end with ".proto" suffix- Returns:
- the error text or
null
if there are no errors
-
getSerializationContext
public static org.infinispan.protostream.SerializationContext getSerializationContext(EmbeddedCacheManager cacheManager)
Obtains the protobuf serialization context of the ProtobufMetadataManager instance associated to a cache manager.- Parameters:
cacheManager
- a cache manager instance- Returns:
- the protobuf
SerializationContext
-
-