Web / Apache OFBiz Interview questions
How does a Service Engine call differ from a direct Java method call?
A direct Java method call executes in-process with whatever access and error handling the caller happens to implement. Calling the same logic as an OFBiz service instead routes it through the dispatcher, which layers in behavior a plain method call doesn't get for free:
- Parameter validation against the service's declared attribute list, so bad input is rejected before your code runs.
- Permission checks if the service definition specifies one.
- Transaction management - the engine can start, join, or suspend a transaction based on the service's
require-new-transactionsetting. - SECA triggers - other services can be chained to run automatically before or after.
- Uniform sync/async/scheduled invocation using the exact same service definition.
The cost is a small amount of reflection/dispatch overhead and an extra layer of indirection, which is why tight inner-loop logic inside a service is often still plain Java, called from the service wrapper rather than being a service itself.
More Related questions...