Class ProtoSchemaBuilder
- java.lang.Object
-
- org.infinispan.protostream.annotations.ProtoSchemaBuilder
-
@Deprecated public final class ProtoSchemaBuilder extends Object
Deprecated.since 4.3.4. To be removed in version 5. Please useAutoProtoSchemaBuilder
instead. See IPROTO-159.Generates a Protocol Buffers schema definition file and the associated marshallers instances based on a set of given@Proto*
annotated classes. The generated schema and marshallers are registered to aSerializationContext
given during creation. The needed types, on which the currently generated types depend on, are also looked up in the sameSerializationContext
.See annotations
ProtoName
,ProtoMessage
,ProtoField
,ProtoEnum
,ProtoTypeId
,ProtoEnumValue
,ProtoDoc
,ProtoDocs
,ProtoUnknownFieldSet
,ProtoFactory
,ProtoReserved
andProtoReservedStatements
.NOTE: This builder contains state that cannot be reset making it impossible to reuse properly. Please create separate instances for each schema generation.
This class performs run-time generation. For a compile-time equivalent see
AutoProtoSchemaBuilder
andSerializationContextInitializer
.- Since:
- 3.0
- Author:
- anistor@redhat.com
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_GENERATED_SCHEMA_NAME
Deprecated.static String
FILE_LONG_OPT
Deprecated.static String
FILE_OPT
Deprecated.static boolean
generateSchemaDebugComments
Deprecated.static String
HELP_LONG_OPT
Deprecated.static String
HELP_OPT
Deprecated.static String
MARSHALLER_LONG_OPT
Deprecated.static String
MARSHALLER_OPT
Deprecated.static String
PACKAGE_LONG_OPT
Deprecated.static String
PACKAGE_OPT
Deprecated.static String
SCHEMA_LONG_OPT
Deprecated.static String
SCHEMA_OPT
Deprecated.
-
Constructor Summary
Constructors Constructor Description ProtoSchemaBuilder()
Deprecated.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description ProtoSchemaBuilder
addClass(Class<?> clazz)
Deprecated.Add a @ProtoXyz annotated class to be analyzed.ProtoSchemaBuilder
addClasses(Class<?>... classes)
Deprecated.Add several @ProtoXyz annotated classes to be analyzed.ProtoSchemaBuilder
autoImportClasses(boolean autoImportClasses)
Deprecated.A flag to control processing of classes that were not directly added but were discovered by analyzing the annotated fields/properties of the added classes.String
build(SerializationContext serializationContext)
Deprecated.Builds the Protocol Buffers schema file defining the types and generates marshaller implementations for these types and registers everything with the givenSerializationContext
.String
build(SerializationContext serializationContext, ClassLoader classLoader)
Deprecated.Builds the Protocol Buffers schema file defining the types and generates marshaller implementations for these types and registers everything with the givenSerializationContext
.The generated classes are defined in the given ClassLoader.ProtoSchemaBuilder
fileName(String fileName)
Deprecated.Set the name of the Protobuf schema file to generate.ProtoSchemaBuilder
generator(String generator)
Deprecated.Sets the 'generated by' comment.static void
main(String[] args)
Deprecated.ProtoSchemaBuilder
packageName(String packageName)
Deprecated.Set the name of the Protobuf package to generate.
-
-
-
Field Detail
-
DEFAULT_GENERATED_SCHEMA_NAME
public static final String DEFAULT_GENERATED_SCHEMA_NAME
Deprecated.- See Also:
- Constant Field Values
-
FILE_OPT
public static final String FILE_OPT
Deprecated.- See Also:
- Constant Field Values
-
FILE_LONG_OPT
public static final String FILE_LONG_OPT
Deprecated.- See Also:
- Constant Field Values
-
PACKAGE_OPT
public static final String PACKAGE_OPT
Deprecated.- See Also:
- Constant Field Values
-
PACKAGE_LONG_OPT
public static final String PACKAGE_LONG_OPT
Deprecated.- See Also:
- Constant Field Values
-
HELP_OPT
public static final String HELP_OPT
Deprecated.- See Also:
- Constant Field Values
-
HELP_LONG_OPT
public static final String HELP_LONG_OPT
Deprecated.- See Also:
- Constant Field Values
-
MARSHALLER_OPT
public static final String MARSHALLER_OPT
Deprecated.- See Also:
- Constant Field Values
-
MARSHALLER_LONG_OPT
public static final String MARSHALLER_LONG_OPT
Deprecated.- See Also:
- Constant Field Values
-
SCHEMA_OPT
public static final String SCHEMA_OPT
Deprecated.- See Also:
- Constant Field Values
-
SCHEMA_LONG_OPT
public static final String SCHEMA_LONG_OPT
Deprecated.- See Also:
- Constant Field Values
-
generateSchemaDebugComments
@Deprecated public static boolean generateSchemaDebugComments
Deprecated.Set this flag totrue
to enable output of debug comments in the generated Protobuf schema.
-
-
Method Detail
-
fileName
public ProtoSchemaBuilder fileName(String fileName)
Deprecated.Set the name of the Protobuf schema file to generate. This is mandatory. The resulting file will be registered in theSerializationContext
with this given name.- Parameters:
fileName
- the name of the file to generate- Returns:
- itself
-
packageName
public ProtoSchemaBuilder packageName(String packageName)
Deprecated.Set the name of the Protobuf package to generate. This is optional.- Parameters:
packageName
- the package name- Returns:
- itself, to help chaining calls
-
generator
public ProtoSchemaBuilder generator(String generator)
Deprecated.Sets the 'generated by' comment. This is useful for documentation purposes.- Parameters:
generator
- a string to be added as a comment in the generated schema
-
addClass
public ProtoSchemaBuilder addClass(Class<?> clazz)
Deprecated.Add a @ProtoXyz annotated class to be analyzed. Proto schema and marshaller will be generated for it.Its superclass and superinterfaces will be also included in the analysis but no separate Protobuf types and marshallers will be generated for them as Protobuf does not have any notion of type hierarchy and inheritance. The fields defined by the superclass or superinterfaces will be just included in the schema of the derived class.
Its inner classes will also be automatically processed if they are referenced by the outer class. If you want to make sure an inner class is processed regardless if referenced or not you will have to add it explicitly using
#addClass
oraddClasses(java.lang.Class<?>...)
.- Parameters:
clazz
- the class to analyze- Returns:
- itself, to help chaining calls
-
addClasses
public ProtoSchemaBuilder addClasses(Class<?>... classes)
Deprecated.Add several @ProtoXyz annotated classes to be analyzed. Proto schema and marshaller will be generated for them.Their superclasses and superinterfaces will be also included in the analysis but no separate Protobuf types and marshallers will be generated for them as Protobuf does not have any notion of type hierarchy and inheritance. The fields defined by the superclass or superinterfaces will be just included in the schema of the derived class.
Inner classes will also be automatically processed if they are referenced by the outer class. If you want to make sure an inner class is processed regardless if referenced or not you will have to add it explicitly using
addClass(java.lang.Class<?>)
or#addClasses
.- Parameters:
classes
- the classes to analyze- Returns:
- itself, to help chaining calls
-
autoImportClasses
public ProtoSchemaBuilder autoImportClasses(boolean autoImportClasses)
Deprecated.A flag to control processing of classes that were not directly added but were discovered by analyzing the annotated fields/properties of the added classes. When such a class is found an error will be generated if autoImportClasses is disabled. This flag istrue
by default to simplify usability (and also for backward compatibility) but can be turned off whenever you need to be very specific about which classes are to be processed. We encourage you to turn it off for maximum control.- Parameters:
autoImportClasses
-- Returns:
- itself, to help chaining calls
-
build
public String build(SerializationContext serializationContext) throws ProtoSchemaBuilderException, IOException
Deprecated.Builds the Protocol Buffers schema file defining the types and generates marshaller implementations for these types and registers everything with the givenSerializationContext
. The generated classes are defined in the thread context ClassLoader.- Parameters:
serializationContext
-- Returns:
- the generated Protocol Buffers schema file text
- Throws:
ProtoSchemaBuilderException
IOException
-
build
public String build(SerializationContext serializationContext, ClassLoader classLoader) throws ProtoSchemaBuilderException, IOException
Deprecated.Builds the Protocol Buffers schema file defining the types and generates marshaller implementations for these types and registers everything with the givenSerializationContext
.The generated classes are defined in the given ClassLoader.- Parameters:
serializationContext
-classLoader
- the ClassLoader in which the generated classes will be defined. Ifnull
, this behaves asbuild(SerializationContext)
- Returns:
- the generated Protocol Buffers schema file text
- Throws:
ProtoSchemaBuilderException
IOException
-
-