Skip to content

BAH-4319 | Initialize service and dao beans through moduleApplicationContext.xml#20

Merged
mohan-13 merged 2 commits into
masterfrom
BAH-4319
Dec 3, 2025
Merged

BAH-4319 | Initialize service and dao beans through moduleApplicationContext.xml#20
mohan-13 merged 2 commits into
masterfrom
BAH-4319

Conversation

@mohan-13

@mohan-13 mohan-13 commented Dec 3, 2025

Copy link
Copy Markdown
Member

This PR removes the use of Spring annotations for initialising service and dao. The beans are defined through moduleApplicationContext.xml injecting OpenMRS service interceptors. This also makes the service available on OpenMRS service context.


private SessionFactory sessionFactory;

public void setSessionFactory(SessionFactory sessionFactory) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You dont need a setter. You have the constructor taking the sessionFactory.
If you are going to wire by the moduleApplicationContext.xml - remove the @repository annotation from EpisodeAttributeTypeDaoImpl. Because in the moduleapplicationContext - we have the component scan.


private EpisodeAttributeTypeDao episodeAttributeTypeDao;

public void setEpisodeAttributeTypeDao(EpisodeAttributeTypeDao episodeAttributeTypeDao) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above. Constructor already takes in the Dao. If you want to wire using app context xml, remove the @service annoatation

@@ -25,4 +25,73 @@

<context:component-scan base-package="org.openmrs.module.episodes"/>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to manually wire up, remove the component scan

<context:component-scan base-package="org.openmrs.module.episodes"/>

<bean id="episodeDao" class="org.openmrs.module.episodes.dao.impl.EpisodeDAOImpl">
<property name="sessionFactory">

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You dont need a property setter. You can use constructor-arg

</bean>
<bean id="episodeAttributeTypeDao" class="org.openmrs.module.episodes.dao.impl.EpisodeAttributeTypeDaoImpl">
<property name="sessionFactory">
<ref bean="sessionFactory"/>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You dont need a property setter. You can use constructor-arg

</property>
<property name="target">
<bean class="org.openmrs.module.episodes.service.impl.EpisodeServiceImpl">
<property name="episodeDAO">

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You dont need a property setter. You can use constructor-arg

<ref bean="transactionManager"/>
</property>
<property name="target">
<bean class="org.openmrs.module.episodes.service.impl.EpisodeAttributeTypeServiceImpl">

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You dont need a property setter. You can use constructor-arg

@mohan-13 mohan-13 merged commit 009f5ad into master Dec 3, 2025
2 checks passed
@mohan-13 mohan-13 deleted the BAH-4319 branch December 3, 2025 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants