use of org.jowidgets.cap.service.api.annotation.CapService in project jo-client-platform by jo-source.
the class ServicePostProcessor method postProcessAfterInitialization.
@Override
public Object postProcessAfterInitialization(final Object bean, final String beanName) {
try {
final CapService serviceAnnotation = beanFactory.findAnnotationOnBean(beanName, CapService.class);
if (serviceAnnotation != null) {
final Class<?> serviceType;
if (serviceAnnotation.type() != void.class) {
serviceType = serviceAnnotation.type();
} else {
if (bean.getClass().getInterfaces().length == 0) {
throw new RuntimeException(beanName + " must implement at least one interface or type must be set on @CapService annotation");
}
serviceType = bean.getClass().getInterfaces()[0];
}
String id = serviceAnnotation.id();
if (id.isEmpty()) {
id = serviceType.getName();
}
final IServiceId<Object> serviceId = new ServiceId<Object>(id, serviceType);
SpringServiceProvider.getInstance().addService(serviceId, beanProxyFactory.createProxy(beanName, serviceType));
}
} catch (final NoSuchBeanDefinitionException e) {
}
return bean;
}
Aggregations