use of org.springframework.stereotype.Repository in project ff4j by ff4j.
the class FeatureAdvisor method getExecutedBeanName.
/**
* Find bean name related to current method invocation.
* @param pMInvoc
* current method invocation
* @return
* bean name related to this method
*/
protected String getExecutedBeanName(MethodInvocation mi) {
Class<?> targetClass = getExecutedClass(mi);
Component component = targetClass.getAnnotation(Component.class);
if (component != null) {
return component.value();
}
Service service = targetClass.getAnnotation(Service.class);
if (service != null) {
return service.value();
}
Repository repo = targetClass.getAnnotation(Repository.class);
if (repo != null) {
return repo.value();
}
// There is no annotation on the bean, still be declared in applicationContext.xml
try {
// Use BeanDefinition names to loop on each bean and fetch target if proxified
for (String beanName : appCtx.getBeanDefinitionNames()) {
Object bean = appCtx.getBean(beanName);
if (AopUtils.isJdkDynamicProxy(bean)) {
bean = ((Advised) bean).getTargetSource().getTarget();
}
if (bean != null && bean.getClass().isAssignableFrom(targetClass)) {
return beanName;
}
}
} catch (Exception e) {
throw new RuntimeException("ff4j-aop: Cannot read bheind proxy target", e);
}
throw new IllegalArgumentException("ff4j-aop: Feature bean must be annotated as a Service or a Component");
}
use of org.springframework.stereotype.Repository in project tephra by heisedebaise.
the class ClassReloaderImpl method getBeanName.
private String getBeanName(Class<?> clazz) {
Component component = clazz.getAnnotation(Component.class);
if (component != null)
return component.value();
Repository repository = clazz.getAnnotation(Repository.class);
if (repository != null)
return repository.value();
Service service = clazz.getAnnotation(Service.class);
if (service != null)
return service.value();
Controller controller = clazz.getAnnotation(Controller.class);
if (controller != null)
return controller.value();
return null;
}
Aggregations