Action Services |
![]() ![]() ![]() |
Instead of writing a Servlet class for each command on the user interface, It is advised to have only one controller Servlet that loads and executes the service classes that are mapped to specific commands. This way you can hide the full names of the java classes executed for the commands and you gain flexibility for the future changes in your package structures. Example: custlist.doms?custid=723723
The java class, say it is mypack.getoperations.CustomerList, that works behind this URL is not known by the users and in the future you can map your URL to another class, e.g. mypack.customer.GetCustomerList without making any changes in the user interfaces. ActionService is an Interface to develop services that complies to this Architecture Here is an action service class example that implements org.moremotion.action.ActionService interface.
The classes that implements org.moremotion.action.ActionService interface should implement the doService method. public void doService(ActionServiceContext asc) throws ServiceException, IOException;
This method is the entry point of the action services. MoreMotion calls this method of the service and passes ActionServiceContext object to it. After finishing its work the service should call Display Page Service with request.generatePage() method and terminate. How to call an Action Service? Simply mypack.MyActionService.doms?UNIT_PRICE=12.25&QUANTITY=5
The requests that contain .doms extension is received by the SCS. The SCS loads the service classes and call their doService() Methods. The Service Controller Servlet (SCS) Calling an Action Service with an URL like "mypack.MyActionService.doms?prm1=ABC&prm2=123" is possible since the extension .doms is already mapped to the MoreMotion's ServiceControllerServlet (SCS) in web.xml file. The SCS receives all the requests that has the .doms extension, loads the action service classes and executes them. Mapping the Action Services If the full name of the action class name should not be exhibited on the user interface or the action service needs service parameters then an Action definition should be made in the MoreMotion configuration using the configuration element action.
Once the action service is defined in the configuration, the calling of it becomes as simple as the following. myservice.doms?UNIT_PRICE=12.25&QUANTITY=5
|