本文整理汇总了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;
}
示例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;
}
示例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());
}
示例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;
}
示例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();
}
}
}
}
示例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;
}