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:
- anistor@redhat.com
-
-
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 booleancanMarshall(Class<?> javaClass)Checks if the given type (message or enum) can be marshalled.booleancanMarshall(Object object)Checks if the given instance can be marshalled.booleancanMarshall(String fullTypeName)Checks if the given type (message or enum) can be marshalled.ConfigurationgetConfiguration()Get the (immutable) configuration object that was used when creating this context.GenericDescriptorgetDescriptorByName(String fullTypeName)Obtains the descriptor associated with a type name.GenericDescriptorgetDescriptorByTypeId(Integer typeId)Obtains the descriptor associated with a numeric type id.EnumDescriptorgetEnumDescriptor(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)DescriptorgetMessageDescriptor(String fullTypeName)IntegergetTypeIdByName(String fullTypeName)Deprecated.StringgetTypeNameById(Integer typeId)Deprecated.voidregisterMarshaller(BaseMarshaller<?> marshaller)Register a type marshaller.voidregisterMarshallerProvider(SerializationContext.InstanceMarshallerProvider<?> marshallerProvider)voidregisterMarshallerProvider(SerializationContext.MarshallerProvider marshallerProvider)Deprecated.voidregisterProtoFiles(FileDescriptorSource source)Register some proto schema definition files from aFileDescriptorSource.voidunregisterMarshaller(BaseMarshaller<?> marshaller)voidunregisterMarshallerProvider(SerializationContext.InstanceMarshallerProvider<?> marshallerProvider)voidunregisterMarshallerProvider(SerializationContext.MarshallerProvider marshallerProvider)Deprecated.voidunregisterProtoFile(String fileName)Unregisters a file.voidunregisterProtoFiles(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:ImmutableSerializationContextGet the (immutable) configuration object that was used when creating this context.- Specified by:
getConfigurationin interfaceImmutableSerializationContext
-
getFileDescriptors
public Map<String,FileDescriptor> getFileDescriptors()
Description copied from interface:ImmutableSerializationContextObtain the currently registered file descriptors.- Specified by:
getFileDescriptorsin interfaceImmutableSerializationContext- Returns:
- an immutable copy of the internal map of descriptors
-
getGenericDescriptors
public Map<String,GenericDescriptor> getGenericDescriptors()
Description copied from interface:ImmutableSerializationContextObtain the currently registered type descriptors.- Specified by:
getGenericDescriptorsin interfaceImmutableSerializationContext- Returns:
- an immutable copy of the internal map of descriptors
-
registerProtoFiles
public void registerProtoFiles(FileDescriptorSource source) throws DescriptorParserException
Description copied from interface:SerializationContextRegister some proto schema definition files from aFileDescriptorSource.- Specified by:
registerProtoFilesin interfaceSerializationContext- Throws:
DescriptorParserException
-
unregisterProtoFile
public void unregisterProtoFile(String fileName)
Description copied from interface:SerializationContextUnregisters 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:
unregisterProtoFilein interfaceSerializationContext
-
unregisterProtoFiles
public void unregisterProtoFiles(Set<String> fileNames)
Description copied from interface:SerializationContextUnregisters 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:
unregisterProtoFilesin interfaceSerializationContext
-
getMessageDescriptor
public Descriptor getMessageDescriptor(String fullTypeName)
- Specified by:
getMessageDescriptorin interfaceImmutableSerializationContext
-
getEnumDescriptor
public EnumDescriptor getEnumDescriptor(String fullTypeName)
- Specified by:
getEnumDescriptorin interfaceImmutableSerializationContext
-
registerMarshaller
public void registerMarshaller(BaseMarshaller<?> marshaller)
Description copied from interface:SerializationContextRegister a type marshaller.- Specified by:
registerMarshallerin interfaceSerializationContext- Parameters:
marshaller- the marshaller instance
-
unregisterMarshaller
public void unregisterMarshaller(BaseMarshaller<?> marshaller)
- Specified by:
unregisterMarshallerin interfaceSerializationContext
-
registerMarshallerProvider
@Deprecated public void registerMarshallerProvider(SerializationContext.MarshallerProvider marshallerProvider)
Deprecated.- Specified by:
registerMarshallerProviderin interfaceSerializationContext
-
unregisterMarshallerProvider
@Deprecated public void unregisterMarshallerProvider(SerializationContext.MarshallerProvider marshallerProvider)
Deprecated.- Specified by:
unregisterMarshallerProviderin interfaceSerializationContext
-
registerMarshallerProvider
public void registerMarshallerProvider(SerializationContext.InstanceMarshallerProvider<?> marshallerProvider)
- Specified by:
registerMarshallerProviderin interfaceSerializationContext
-
unregisterMarshallerProvider
public void unregisterMarshallerProvider(SerializationContext.InstanceMarshallerProvider<?> marshallerProvider)
- Specified by:
unregisterMarshallerProviderin interfaceSerializationContext
-
canMarshall
public boolean canMarshall(Class<?> javaClass)
Description copied from interface:ImmutableSerializationContextChecks if the given type (message or enum) can be marshalled. This checks that a marshaller was registered for it.- Specified by:
canMarshallin interfaceImmutableSerializationContext- Parameters:
javaClass- the object or enum class to check- Returns:
trueif a marshaller exists,falseotherwise
-
canMarshall
public boolean canMarshall(String fullTypeName)
Description copied from interface:ImmutableSerializationContextChecks 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:
canMarshallin interfaceImmutableSerializationContext- Parameters:
fullTypeName- the fully qualified name of the Protobuf definition to check- Returns:
trueif a marshaller exists,falseotherwise
-
canMarshall
public boolean canMarshall(Object object)
Description copied from interface:ImmutableSerializationContextChecks if the given instance can be marshalled.- Specified by:
canMarshallin interfaceImmutableSerializationContext- Parameters:
object- the instance- Returns:
trueif a marshaller exists,falseotherwise
-
getMarshaller
public <T> BaseMarshaller<T> getMarshaller(T object)
Description copied from interface:ImmutableSerializationContextObtains the marshaller associated with a given instance.- Specified by:
getMarshallerin interfaceImmutableSerializationContext- Parameters:
object- the instance- Returns:
- the marshaller
-
getMarshaller
public <T> BaseMarshaller<T> getMarshaller(String fullTypeName)
Description copied from interface:ImmutableSerializationContextObtains the marshaller associated with a Protobuf type name.- Specified by:
getMarshallerin interfaceImmutableSerializationContext- Parameters:
fullTypeName- the type name- Returns:
- the marshaller
-
getMarshaller
public <T> BaseMarshaller<T> getMarshaller(Class<T> clazz)
Description copied from interface:ImmutableSerializationContextObtains the marshaller associated with a Java type.- Specified by:
getMarshallerin 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:ImmutableSerializationContextObtains the Protobuf type name associated with a numeric type id.- Specified by:
getTypeNameByIdin 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:ImmutableSerializationContextObtains the associated numeric type id for a Protobuf type name, if a numeric id was defined.- Specified by:
getTypeIdByNamein interfaceImmutableSerializationContext- Parameters:
fullTypeName- the fully qualified type name- Returns:
- the type id or
nullif no type id is associated with the type
-
getDescriptorByName
public GenericDescriptor getDescriptorByName(String fullTypeName)
Description copied from interface:ImmutableSerializationContextObtains the descriptor associated with a type name.- Specified by:
getDescriptorByNamein interfaceImmutableSerializationContext- Parameters:
fullTypeName- the fully qualified type name- Returns:
- the descriptor
-
getDescriptorByTypeId
public GenericDescriptor getDescriptorByTypeId(Integer typeId)
Description copied from interface:ImmutableSerializationContextObtains the descriptor associated with a numeric type id.- Specified by:
getDescriptorByTypeIdin interfaceImmutableSerializationContext- Parameters:
typeId- the numeric type id- Returns:
- the descriptor
-
-