Wiki Spaces

Documentation
Projects
Resources

Get Help from Others

Q&A: Ask OpenMRS
Discussion: OpenMRS Talk
Real-Time: IRC Chat | Slack

Documentation

Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Programming to Interfaces

All of our services are interfaces. The default implementation of these services are named *ServiceImpl.java. The implementations can be found in the impl directory of the package.

In order to create a new implementation of a service (for whatever unknown reason that would be in the future), we would only need to change the file specified in Spring's /metadata/api/spring/application-context.xml file.

...

OpenMRS is intentionally built with multiple layers in mind. One of the layers is a java API that can be used in other projects just as easily as it can be inside of OpenMRS.

(TODO: Link to javadocs)
(TODO: overview of openmrs database access via objects)

Context Singleton

Services are accessed in a static way from the org.openmrs.api.context.Context object:

Code Block
UserService userService = Context.getUserService();
User bobObject = userService.findUser("bob");

The Context object has two primarily goals. Serve up Access to the OpenMRS services (found in the ServiceContext) and serve up the actions for the current user via the UserContext. The UserContext has been extracted out of the Context. The Context and ServiceContext (and hence the services inside of it) remain as singletons while the small UserContext is duplicated for each user that is currently logged in.and access to the currently logged in user.

Programming to Interfaces

All of our services are interfaces. The default implementation of these services are named *ServiceImpl.java. The implementations can be found in the impl directory of the package.

In order to create a new implementation of a service (for whatever unknown reason that would be in the future), we would only need to change the file specified in Spring's /metadata/api/spring/application-context.xml file.

Authentication and Authorization

...