POJO Service Engine
From Opentaps Wiki
Revision as of 21:57, 9 July 2008 by Sichen (talk | contribs) (Protected "POJO Service Engine": Sysop page [edit=sysop:move=sysop])
POJO Service Engine
The POJO service engine is designed to allow you to mount your Java service objects directly on to the ofbiz service engine, without having to write a static Java method to call it. To use the POJO service engine, you have to declare your service with service engine XML file, just like for all of the other ofbiz services, but use pojo instead of java as the engine:
Then, you could write your service as a Java class with the following requirements:
- It must extend the base org.opentaps.foundation.service.ofbiz.Service class
- You must have a default constructor which takes no parameters
- For each input parameter defined in your services XML, you must have a set method. The set method must be named "set" plus the name of the variable, with the first letter capitalized. For example, if you have "orderId" as an input parameter of your service, you must have a "setOrderId" method. It can not be "SetOrderId", "setorderid", or "setorderId". This is done intentionally to enforce code consistency.
- Each set method must take one parameter, and it must match the parameter in your services XML. For example, if your services XML specifies "java.util.List", your set method take a single parameter of the java.util.List class, not ArrayList, FastList, LinkedList, etc.
- For each output parameter defined in your services XML, you must define one get method which takes no parameters. The name of the get method must be "get" plus the name of the variable with the first letter capitalized (ie, "getInvoiceId()" for "invoiceId").
- The invoke method must be a void method with no parameters.
- Instead of returning ServiceUtil.returnError when there is a problem with the service, throw exceptions such as ServiceException