Package org.infinispan.protostream.impl
Class SerializationContextImpl
- java.lang.Object
-
- org.infinispan.protostream.impl.SerializationContextImpl
-
- All Implemented Interfaces:
ImmutableSerializationContext
,SerializationContext
public final class SerializationContextImpl extends Object implements SerializationContext
- Since:
- 1.0
- Author:
- [email protected]
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.infinispan.protostream.SerializationContext
SerializationContext.InstanceMarshallerProvider<T>, SerializationContext.MarshallerProvider
-
-
Constructor Summary
Constructors Constructor Description SerializationContextImpl(Configuration configuration)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
canMarshall(Class<?> javaClass)
Checks if the given type (message or enum) can be marshalled.boolean
canMarshall(Object object)
Checks if the given instance can be marshalled.boolean
canMarshall(String fullTypeName)
Checks if the given type (message or enum) can be marshalled.Configuration
getConfiguration()
Get the (immutable) configuration object that was used when creating this context.GenericDescriptor
getDescriptorByName(String fullTypeName)
Obtains the descriptor associated with a type name.GenericDescriptor
getDescriptorByTypeId(Integer typeId)
Obtains the descriptor associated with a numeric type id.EnumDescriptor
getEnumDescriptor(String fullTypeName)
Map<String,FileDescriptor>
getFileDescriptors()
Obtain the currently registered file descriptors.Map<String,GenericDescriptor>
getGenericDescriptors()
Obtain the currently registered type descriptors.<T> BaseMarshaller<T>
getMarshaller(Class<T> clazz)
Obtains the marshaller associated with a Java type.<T> BaseMarshaller<T>
getMarshaller(String fullTypeName)
Obtains the marshaller associated with a Protobuf type name.<T> BaseMarshaller<T>
getMarshaller(T object)
Obtains the marshaller associated with a given instance.<T> BaseMarshallerDelegate<T>
getMarshallerDelegate(Class<T> javaClass)
<T> BaseMarshallerDelegate<T>
getMarshallerDelegate(String typeName)
<T> BaseMarshallerDelegate<T>
getMarshallerDelegate(T object)
Descriptor
getMessageDescriptor(String fullTypeName)
Integer
getTypeIdByName(String fullTypeName)
Deprecated.String
getTypeNameById(Integer typeId)
Deprecated.void
registerMarshaller(BaseMarshaller<?> marshaller)
Register a type marshaller.void
registerMarshallerProvider(SerializationContext.InstanceMarshallerProvider<?> marshallerProvider)
void
registerMarshallerProvider(SerializationContext.MarshallerProvider marshallerProvider)
Deprecated.void
registerProtoFiles(FileDescriptorSource source)
Register some proto schema definition files from aFileDescriptorSource
.void
unregisterMarshaller(BaseMarshaller<?> marshaller)
void
unregisterMarshallerProvider(SerializationContext.InstanceMarshallerProvider<?> marshallerProvider)
void
unregisterMarshallerProvider(SerializationContext.MarshallerProvider marshallerProvider)
Deprecated.void
unregisterProtoFile(String fileName)
Unregisters a file.void
unregisterProtoFiles(Set<String> fileNames)
Unregisters a set of files.
-
-
-
Constructor Detail
-
SerializationContextImpl
public SerializationContextImpl(Configuration configuration)
-
-
Method Detail
-
getConfiguration
public Configuration getConfiguration()
Description copied from interface:ImmutableSerializationContext
Get the (immutable) configuration object that was used when creating this context.- Specified by:
getConfiguration
in interfaceImmutableSerializationContext
-
getFileDescriptors
public Map<String,FileDescriptor> getFileDescriptors()
Description copied from interface:ImmutableSerializationContext
Obtain the currently registered file descriptors.- Specified by:
getFileDescriptors
in interfaceImmutableSerializationContext
- Returns:
- an immutable copy of the internal map of descriptors
-
getGenericDescriptors
public Map<String,GenericDescriptor> getGenericDescriptors()
Description copied from interface:ImmutableSerializationContext
Obtain the currently registered type descriptors.- Specified by:
getGenericDescriptors
in interfaceImmutableSerializationContext
- Returns:
- an immutable copy of the internal map of descriptors
-
registerProtoFiles
public void registerProtoFiles(FileDescriptorSource source) throws DescriptorParserException
Description copied from interface:SerializationContext
Register some proto schema definition files from aFileDescriptorSource
.- Specified by:
registerProtoFiles
in interfaceSerializationContext
- Throws:
DescriptorParserException
-
unregisterProtoFile
public void unregisterProtoFile(String fileName)
Description copied from interface:SerializationContext
Unregisters a file. All types defined in it are removed and also the types from all dependant files. The status of dependant files is set to 'unresolved'.- Specified by:
unregisterProtoFile
in interfaceSerializationContext
-
unregisterProtoFiles
public void unregisterProtoFiles(Set<String> fileNames)
Description copied from interface:SerializationContext
Unregisters a set of files. All types defined in them are removed and also the types from all dependant files. The status of dependant files is set to 'unresolved'.- Specified by:
unregisterProtoFiles
in interfaceSerializationContext
-
getMessageDescriptor
public Descriptor getMessageDescriptor(String fullTypeName)
- Specified by:
getMessageDescriptor
in interfaceImmutableSerializationContext
-
getEnumDescriptor
public EnumDescriptor getEnumDescriptor(String fullTypeName)
- Specified by:
getEnumDescriptor
in interfaceImmutableSerializationContext
-
registerMarshaller
public void registerMarshaller(BaseMarshaller<?> marshaller)
Description copied from interface:SerializationContext
Register a type marshaller.- Specified by:
registerMarshaller
in interfaceSerializationContext
- Parameters:
marshaller
- the marshaller instance
-
unregisterMarshaller
public void unregisterMarshaller(BaseMarshaller<?> marshaller)
- Specified by:
unregisterMarshaller
in interfaceSerializationContext
-
registerMarshallerProvider
@Deprecated public void registerMarshallerProvider(SerializationContext.MarshallerProvider marshallerProvider)
Deprecated.- Specified by:
registerMarshallerProvider
in interfaceSerializationContext
-
unregisterMarshallerProvider
@Deprecated public void unregisterMarshallerProvider(SerializationContext.MarshallerProvider marshallerProvider)
Deprecated.- Specified by:
unregisterMarshallerProvider
in interfaceSerializationContext
-
registerMarshallerProvider
public void registerMarshallerProvider(SerializationContext.InstanceMarshallerProvider<?> marshallerProvider)
- Specified by:
registerMarshallerProvider
in interfaceSerializationContext
-
unregisterMarshallerProvider
public void unregisterMarshallerProvider(SerializationContext.InstanceMarshallerProvider<?> marshallerProvider)
- Specified by:
unregisterMarshallerProvider
in interfaceSerializationContext
-
canMarshall
public boolean canMarshall(Class<?> javaClass)
Description copied from interface:ImmutableSerializationContext
Checks if the given type (message or enum) can be marshalled. This checks that a marshaller was registered for it.- Specified by:
canMarshall
in interfaceImmutableSerializationContext
- Parameters:
javaClass
- the object or enum class to check- Returns:
true
if a marshaller exists,false
otherwise
-
canMarshall
public boolean canMarshall(String fullTypeName)
Description copied from interface:ImmutableSerializationContext
Checks if the given type (message or enum) can be marshalled. This checks that the Protobuf type was defined and a marshaller was registered for it.- Specified by:
canMarshall
in interfaceImmutableSerializationContext
- Parameters:
fullTypeName
- the fully qualified name of the Protobuf definition to check- Returns:
true
if a marshaller exists,false
otherwise
-
canMarshall
public boolean canMarshall(Object object)
Description copied from interface:ImmutableSerializationContext
Checks if the given instance can be marshalled.- Specified by:
canMarshall
in interfaceImmutableSerializationContext
- Parameters:
object
- the instance- Returns:
true
if a marshaller exists,false
otherwise
-
getMarshaller
public <T> BaseMarshaller<T> getMarshaller(T object)
Description copied from interface:ImmutableSerializationContext
Obtains the marshaller associated with a given instance.- Specified by:
getMarshaller
in interfaceImmutableSerializationContext
- Parameters:
object
- the instance- Returns:
- the marshaller
-
getMarshaller
public <T> BaseMarshaller<T> getMarshaller(String fullTypeName)
Description copied from interface:ImmutableSerializationContext
Obtains the marshaller associated with a Protobuf type name.- Specified by:
getMarshaller
in interfaceImmutableSerializationContext
- Parameters:
fullTypeName
- the type name- Returns:
- the marshaller
-
getMarshaller
public <T> BaseMarshaller<T> getMarshaller(Class<T> clazz)
Description copied from interface:ImmutableSerializationContext
Obtains the marshaller associated with a Java type.- Specified by:
getMarshaller
in interfaceImmutableSerializationContext
- Parameters:
clazz
- the class- Returns:
- the marshaller
-
getMarshallerDelegate
public <T> BaseMarshallerDelegate<T> getMarshallerDelegate(String typeName)
-
getMarshallerDelegate
public <T> BaseMarshallerDelegate<T> getMarshallerDelegate(Class<T> javaClass)
-
getMarshallerDelegate
public <T> BaseMarshallerDelegate<T> getMarshallerDelegate(T object)
-
getTypeNameById
@Deprecated public String getTypeNameById(Integer typeId)
Deprecated.Description copied from interface:ImmutableSerializationContext
Obtains the Protobuf type name associated with a numeric type id.- Specified by:
getTypeNameById
in interfaceImmutableSerializationContext
- Parameters:
typeId
- the numeric type id- Returns:
- the fully qualified type name
-
getTypeIdByName
@Deprecated public Integer getTypeIdByName(String fullTypeName)
Deprecated.Description copied from interface:ImmutableSerializationContext
Obtains the associated numeric type id for a Protobuf type name, if a numeric id was defined.- Specified by:
getTypeIdByName
in interfaceImmutableSerializationContext
- Parameters:
fullTypeName
- the fully qualified type name- Returns:
- the type id or
null
if no type id is associated with the type
-
getDescriptorByName
public GenericDescriptor getDescriptorByName(String fullTypeName)
Description copied from interface:ImmutableSerializationContext
Obtains the descriptor associated with a type name.- Specified by:
getDescriptorByName
in interfaceImmutableSerializationContext
- Parameters:
fullTypeName
- the fully qualified type name- Returns:
- the descriptor
-
getDescriptorByTypeId
public GenericDescriptor getDescriptorByTypeId(Integer typeId)
Description copied from interface:ImmutableSerializationContext
Obtains the descriptor associated with a numeric type id.- Specified by:
getDescriptorByTypeId
in interfaceImmutableSerializationContext
- Parameters:
typeId
- the numeric type id- Returns:
- the descriptor
-
-