io.spotnext.spring.web.controller.AbstractBaseController Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spot-spring-web-support Show documentation
Show all versions of spot-spring-web-support Show documentation
The spOt microservice framework.
package io.spotnext.spring.web.controller;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import io.spotnext.core.infrastructure.service.LoggingService;
import io.spotnext.core.infrastructure.support.spring.Registry;
/**
* Abstract AbstractBaseController class.
*
* @author mojo2012
* @version 1.0
* @since 1.0
*/
public abstract class AbstractBaseController implements ApplicationContextAware {
private ApplicationContext applicationContext;
@Autowired
protected LoggingService loggingService;
/** {@inheritDoc} */
@Override
public void setApplicationContext(final ApplicationContext context) throws BeansException {
this.applicationContext = context;
}
/**
* getWebApplicationContext.
*
* @return a {@link org.springframework.context.ApplicationContext} object.
*/
public ApplicationContext getWebApplicationContext() {
return this.applicationContext;
}
protected T getBean(final Class beanType) {
return Registry.getApplicationContext().getBean(beanType);
}
protected T getBean(final Class beanType, final String beanName) {
return Registry.getApplicationContext().getBean(beanName, beanType);
}
}