Have you implemented OpenMRS? Please participate in the Implementation Site Survey. If you already have, thank you!
3 layer architecture
Hibernate abstracts the implementation - do not need to code to the db. Map getters and setters to table fields
Each services has a DAO dedicated to it.
The service methods are more complex
OpenMRS API jar has the services, DAO's.
Web API jar has only the controllers needed for the web app.
If you are starting your own module, you may reference the objects already in the OpenMRS API. But if your module refers to its own objects, you need your own dao's and hibernate mapping module
Tips for Build.xml
Services are in org.openmrs.api package.
UserService has basic methods that act on simple openmrs objects, as opposed to table columns. UserServiceImpl is its implementation.
Controllers are where access of services happens.
Spring injects the specific implementation into the service (such as UserService) at startup.
In openmrs-trunk, applicationContext-service.xml has the setup config for Spring.
This bean called BasicModuleFormController is of type BasicModuleFormController. Spring at startup instantiates this class, calls this setter, and passes its associated string
If you want to create a service, start from the module start page at http://modules.openmrs.org/modules/ - see the Example code - http://dev.openmrs.org/browser/openmrs-modules - to copy/paste code snippets. On modules wiki page at http://openmrs.org/wiki/Modules, see the Overall Module Structure listing.
Calling the moduleService.
SessionFactory - used by Hibernate
_ Code examples are incomplete and probably quite wrong... _
Must implement the DAO method.
Creating the interface for the DAO
Criteria in hibernate is a way to build sql objects in hibernate - user Java objects
Opened up the controller
The service upon startup is in the Context. Address it thusly:
Should not cache this service - if it's unloaded and reloaded - length of the object is the length of time of the module. Service itself may cache things. When reloaded the cache is cleared up.
Allows your module to affect the services of another module or of core.
"Anytime a Person method is called, call my method"
AOP only works on the entire class.
Your service will be called on every get, delete, etc.
3 different types of AOP
If you are doing an around advice, use the matches method
Best place to find a list of methods - attach source to your project.(Demo on how to do this in Eclipse. Browse to attach source)
Javadocs are at doc.openmrs.org.