public class ServiceServiceImpl implements ServiceService, ApplicationContextAware {
@Override
public void setApplicationContext( applicationContext)
throws BeansException {
= applicationContext;
}
public void addBeanService(Service service) throws BVSException {
if (!(())) {
Class<?> serviceClass = getServiceClass(());
BeanDefinitionBuilder beanDefinitionBuilder = (serviceClass);
("servicename", ());
registerBean((), ());
}
}
/**
* @desc Register beans with spring container
* @param beanName
* @param beanDefinition
*/
private void registerBean(String beanName, BeanDefinition beanDefinition) {
ConfigurableApplicationContext configurableApplicationContext = (ConfigurableApplicationContext) context;
BeanDefinitionRegistry beanDefinitonRegistry = (BeanDefinitionRegistry) configurableApplicationContext
.getBeanFactory();
(beanName, beanDefinition);
}
/**
* @desc Find class by class name
* @param className
* @return
* @throws BVSException
*/
private Class<?> getServiceClass(String className) throws BVSException {
try {
return ().getContextClassLoader().loadClass(className);
} catch (ClassNotFoundException e) {
("not found service class:" + className, e);
throw new BVSException("not found service class:" + className, e);
}
}
}