当前位置: 首页>>代码示例>>Java>>正文


Java Component.value方法代码示例

本文整理汇总了Java中org.springframework.stereotype.Component.value方法的典型用法代码示例。如果您正苦于以下问题:Java Component.value方法的具体用法?Java Component.value怎么用?Java Component.value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.stereotype.Component的用法示例。


在下文中一共展示了Component.value方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getBeanName

import org.springframework.stereotype.Component; //导入方法依赖的package包/类
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;
}
 
开发者ID:heisedebaise,项目名称:tephra,代码行数:20,代码来源:ClassReloaderImpl.java

示例2: getBeanName

import org.springframework.stereotype.Component; //导入方法依赖的package包/类
public static String getBeanName(Class<?> beanClass) {
	String beanName = null;
	Named nameAnn = beanClass.getAnnotation(Named.class);
	//todo 如果没有named标注,则不加入bean;
	if (nameAnn != null) {
		if (Utils.hasLength(nameAnn.value()))
			beanName = nameAnn.value();
	}
	else {
		Component componentAnn = beanClass.getAnnotation(Component.class);
		if (componentAnn != null) {
			if (Utils.hasLength(componentAnn.value()))
				beanName = componentAnn.value();
		}
	}
	
	if (!Utils.hasLength(beanName)) {
		beanName = Utils.beanName(beanClass.getSimpleName());
	}
	return beanName;
}
 
开发者ID:niaoge,项目名称:spring-dynamic,代码行数:22,代码来源:Commons.java

示例3: getBeanName

import org.springframework.stereotype.Component; //导入方法依赖的package包/类
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名の指定がない場合は、クラス名の先頭を小文字にした名称とする。
    return uncapitalize(clazz.getSimpleName());
}
 
开发者ID:mygreen,项目名称:super-csv-annotation,代码行数:26,代码来源:SpringBeanFactory.java

示例4: process

import org.springframework.stereotype.Component; //导入方法依赖的package包/类
@Nullable
@Override
public <T> AnnotatedComponent<T> process(Scope scope, Class<T> clazz) {
    Component widget = clazz.getAnnotation(Component.class);
    if (widget != null) {
        return new AnnotatedComponent(clazz, widget.value(), ComponentType.BEAN);
    }
    return null;
}
 
开发者ID:worldiety,项目名称:homunculus,代码行数:10,代码来源:SPRComponentWidget.java

示例5: updateContext

import org.springframework.stereotype.Component; //导入方法依赖的package包/类
public void updateContext(Collection<Class> classes) {
    if (beanFactory != null) {
        boolean needToRefreshRemotingContext = false;
        for (Class clazz : classes) {
            Service serviceAnnotation = (Service) clazz.getAnnotation(Service.class);
            ManagedBean managedBeanAnnotation = (ManagedBean) clazz.getAnnotation(ManagedBean.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 (managedBeanAnnotation != null) {
                beanName = managedBeanAnnotation.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();
            }
        }
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:45,代码来源:SpringBeanLoader.java

示例6: getAppInfo

import org.springframework.stereotype.Component; //导入方法依赖的package包/类
@Override
public Map<String, Object> getAppInfo() {
	if (appinfo == null) {
		Map<String, Object> viewInfo = getParamDefaultVals();
		HashMap<String, Object> ret = new HashMap<String, Object>();
		
		// get the annotation, use it to fill in any values not declared in the param
		HMPAppInfo annotation = getClass().getAnnotation(HMPAppInfo.class);
		Component annotation2 = getClass().getAnnotation(Component.class);
		
		// get the name from: 1) declared name, 2) ViewInfoParam, 3) annotation, 4) class name
		String name = this.name;
		if (name == null) {
			name = (String) viewInfo.get("view.name");
		}
		if (name == null && annotation != null) {
			name = annotation.title();
		}
		if (name == null) {
			name = getClass().getName();
		}
		
		// get the ID from: 1) declared ID, 2) @Component annotation, 3) class name
		String id = this.id;
		if (id == null && annotation2 != null) {
			id = annotation2.value();
		}
		if (id == null) {
			id = getClass().getName();
		}
		
		// TODO: this probably needs to be delegated to the subclasses
		String type = "gov.va.cpe.frame";
		if (this.type != null) {
			type = this.type;
		} else if (annotation != null) {
			type = annotation.value();
		}
		
		// return the results
		ret.put("type", type);
		ret.put("name", name);
		ret.put("id", id);
		ret.put("code", ret.get("id"));
		ret.put("resource", this.resource);
		appinfo = ret;
	}
	
	return appinfo;
}
 
开发者ID:KRMAssociatesInc,项目名称:eHMP,代码行数:51,代码来源:Frame.java


注:本文中的org.springframework.stereotype.Component.value方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。