|
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.openmrs.api.context.Context
public class Context
Represents an OpenMRS Context, which may be used to
authenticate to the database and obtain services in order to interact with
the system.
The Context is split into a UserContext and ServiceContext. The UserContext is
lightweight and there is an instance for every user logged into the system. The
ServiceContext is heavier and contains each service class. This is more static
and there is only one ServiceContext per OpenMRS instance.
UserContext,
ServiceContext| Constructor Summary | |
|---|---|
Context()
Default public constructor |
|
| Method Summary | |
|---|---|
static void |
addAdvice(java.lang.Class cls,
org.aopalliance.aop.Advice advice)
Adds an AOP advice object around the given Class cls
Advice comes in the form of before or afterReturning methods |
static void |
addAdvisor(java.lang.Class cls,
org.springframework.aop.Advisor advisor)
Adds an AOP advisor around the given Class cls
Advisors can wrap around a method and effect the method before or after |
static void |
addProxyPrivilege(java.lang.String privilege)
Convenience method. |
static void |
authenticate(java.lang.String username,
java.lang.String password)
Used to authenticate user within the context |
static void |
becomeUser(java.lang.String systemId)
Become a different user. |
static void |
checkCoreDataset()
Runs through the core data (e.g. |
static void |
clearSession()
Used to clear cached objects out of a session in the middle of a unit of work. |
static void |
clearUserContext()
Clears the user context from the threadlocal. |
static void |
closeSession()
Used to define a unit of work. |
static void |
evictFromSession(java.lang.Object obj)
Used to clear a cached object out of a session in the middle of a unit of work. |
static AdministrationService |
getAdministrationService()
|
static AlertService |
getAlertService()
|
static java.util.Set<Role> |
getAllRoles(User user)
Convenience method. |
static ArdenService |
getArdenService()
|
static User |
getAuthenticatedUser()
|
static CohortService |
getCohortService()
|
static ConceptService |
getConceptService()
|
static DataSetService |
getDataSetService()
|
static java.text.SimpleDateFormat |
getDateFormat()
Gets the simple date format for the current user's locale. |
static EncounterService |
getEncounterService()
|
static FormService |
getFormService()
|
static HL7Service |
getHL7Service()
|
static java.util.Locale |
getLocale()
Convenience method. |
static LocationService |
getLocationService()
|
static LogicService |
getLogicService()
|
static MessageService |
getMessageService()
Get the message service. |
static ObsService |
getObsService()
|
static OrderService |
getOrderService()
|
static PatientService |
getPatientService()
|
static PatientSetService |
getPatientSetService()
|
static PersonService |
getPersonService()
|
static ProgramWorkflowService |
getProgramWorkflowService()
|
static ReportObjectService |
getReportObjectService()
|
static ReportService |
getReportService()
|
static java.util.Properties |
getRuntimeProperties()
Get the runtime properties that this OpenMRS instance was started with |
static SchedulerService |
getSchedulerService()
|
static java.lang.Object |
getService(java.lang.Class cls)
Used for getting services not in the previous get*Service() calls |
static UserContext |
getUserContext()
Gets the user context from the thread local. |
static UserService |
getUserService()
|
static java.lang.Object |
getVolatileUserData(java.lang.String key)
Get a piece of information for the currently authenticated user. |
static boolean |
hasPrivilege(java.lang.String privilege)
Convenience method. |
static boolean |
isAuthenticated()
|
static boolean |
isRefreshingContext()
|
static void |
logout()
logs out the "active" (authenticated) user within context |
static void |
openSession()
Used to define a unit of work. |
static void |
removeAdvice(java.lang.Class cls,
org.aopalliance.aop.Advice advice)
Removes the given AOP advice object from Class cls |
static void |
removeAdvisor(java.lang.Class cls,
org.springframework.aop.Advisor advisor)
Removes the given AOP advisor from Class cls |
static void |
removeProxyPrivilege(java.lang.String privilege)
Convenience method. |
static void |
requirePrivilege(java.lang.String privilege)
Throws an exception if the currently authenticated user does not have the specified privilege. |
void |
setContextDAO(ContextDAO dao)
Used to set the context's DAO for the application. |
static void |
setLocale(java.util.Locale locale)
Convenience method. |
static void |
setRuntimeProperties(java.util.Properties props)
Set the runtime properties to be used by this OpenMRS instance |
void |
setServiceContext(ServiceContext ctx)
Sets the service context. |
static void |
setUserContext(UserContext ctx)
Sets the user context on the thread local so that the service layer can perform authentication/authorization checks. |
static void |
setVolatileUserData(java.lang.String key,
java.lang.Object value)
Set a piece of information for the currently authenticated user. |
static void |
shutdown()
Stops the OpenMRS System Should be called after all activity has ended and application is closing |
static void |
startup(java.util.Properties props)
Starts the OpenMRS System Should be called prior to any kind of activity |
static void |
startup(java.lang.String url,
java.lang.String username,
java.lang.String password,
java.util.Properties properties)
Starts the OpenMRS System in a _non-webapp_ environment |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Context()
| Method Detail |
|---|
public void setContextDAO(ContextDAO dao)
daoContext - public static void setUserContext(UserContext ctx)
userContext - public static void clearUserContext()
public static UserContext getUserContext()
public void setServiceContext(ServiceContext ctx)
ctx -
public static void authenticate(java.lang.String username,
java.lang.String password)
throws ContextAuthenticationException
username - user's identifier token for loginpassword - user's password for authenticating to context
ContextAuthenticationException
public static void becomeUser(java.lang.String systemId)
throws ContextAuthenticationException
systemId -
ContextAuthenticationExceptionpublic static java.util.Properties getRuntimeProperties()
public static void setRuntimeProperties(java.util.Properties props)
props - runtime propertiespublic static ConceptService getConceptService()
public static EncounterService getEncounterService()
public static LocationService getLocationService()
public static ObsService getObsService()
public static PatientService getPatientService()
public static CohortService getCohortService()
public static PersonService getPersonService()
public static HL7Service getHL7Service()
public static PatientSetService getPatientSetService()
public static UserService getUserService()
public static OrderService getOrderService()
public static FormService getFormService()
public static ReportService getReportService()
public static ReportObjectService getReportObjectService()
public static DataSetService getDataSetService()
public static LogicService getLogicService()
public static AdministrationService getAdministrationService()
public static SchedulerService getSchedulerService()
public static AlertService getAlertService()
public static ArdenService getArdenService()
public static ProgramWorkflowService getProgramWorkflowService()
public static MessageService getMessageService()
public static User getAuthenticatedUser()
nullpublic static boolean isAuthenticated()
public static void logout()
authenticate(java.lang.String, java.lang.String)
public static java.util.Set<Role> getAllRoles(User user)
throws java.lang.Exception
java.lang.Exceptionpublic static boolean hasPrivilege(java.lang.String privilege)
public static void requirePrivilege(java.lang.String privilege)
throws ContextAuthenticationException
privilege -
ContextAuthenticationExceptionpublic static void addProxyPrivilege(java.lang.String privilege)
public static void removeProxyPrivilege(java.lang.String privilege)
public static void setLocale(java.util.Locale locale)
public static java.util.Locale getLocale()
public static void openSession()
public static void closeSession()
public static void clearSession()
public static void evictFromSession(java.lang.Object obj)
obj - The object to evict/remove from the sessionpublic static void startup(java.util.Properties props)
Properties - runtime properties to use for startup
public static void startup(java.lang.String url,
java.lang.String username,
java.lang.String password,
java.util.Properties properties)
url - database url like "jdbc:mysql://localhost:3306/openmrs?autoReconnect=true"username - connection usernamepassword - connection passwordProperties - other startup propertiespublic static void shutdown()
public static java.lang.Object getService(java.lang.Class cls)
cls -
public static void addAdvisor(java.lang.Class cls,
org.springframework.aop.Advisor advisor)
cls
Advisors can wrap around a method and effect the method before or after
cls - advisor -
public static void addAdvice(java.lang.Class cls,
org.aopalliance.aop.Advice advice)
cls
Advice comes in the form of before or afterReturning methods
cls - advice -
public static void removeAdvisor(java.lang.Class cls,
org.springframework.aop.Advisor advisor)
cls
cls - advisor -
public static void removeAdvice(java.lang.Class cls,
org.aopalliance.aop.Advice advice)
cls
cls - advice - public static void checkCoreDataset()
public static java.lang.Object getVolatileUserData(java.lang.String key)
key - identifying string for the information
public static void setVolatileUserData(java.lang.String key,
java.lang.Object value)
key - identifying string for this informationvalue - information to be storedpublic static java.text.SimpleDateFormat getDateFormat()
OpenmrsConstants.OPENMRS_LOCALE_DATE_PATTERNS()public static boolean isRefreshingContext()
ServiceContext.isRefreshingContext()
|
OpenMRS-trunk | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||