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 useAutoProtoSchemaBuilderinstead. 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 aSerializationContextgiven 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,ProtoReservedandProtoReservedStatements.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
AutoProtoSchemaBuilderandSerializationContextInitializer.- Since:
- 3.0
- Author:
- anistor@redhat.com
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_GENERATED_SCHEMA_NAMEDeprecated.static StringFILE_LONG_OPTDeprecated.static StringFILE_OPTDeprecated.static booleangenerateSchemaDebugCommentsDeprecated.static StringHELP_LONG_OPTDeprecated.static StringHELP_OPTDeprecated.static StringMARSHALLER_LONG_OPTDeprecated.static StringMARSHALLER_OPTDeprecated.static StringPACKAGE_LONG_OPTDeprecated.static StringPACKAGE_OPTDeprecated.static StringSCHEMA_LONG_OPTDeprecated.static StringSCHEMA_OPTDeprecated.
-
Constructor Summary
Constructors Constructor Description ProtoSchemaBuilder()Deprecated.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description ProtoSchemaBuilderaddClass(Class<?> clazz)Deprecated.Add a @ProtoXyz annotated class to be analyzed.ProtoSchemaBuilderaddClasses(Class<?>... classes)Deprecated.Add several @ProtoXyz annotated classes to be analyzed.ProtoSchemaBuilderautoImportClasses(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.Stringbuild(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.Stringbuild(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.ProtoSchemaBuilderfileName(String fileName)Deprecated.Set the name of the Protobuf schema file to generate.ProtoSchemaBuildergenerator(String generator)Deprecated.Sets the 'generated by' comment.static voidmain(String[] args)Deprecated.ProtoSchemaBuilderpackageName(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 totrueto 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 theSerializationContextwith 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
#addClassoraddClasses(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 istrueby 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:
ProtoSchemaBuilderExceptionIOException
-
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:
ProtoSchemaBuilderExceptionIOException
-
-