There are following code parts that are created during the build process:
1. Java classes for:
- Aggregate IDs and other types the developer defines in .proto files
- Aggregate States
- Stream Projection States
These files are created under
generated/main/java project sub-folder.
They are generated by protobuf compiler.
2. gRPC service implementations and stubs
Generated under generated/grpc path by gRPC plug-in to Protobuf compiler.
3. Mapping from Proto types to Java classes
It is the file named proto_to_java_class.properties. The purpose of this file is to provide mapping from Proto type to corresponding Java class. It’s not currently possible to know Java class from Proto type.
4. Command Validators
This is not yet implemented, but we’re going to do that. A command validator is a class that validates commands for an aggregate class. The validation rules are based on Protobuf field annotations.
5. Business Failures
A business failure (unlike a technical error) is a condition under which a request cannot be complete (but there are ways for solving this situation). Example would be: CreditCardValidationDeclined, InsufficientAmount, TaskInProgressCannotBeRemoved.
There are two parts of code per business failure that are generated.
Part 1: a Java class for corresponding Protobuf message. Unlike commands and events, failures are all gathered in the same enclosing class called Failures. This is done so because there’s another piece of code related to a business failure.
Part 2: a Java class derived from FailureThrowable. Each such class is top level class generated underfailures sub-package of the corresponding aggregate. Instances of the class would contain corresponding failure message. We generate these Throwable classes because Java does not support generic types for throwables. More on this read in Failures and Code Generation chapters of the Spine documentation.