當前位置: 首頁>>代碼示例>>Java>>正文


Java BeanDefinition.isSingleton方法代碼示例

本文整理匯總了Java中org.springframework.beans.factory.config.BeanDefinition.isSingleton方法的典型用法代碼示例。如果您正苦於以下問題:Java BeanDefinition.isSingleton方法的具體用法?Java BeanDefinition.isSingleton怎麽用?Java BeanDefinition.isSingleton使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.beans.factory.config.BeanDefinition的用法示例。


在下文中一共展示了BeanDefinition.isSingleton方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: isJaxrsResourceClass

import org.springframework.beans.factory.config.BeanDefinition; //導入方法依賴的package包/類
/**
 * Check whether given bean definition is a valid {@link Provider} or {@link Path} resource.
 * @param definition Bean definition
 * @param beanClass Bean class
 * @return <code>true</code> if it is a valid JAX-RS resource class
 */
private static boolean isJaxrsResourceClass(BeanDefinition definition, Class<?> beanClass) {
	// check Provider
	if (beanClass.isAnnotationPresent(Provider.class)) {
		if (!definition.isSingleton()) {
			throw new BeanDefinitionValidationException("Invalid JAX-RS @Provider bean definition for bean class ["
					+ beanClass + "]: JAX-RS providers must be singleton beans");
		}
		return true;
	}
	// check Path resource
	Class<?> pathClass = AnnotationUtils.getClassWithAnnotation(beanClass, Path.class);
	if (pathClass != null) {
		return true;
	}
	return false;
}
 
開發者ID:holon-platform,項目名稱:holon-jaxrs,代碼行數:23,代碼來源:JerseyResourcesPostProcessor.java

示例2: parseSingleRef

import org.springframework.beans.factory.config.BeanDefinition; //導入方法依賴的package包/類
private static void parseSingleRef(String property, Element element, BeanDefinition bd,
                                   ParserContext parserContext) {

    String value = element.getAttribute(property);
    if (StringUtils.isNotBlank(value)) {
        if (parserContext.getRegistry().containsBeanDefinition(value)) {
            BeanDefinition refBean = parserContext.getRegistry().getBeanDefinition(value);
            if (!refBean.isSingleton()) {
                throw new IllegalStateException("The exported service ref " + value + " must be singleton! Please set the " + value
                        + " bean scope to singleton, eg: <bean id=\"" + value + "\" scope=\"singleton\" ...>");
            }
        }
        bd.getPropertyValues().addPropertyValue(property, new RuntimeBeanReference(value));
    }
}
 
開發者ID:TFdream,項目名稱:mango,代碼行數:16,代碼來源:MangoBeanDefinitionParser.java

示例3: predictBeanType

import org.springframework.beans.factory.config.BeanDefinition; //導入方法依賴的package包/類
@Override
public Class<?> predictBeanType(Class<?> beanClass, String beanName) {
	// We only apply special treatment to ScriptFactory implementations here.
	if (!ScriptFactory.class.isAssignableFrom(beanClass)) {
		return null;
	}

	BeanDefinition bd = this.beanFactory.getMergedBeanDefinition(beanName);

	try {
		String scriptFactoryBeanName = SCRIPT_FACTORY_NAME_PREFIX + beanName;
		String scriptedObjectBeanName = SCRIPTED_OBJECT_NAME_PREFIX + beanName;
		prepareScriptBeans(bd, scriptFactoryBeanName, scriptedObjectBeanName);

		ScriptFactory scriptFactory = this.scriptBeanFactory.getBean(scriptFactoryBeanName, ScriptFactory.class);
		ScriptSource scriptSource = getScriptSource(scriptFactoryBeanName, scriptFactory.getScriptSourceLocator());
		Class<?>[] interfaces = scriptFactory.getScriptInterfaces();

		Class<?> scriptedType = scriptFactory.getScriptedObjectType(scriptSource);
		if (scriptedType != null) {
			return scriptedType;
		}
		else if (!ObjectUtils.isEmpty(interfaces)) {
			return (interfaces.length == 1 ? interfaces[0] : createCompositeInterface(interfaces));
		}
		else {
			if (bd.isSingleton()) {
				Object bean = this.scriptBeanFactory.getBean(scriptedObjectBeanName);
				if (bean != null) {
					return bean.getClass();
				}
			}
		}
	}
	catch (Exception ex) {
		if (ex instanceof BeanCreationException
				&& ((BeanCreationException) ex).getMostSpecificCause() instanceof BeanCurrentlyInCreationException) {
			if (logger.isTraceEnabled()) {
				logger.trace("Could not determine scripted object type for bean '" + beanName + "': "
						+ ex.getMessage());
			}
		}
		else {
			if (logger.isDebugEnabled()) {
				logger.debug("Could not determine scripted object type for bean '" + beanName + "'", ex);
			}
		}
	}

	return null;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:52,代碼來源:ScriptFactoryPostProcessor.java


注:本文中的org.springframework.beans.factory.config.BeanDefinition.isSingleton方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。