public class ServiceContext extends Object implements org.springframework.context.ApplicationContextAware
Service Context
, which returns the services represented
throughout the system. Context
class. getService(Class)
Context
Modifier and Type | Method and Description |
---|---|
void |
addAdvice(Class cls,
org.aopalliance.aop.Advice advice) |
void |
addAdvisor(Class cls,
org.springframework.aop.Advisor advisor) |
static void |
destroyInstance()
Null out the current instance of the ServiceContext.
|
void |
doneRefreshingContext()
Should be called right after any spring context refresh This wakes up all calls to
getService that were waiting because
startRefreshingContext was called |
AdministrationService |
getAdministrationService() |
AlertService |
getAlertService() |
org.springframework.context.ApplicationContext |
getApplicationContext() |
CohortService |
getCohortService() |
ConceptService |
getConceptService() |
ConditionService |
getConditionService() |
DatatypeService |
getDatatypeService()
Gets the datatype service
|
DiagnosisService |
getDiagnosisService() |
EncounterService |
getEncounterService() |
FormService |
getFormService() |
HL7Service |
getHL7Service() |
static ServiceContext |
getInstance()
There should only be one ServiceContext per openmrs (java virtual machine).
|
LocationService |
getLocationService() |
LogicService |
getLogicService() |
MedicationDispenseService |
getMedicationDispenseService() |
MessageService |
getMessageService() |
MessageSourceService |
getMessageSourceService()
Gets the MessageSourceService used in the context.
|
List<OpenmrsService> |
getModuleOpenmrsServices(String modulePackage)
Gets a list of services implementing the
OpenmrsService interface, for a given
module. |
ObsService |
getObsService() |
OrderService |
getOrderService() |
OrderSetService |
getOrderSetService() |
PatientService |
getPatientService() |
PersonService |
getPersonService() |
ProgramWorkflowService |
getProgramWorkflowService() |
ProviderService |
getProviderService()
Gets the provider service.
|
<T> T |
getRegisteredComponent(String beanName,
Class<T> type)
Retrieves a bean that match the given type (including subclasses) and name.
|
<T> List<T> |
getRegisteredComponents(Class<T> type)
Retrieves all Beans which have been registered in the Spring
ApplicationContext that
match the given object type (including subclasses). |
SchedulerService |
getSchedulerService() |
SerializationService |
getSerializationService() |
<T> T |
getService(Class<? extends T> cls)
Returns the current proxy that is stored for the Class
cls |
UserService |
getUserService() |
VisitService |
getVisitService()
Gets the visit service.
|
boolean |
isRefreshingContext()
Returns true/false whether startRefreshingContext() has been called without a subsequent call
to doneRefreshingContext() yet.
|
boolean |
isUseSystemClassLoader()
Checks if we are using the system class loader.
|
void |
removeAdvice(Class cls,
org.aopalliance.aop.Advice advice) |
void |
removeAdvisor(Class cls,
org.springframework.aop.Advisor advisor) |
void |
setAdministrationService(AdministrationService administrationService) |
void |
setAlertService(AlertService alertService) |
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext) |
void |
setCohortService(CohortService cs) |
void |
setConceptService(ConceptService conceptService) |
void |
setConditionService(ConditionService conditionService) |
void |
setDatatypeService(DatatypeService datatypeService)
Sets the datatype service
|
void |
setDiagnosisService(DiagnosisService diagnosisService) |
void |
setEncounterService(EncounterService encounterService) |
void |
setFormService(FormService formService) |
void |
setHl7Service(HL7Service hl7Service) |
void |
setLocationService(LocationService locationService) |
void |
setLogicService(LogicService logicService) |
void |
setMedicationDispenseService(MedicationDispenseService medicationDispenseService) |
void |
setMessageService(MessageService messageService)
Sets the message service.
|
void |
setMessageSourceService(MessageSourceService messageSourceService)
Sets the MessageSourceService used in the context.
|
void |
setModuleService(List<Object> params)
Allow other services to be added to our service layer
Classes will be found/loaded with the ModuleClassLoader params [0] = string representing the service interfaceparams [1] = service instance |
void |
setObsService(ObsService obsService) |
void |
setOrderService(OrderService orderService) |
void |
setOrderSetService(OrderSetService orderSetService) |
void |
setPatientService(PatientService patientService) |
void |
setPersonService(PersonService personService) |
void |
setProgramWorkflowService(ProgramWorkflowService programWorkflowService) |
void |
setProviderService(ProviderService providerService)
Sets the provider service.
|
static void |
setRefreshingContext(boolean refreshingContext) |
void |
setSchedulerService(SchedulerService schedulerService)
Set the scheduler service.
|
void |
setSerializationService(SerializationService serializationService) |
void |
setService(Class cls,
Object classInstance)
Allow other services to be added to our service layer
|
void |
setUserService(UserService userService) |
void |
setUseSystemClassLoader(boolean useSystemClassLoader)
Set this service context to use the system class loader if the
useSystemClassLoader is set to true. |
void |
setVisitService(VisitService visitService)
Sets the visit service.
|
void |
startRefreshingContext()
Should be called right before any spring context refresh This forces all calls to
getService to wait until
doneRefreshingContext is called |
public static ServiceContext getInstance()
Context
public static void destroyInstance()
public EncounterService getEncounterService()
public LocationService getLocationService()
public ObsService getObsService()
public ConditionService getConditionService()
public void setConditionService(ConditionService conditionService)
conditionService
- condition related servicepublic DiagnosisService getDiagnosisService()
public void setDiagnosisService(DiagnosisService diagnosisService)
diagnosisService
- diagnosis related servicepublic MedicationDispenseService getMedicationDispenseService()
public void setMedicationDispenseService(MedicationDispenseService medicationDispenseService)
medicationDispenseService
- MedicationDispense related servicepublic CohortService getCohortService()
public void setCohortService(CohortService cs)
cs
- cohort related servicepublic OrderSetService getOrderSetService()
public OrderService getOrderService()
public FormService getFormService()
public SerializationService getSerializationService()
public AdministrationService getAdministrationService()
public ProgramWorkflowService getProgramWorkflowService()
public LogicService getLogicService()
public SchedulerService getSchedulerService()
public void setSchedulerService(SchedulerService schedulerService)
schedulerService
- public AlertService getAlertService()
public void setAlertService(AlertService alertService)
alertService
- public void setProgramWorkflowService(ProgramWorkflowService programWorkflowService)
programWorkflowService
- public void setLogicService(LogicService logicService)
logicService
- public MessageService getMessageService()
public void setMessageService(MessageService messageService)
messageService
- public HL7Service getHL7Service()
public void setHl7Service(HL7Service hl7Service)
hl7Service
- the hl7Service to setpublic void setAdministrationService(AdministrationService administrationService)
administrationService
- the administrationService to setpublic void setEncounterService(EncounterService encounterService)
encounterService
- the encounterService to setpublic void setLocationService(LocationService locationService)
locationService
- the LocationService to setpublic void setFormService(FormService formService)
formService
- the formService to setpublic void setObsService(ObsService obsService)
obsService
- the obsService to setpublic void setOrderService(OrderService orderService)
orderService
- the orderService to setpublic void setOrderSetService(OrderSetService orderSetService)
orderSetService
- the orderSetService to setpublic void setSerializationService(SerializationService serializationService)
serializationService
- public PatientService getPatientService()
public void setPatientService(PatientService patientService)
patientService
- the patientService to setpublic PersonService getPersonService()
public void setPersonService(PersonService personService)
personService
- the personService to setpublic ConceptService getConceptService()
public void setConceptService(ConceptService conceptService)
conceptService
- the conceptService to setpublic UserService getUserService()
public void setUserService(UserService userService)
userService
- the userService to setpublic MessageSourceService getMessageSourceService()
public void setMessageSourceService(MessageSourceService messageSourceService)
messageSourceService
- the MessageSourceService to usepublic void addAdvisor(Class cls, org.springframework.aop.Advisor advisor)
cls
- advisor
- public void addAdvice(Class cls, org.aopalliance.aop.Advice advice)
cls
- advice
- public void removeAdvisor(Class cls, org.springframework.aop.Advisor advisor)
cls
- advisor
- public void removeAdvice(Class cls, org.aopalliance.aop.Advice advice)
cls
- advice
- public <T> T getService(Class<? extends T> cls)
cls
cls
- cls
classpublic void setService(Class cls, Object classInstance)
cls
- Interface to proxyclassInstance
- the actual instance of the cls
interfacepublic void setModuleService(List<Object> params)
params
[0] = string representing the service interfaceparams
[1] = service instanceparams
- list of parameterspublic void setUseSystemClassLoader(boolean useSystemClassLoader)
useSystemClassLoader
is set to true. If false, the openmrs class loader is used
to load module servicesuseSystemClassLoader
- true/false whether to use the system class loaderpublic boolean isUseSystemClassLoader()
public static void setRefreshingContext(boolean refreshingContext)
public void startRefreshingContext()
doneRefreshingContext
is calledpublic void doneRefreshingContext()
startRefreshingContext
was calledpublic boolean isRefreshingContext()
public <T> List<T> getRegisteredComponents(Class<T> type)
ApplicationContext
that
match the given object type (including subclasses).
NOTE: This method introspects top-level beans only. It does not check nested beans which might match the specified type as well.
type
- the type of Bean to retrieve from the Spring ApplicationContext
ListableBeanFactory.getBeansOfType(Class)
public <T> T getRegisteredComponent(String beanName, Class<T> type) throws APIException
beanName
- the name of registered bean to retrievetype
- the type of bean to retrieveAPIException
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
setApplicationContext
in interface org.springframework.context.ApplicationContextAware
applicationContext
- the applicationContext to setpublic org.springframework.context.ApplicationContext getApplicationContext()
public List<OpenmrsService> getModuleOpenmrsServices(String modulePackage)
OpenmrsService
interface, for a given
module.modulePackage
- the module's package name.public VisitService getVisitService()
public void setVisitService(VisitService visitService)
visitService
- the visitService to setpublic ProviderService getProviderService()
public void setProviderService(ProviderService providerService)
providerService
- the providerService to setpublic DatatypeService getDatatypeService()
public void setDatatypeService(DatatypeService datatypeService)
datatypeService
- the datatypeService to setCopyright © 2024 OpenMRS Inc.. All rights reserved.