-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
O3-3347: Follow-up; don't use mvc:annotation-driven (#61)
- Loading branch information
Showing
2 changed files
with
29 additions
and
6 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
omod/src/main/java/org/openmrs/module/spa/spring/SpaBeanPostProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.openmrs.module.spa.spring; | ||
|
||
import org.openmrs.module.spa.SpaResourceConverter; | ||
import org.springframework.beans.BeansException; | ||
import org.springframework.beans.factory.config.BeanPostProcessor; | ||
import org.springframework.context.ApplicationContext; | ||
import org.springframework.context.ApplicationContextAware; | ||
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter; | ||
|
||
public class SpaBeanPostProcessor implements BeanPostProcessor, ApplicationContextAware { | ||
|
||
private ApplicationContext applicationContext; | ||
|
||
@Override | ||
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { | ||
if (bean instanceof RequestMappingHandlerAdapter) { | ||
RequestMappingHandlerAdapter handlerMappingAdapter = (RequestMappingHandlerAdapter) bean; | ||
handlerMappingAdapter.getMessageConverters().add(0, applicationContext.getBean(SpaResourceConverter.class)); | ||
} | ||
return bean; | ||
} | ||
|
||
@Override | ||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { | ||
this.applicationContext = applicationContext; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters