本文整理匯總了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);
}
示例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();
}
示例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;
}
示例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;
}
示例5: initializerFactory
/**
* Configure the initializer factory
*
* @return initializer factory
*/
@Bean
@Scope(BeanDefinition.SCOPE_SINGLETON)
public InitializerFactory initializerFactory() {
return new RuleInitializerFactory();
}