Web / Apache OFBiz Interview questions
How do you define a new service in OFBiz?
A service's definition and its implementation are kept separate:
- Declare the service in a
servicedef/services.xmlfile: its name, engine type (java,simple,groovy,entity-auto, etc.), and itsattributelist (input/output parameters with modeIN,OUT, orINOUT). - Point it at an implementation: a Java class/method, a Mini-language XML file, or a Groovy script.
- Write the implementation, using the delegator/dispatcher available in the service context to do the actual work.
- Call it with
dispatcher.runSync("yourServiceName", paramMap)from Java, or reference it directly from a form/screen action or an event.
Because the parameter list is declared up front, the engine validates every call automatically, catching missing or mistyped inputs before your code even runs.
More Related questions...