Web / Apache OFBiz Interview questions
How do Entity ECAs enforce validation rules without modifying core Java code?
An Entity ECA (EECA) is declared in XML against a specific entity and operation - "whenever ExampleItem is created or stored, run this condition and action" - without touching the Java class or Mini-language service that performs the actual write.
<eca entity="ExampleItem" operation="create-store" event="return"> <condition field-name="itemName" operator="is-empty"/> <action service="raiseExampleItemValidationError" mode="sync"/> </eca>
Because the rule is registered against the entity operation itself rather than any particular calling code path, it fires consistently whether the write came from a UI form, an import script, or another service - which is exactly the point: validation logic lives in one declarative place instead of being duplicated, or forgotten, in every code path that might touch that entity.
The trade-off is that EECA rules are less visible than a validation check written directly in a service, so teams typically reserve them for rules that genuinely need to apply universally, keeping entity-specific business validation in the service layer where it's easier to trace.
More Related questions...