Annotation Type AutoProtoSchemaBuilder
-
@Target({TYPE,PACKAGE}) @Retention(CLASS) public @interface AutoProtoSchemaBuilder
Generates compile-time auto-implementations ofSerializationContextInitializer
. Annotate a class or interface extending fromSerializationContextInitializer
with this annotation and a new concrete public class named based onclassName()
, having a default no-arguments public constructor will be generated at compile time in the same package. The implementations of the methods fromSerializationContextInitializer
will be generated based on the information provided in the attributes of this annotation.This annotation is used at compile time annotation processing only and should not be relied upon at runtime, so its retention is set to
RetentionPolicy.CLASS
.NOTE: This annotation can also be used on packages but this kind of usage has been deprecated in 4.3.4 and will be removed in version 5. See IPROTO-157.
- Since:
- 4.3
- Author:
- [email protected]
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description boolean
autoImportClasses
Deprecated.since 4.3.4.String[]
basePackages
The list of packages to scan (optional).String
className
The name of the generated Java implementation class (optional).Class<? extends SerializationContextInitializer>[]
dependsOn
TheSerializationContextInitializer
s that must be executed before this one.Class<?>[]
excludeClasses
Classes to be explicitly excluded.Class<?>[]
includeClasses
Annotated classes to process (optional).boolean
marshallersOnly
Generate only the marshallers and skip the schema file.String
schemaFileName
The generated Protobuf schema file name (optional).String
schemaFilePath
Generated Protobuf schema resource file path (optional).String
schemaPackageName
Package of the generated Protobuf schema.boolean
service
Enable generation of aMETA-INF/services
file for the generated implementation class of theSerializationContextInitializer
to be loadable by theServiceLoader
.String[]
value
A handy alias forbasePackages()
.
-
-
-
Element Detail
-
className
String className
The name of the generated Java implementation class (optional). If missing, the name of the current class plus the "Impl" suffix is assumed by default.- Default:
- ""
-
-
-
schemaFileName
String schemaFileName
The generated Protobuf schema file name (optional). It can contain'/'
characters, so it might appear like a relative or absolute file name. Must end with ".proto" suffix. The schema will be registered under this name in theSerializationContext
bySerializationContextInitializer.registerSchema(SerializationContext)
. If missing, the simple name of the annotated class plus the ".proto" suffix will be used by default.- Default:
- ""
-
-
-
schemaFilePath
String schemaFilePath
Generated Protobuf schema resource file path (optional). If this is present then a resource file is generated in the designated path, with the given file name, and will be available to the ClassLoader at runtime, otherwise the generated schema file is directly baked as a String constant into the generated class and no resource file is generated.- Default:
- ""
-
-
-
schemaPackageName
String schemaPackageName
Package of the generated Protobuf schema. This is optional. If the package name is not specified then the unnamed/default package is assumed.- Default:
- ""
-
-
-
value
String[] value
A handy alias forbasePackages()
.value
andbasePackages()
are mutually exclusive. SeebasePackages()
for usage.- Default:
- {}
-
-
-
basePackages
String[] basePackages
The list of packages to scan (optional).basePackages
andincludeClasses()
are mutually exclusive. The packages are scanned for annotated classes recursively. IfbasePackages
is empty then all packages are considered, starting from root and including the default (unnamed) package. The packages are filtered based on theexcludeClasses()
filter. If neitherincludeClasses()
norbasePackages
is specified then the entire source path is scanned. Be wary of using this last option in anything but very simple demo projects.- Default:
- {}
-
-
-
includeClasses
Class<?>[] includeClasses
Annotated classes to process (optional). IfincludeClasses
is empty, allProtoXyz
annotated classes that belong to the packages listed inbasePackages()
will be scanned. If neitherincludeClasses
norbasePackages()
was specified then the entire source path will be scanned. Be wary of using this last option in anything but very simple demo projects.- Default:
- {}
-
-
-
excludeClasses
Class<?>[] excludeClasses
Classes to be explicitly excluded.excludeClasses
andincludeClasses()
are mutually exclusive. This can be used together withbasePackages()
.- Default:
- {}
-
-
-
autoImportClasses
@Deprecated boolean autoImportClasses
Deprecated.since 4.3.4. This will be removed in version 5. See IPROTO-158.Indicates if we accept classes not explicitly included by theincludeClasses()
orbasePackages()
to be auto-detected by reference from the already included classes and to be added automatically. If this is set tofalse
(which is the default) it results in a compilation error when such a case is encountered.- Default:
- false
-
-
-
service
boolean service
Enable generation of aMETA-INF/services
file for the generated implementation class of theSerializationContextInitializer
to be loadable by theServiceLoader
. This defaults totrue
. The ProtoStream library does not make any use of theServiceLoader
to benefit from this mechanism but the user's application is free to use it.- Default:
- true
-
-
-
marshallersOnly
boolean marshallersOnly
Generate only the marshallers and skip the schema file.The schema is actually always generated at compile time, in memory, so that various validations can be performed at compile time, but with this flag you effectively ensure it finally gets excluded from both the generated source code and the generated resource files and it does not get registered at runtime by this
SerializationContextInitializer
implementation. This flag is useful in cases where you want to register the schema manually for whatever reason or the schema is already provided/registered by other parts of your application.This option conflicts with
schemaFilePath()
and they cannot be used together. Also, this option cannot be set totrue
if the annotated element is a subtype ofGeneratedSchema
, which is expected to always provide a generated schema, as the name implies.- Default:
- false
-
-
-
dependsOn
Class<? extends SerializationContextInitializer>[] dependsOn
TheSerializationContextInitializer
s that must be executed before this one. Classes or interfaces listed here must implementSerializationContextInitializer
and must also be annotated withAutoProtoSchemaBuilder
. Classes not annotated withAutoProtoSchemaBuilder
will result in a compilation error.- Default:
- {}
-
-