当前位置: 首页>>代码示例>>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;未经允许,请勿转载。