org.springframework.stereotype.Component#value ( )源码实例Demo

下面列出了org.springframework.stereotype.Component#value ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: tephra   文件: ClassReloaderImpl.java
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;
}
 
源代码2 项目: joyrpc   文件: RpcDefinitionPostProcessor.java
/**
 * 获取组件名称
 *
 * @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;
}
 
源代码3 项目: dubbox   文件: DefaultMethodInvoker.java
@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;
	}
}
 
源代码4 项目: liteFlow   文件: NodeCondComponent.java
@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);
}
 
源代码5 项目: super-csv-annotation   文件: SpringBeanFactory.java
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];
    }
 
源代码6 项目: cuba   文件: SpringBeanLoader.java
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();
            }
        }
    }
}
 
源代码7 项目: xlsmapper   文件: SpringBeanFactory.java
/**
 * クラスタイプから、候補となる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];
}
 
 同类方法