Java Code Examples for org.springframework.stereotype.Component#value()
The following examples show how to use
org.springframework.stereotype.Component#value() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClassReloaderImpl.java From tephra with MIT License | 6 votes |
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; }
Example 2
Source File: RpcDefinitionPostProcessor.java From joyrpc with Apache License 2.0 | 5 votes |
/** * 获取组件名称 * * @param providerClass 服务提供接口类 * @return 服务名称 */ protected String getComponentName(final Class<?> providerClass) { String name = null; Component component = findAnnotation(providerClass, Component.class); if (component != null) { name = component.value(); } if (isEmpty(name)) { Service service = findAnnotation(providerClass, Service.class); if (service != null) { name = service.value(); } } return name; }
Example 3
Source File: DefaultMethodInvoker.java From dubbox with Apache License 2.0 | 5 votes |
@Override public void setTargetClass(Class<?> targetClass) { this.targetClass = targetClass; if (StringUtils.isBlank(targetObjectId)) { Component component = AnnotationUtils.findAnnotation(targetClass, Component.class); String beanName = component.value(); if (StringUtils.isBlank(beanName)) { beanName = StringUtils.uncapitalize(targetClass.getSimpleName()); } this.targetObjectId = beanName; } }
Example 4
Source File: NodeCondComponent.java From liteFlow with Apache License 2.0 | 5 votes |
@Override protected void process() throws Exception { Class<?> clazz = this.processCond(); Component component = clazz.getAnnotation(Component.class); String nodeId = component.value(); this.getSlot().setCondResult(this.getClass().getName(), nodeId); }
Example 5
Source File: SpringBeanFactory.java From super-csv-annotation with Apache License 2.0 | 5 votes |
private String getBeanName(final Class<?> clazz) { final Component componentAnno = clazz.getAnnotation(Component.class); if(componentAnno != null && !componentAnno.value().isEmpty()) { return componentAnno.value(); } final Service serviceAnno = clazz.getAnnotation(Service.class); if(serviceAnno != null && !serviceAnno.value().isEmpty()) { return serviceAnno.value(); } final Repository repositoryAnno = clazz.getAnnotation(Repository.class); if(repositoryAnno != null && !repositoryAnno.value().isEmpty()) { return repositoryAnno.value(); } final Controller controllerAnno = clazz.getAnnotation(Controller.class); if(controllerAnno != null && !controllerAnno.value().isEmpty()) { return controllerAnno.value(); } // ステレオタイプのアノテーションでBean名の指定がない場合は、クラス名の先頭を小文字にした名称とする。 String simpleName = uncapitalize(clazz.getSimpleName()); String[] names = applicationContext.getBeanNamesForType(clazz); if(names.length == 0) { return simpleName; } // 複数存在する場合、候補の中から一番シンプルな形式の名前で一致するものを選択する for(String name : names) { if(name.equals(simpleName)) { return name; } } // 見つからない場合は、候補の先頭のものにする。 return names[0]; }
Example 6
Source File: SpringBeanLoader.java From cuba with Apache License 2.0 | 4 votes |
public void updateContext(Collection<Class> classes) { if (beanFactory != null) { boolean needToRefreshRemotingContext = false; for (Class clazz : classes) { Service serviceAnnotation = (Service) clazz.getAnnotation(Service.class); Component componentAnnotation = (Component) clazz.getAnnotation(Component.class); Controller controllerAnnotation = (Controller) clazz.getAnnotation(Controller.class); String beanName = null; if (serviceAnnotation != null) { beanName = serviceAnnotation.value(); } else if (componentAnnotation != null) { beanName = componentAnnotation.value(); } else if (controllerAnnotation != null) { beanName = controllerAnnotation.value(); } if (StringUtils.isNotBlank(beanName)) { GenericBeanDefinition beanDefinition = new GenericBeanDefinition(); beanDefinition.setBeanClass(clazz); Scope scope = (Scope) clazz.getAnnotation(Scope.class); if (scope != null) { beanDefinition.setScope(scope.value()); } beanFactory.registerBeanDefinition(beanName, beanDefinition); } if (StringUtils.isNotBlank(beanName)) { needToRefreshRemotingContext = true; } } if (needToRefreshRemotingContext) { ApplicationContext remotingContext = RemotingContextHolder.getRemotingApplicationContext(); if (remotingContext != null && remotingContext instanceof ConfigurableApplicationContext) { ((ConfigurableApplicationContext) remotingContext).refresh(); } } } }
Example 7
Source File: SpringBeanFactory.java From xlsmapper with Apache License 2.0 | 4 votes |
/** * クラスタイプから、候補となるSpringBean名を取得する * @param targetClass SpringBeanのクラスタイプ * @return SpringBean名 */ private String getBeanName(final Class<?> targetClass) { final Component componentAnno = targetClass.getAnnotation(Component.class); if(componentAnno != null && !componentAnno.value().isEmpty()) { return componentAnno.value(); } final Service serviceAnno = targetClass.getAnnotation(Service.class); if(serviceAnno != null && !serviceAnno.value().isEmpty()) { return serviceAnno.value(); } final Repository repositoryAnno = targetClass.getAnnotation(Repository.class); if(repositoryAnno != null && !repositoryAnno.value().isEmpty()) { return repositoryAnno.value(); } final Controller controllerAnno = targetClass.getAnnotation(Controller.class); if(controllerAnno != null && !controllerAnno.value().isEmpty()) { return controllerAnno.value(); } // ステレオタイプのアノテーションでBean名の指定がない場合は、クラス名の先頭を小文字にした名称とする。 String simpleName = Utils.uncapitalize(targetClass.getSimpleName()); String[] names = applicationContext.getBeanNamesForType(targetClass); if(names.length == 0) { return simpleName; } // 複数存在する場合、候補の中から一番シンプルな形式の名前で一致するものを選択する for(String name : names) { if(name.equals(simpleName)) { return name; } } // 見つからない場合は、候補の先頭のものにする。 return names[0]; }