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


Java BeanDefinition.SCOPE_SINGLETON属性代码示例

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


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

示例1: aopFolderWatcher

/**
 * Configures the AOP file System watcher to observe the paths passed in for the
 * jboss aop folder.
 */
@Bean
@Scope(BeanDefinition.SCOPE_SINGLETON)
@Autowired
public AopXmlLoader aopFolderWatcher(Environment env) throws JaffaRulesFrameworkException {

    // Check to see if this is supported. If explicitly disabled, then return early.
    if (env.containsProperty("jaffa.aop.springconfig.disabled") &&
            env.getProperty("jaffa.aop.springconfig.disabled").equals("true")) {
        return null;
    }

    String aopPath =
            env.containsProperty("jboss.aop.path") ?
                    env.getProperty("jboss.aop.path") :
                    AopConstants.DEFAULT_AOP_PATTERN;

    List<String> paths = Arrays.asList(aopPath.split(";"));
    return new AopXmlLoader(paths);
}
 
开发者ID:jaffa-projects,项目名称:jaffa-framework,代码行数:23,代码来源:JaffaRulesConfig.java

示例2: generateJson

/**
 * Actually generate a JSON snapshot of the beans in the given ApplicationContexts.
 * <p>This implementation doesn't use any JSON parsing libraries in order to avoid
 * third-party library dependencies. It produces an array of context description
 * objects, each containing a context and parent attribute as well as a beans
 * attribute with nested bean description objects. Each bean object contains a
 * bean, scope, type and resource attribute, as well as a dependencies attribute
 * with a nested array of bean names that the present bean depends on.
 * @param contexts the set of ApplicationContexts
 * @return the JSON document
 */
protected String generateJson(Set<ConfigurableApplicationContext> contexts) {
	StringBuilder result = new StringBuilder("[\n");
	for (Iterator<ConfigurableApplicationContext> it = contexts.iterator(); it.hasNext();) {
		ConfigurableApplicationContext context = it.next();
		result.append("{\n\"context\": \"").append(context.getId()).append("\",\n");
		if (context.getParent() != null) {
			result.append("\"parent\": \"").append(context.getParent().getId()).append("\",\n");
		}
		else {
			result.append("\"parent\": null,\n");
		}
		result.append("\"beans\": [\n");
		ConfigurableListableBeanFactory bf = context.getBeanFactory();
		String[] beanNames = bf.getBeanDefinitionNames();
		boolean elementAppended = false;
		for (String beanName : beanNames) {
			BeanDefinition bd = bf.getBeanDefinition(beanName);
			if (isBeanEligible(beanName, bd, bf)) {
				if (elementAppended) {
					result.append(",\n");
				}
				result.append("{\n\"bean\": \"").append(beanName).append("\",\n");
				String scope = bd.getScope();
				if (!StringUtils.hasText(scope)) {
					scope = BeanDefinition.SCOPE_SINGLETON;
				}
				result.append("\"scope\": \"").append(scope).append("\",\n");
				Class<?> beanType = bf.getType(beanName);
				if (beanType != null) {
					result.append("\"type\": \"").append(beanType.getName()).append("\",\n");
				}
				else {
					result.append("\"type\": null,\n");
				}
				String resource = StringUtils.replace(bd.getResourceDescription(), "\\", "/");
				result.append("\"resource\": \"").append(resource).append("\",\n");
				result.append("\"dependencies\": [");
				String[] dependencies = bf.getDependenciesForBean(beanName);
				if (dependencies.length > 0) {
					result.append("\"");
				}
				result.append(StringUtils.arrayToDelimitedString(dependencies, "\", \""));
				if (dependencies.length > 0) {
					result.append("\"");
				}
				result.append("]\n}");
				elementAppended = true;
			}
		}
		result.append("]\n");
		result.append("}");
		if (it.hasNext()) {
			result.append(",\n");
		}
	}
	result.append("]");
	return result.toString();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:69,代码来源:LiveBeansView.java

示例3: ruleValidatorFactory

/**
 * Configure the validator factory
 *
 * @return validator factory
 */
@Bean(name = "ruleValidatorFactory")
@Scope(BeanDefinition.SCOPE_SINGLETON)
public RuleValidatorFactory ruleValidatorFactory() {
    RuleValidatorFactory factory = new RuleValidatorFactory();
    factory.addValidatorTypes("mandatory", "max-length", "min-length", "case-type", "max-value", "min-value",
            "candidate-key", "comment", "foreign-key", "generic-foreign-key", "in-list",
            "not-in-list", "partial-foreign-key", "pattern", "primary-key");
    return factory;
}
 
开发者ID:jaffa-projects,项目名称:jaffa-framework,代码行数:14,代码来源:JaffaRulesConfig.java

示例4: conversionService

/**
 * Load the properties files used in application contexts here
 *
 * @return the initialized instance of the PropertyPlaceholderConfigurer class
 */
@Bean(name="properties")
@Scope(BeanDefinition.SCOPE_SINGLETON)
public PropertyPlaceholderConfigurer conversionService() {
    PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer();
    Resource resource1 = new ClassPathResource("application_file_1.properties");
    Resource resource2 = new ClassPathResource("application_file_2.properties");
    configurer.setLocations(resource1, resource2);
    return configurer;
}
 
开发者ID:jaffa-projects,项目名称:jaffa-framework,代码行数:14,代码来源:PropertyPlaceholderConfig.java

示例5: initializerFactory

/**
 * Configure the initializer factory
 *
 * @return initializer factory
 */
@Bean
@Scope(BeanDefinition.SCOPE_SINGLETON)
public InitializerFactory initializerFactory() {
    return new RuleInitializerFactory();
}
 
开发者ID:jaffa-projects,项目名称:jaffa-framework,代码行数:10,代码来源:JaffaRulesConfig.java


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