當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。