Example usage for org.springframework.beans.factory.support AbstractBeanDefinition SCOPE_DEFAULT

List of usage examples for org.springframework.beans.factory.support AbstractBeanDefinition SCOPE_DEFAULT

Introduction

In this page you can find the example usage for org.springframework.beans.factory.support AbstractBeanDefinition SCOPE_DEFAULT.

Prototype

String SCOPE_DEFAULT

To view the source code for org.springframework.beans.factory.support AbstractBeanDefinition SCOPE_DEFAULT.

Click Source Link

Document

Constant for the default scope name: "" , equivalent to singleton status unless overridden from a parent bean definition (if applicable).

Usage

From source file:de.acosix.alfresco.mtsupport.repo.beans.TemplatedTenantBeanEmitter.java

/**
 * {@inheritDoc}//from   w w  w  . j a  va 2 s  .  c  om
 */
@Override
public void postProcessBeanDefinitionRegistry(final BeanDefinitionRegistry registry) throws BeansException {
    if (this.isEnabled()) {
        final String enabledTenantsProperty = this.effectiveProperties
                .getProperty(this.enabledTenantPropertyKey);
        if (enabledTenantsProperty == null || enabledTenantsProperty.trim().isEmpty()) {
            LOGGER.debug("No tenants have been defined as enabled");
        } else {
            final List<String> enabledTenants = Arrays.asList(enabledTenantsProperty.trim().split("\\s*,\\s*"));
            LOGGER.debug("Processing beans {} for enabled tenants {}", this.beanNames, enabledTenants);

            for (final String beanName : this.beanNames) {
                LOGGER.debug("Processing {}", beanName);
                final String templateBeanName = beanName + TenantBeanUtils.TENANT_BEAN_TEMPLATE_SUFFIX;
                if (registry.containsBeanDefinition(templateBeanName)) {
                    final BeanDefinition beanDefinition = registry.getBeanDefinition(templateBeanName);

                    if (beanDefinition instanceof AbstractBeanDefinition) {
                        for (final String tenant : enabledTenants) {
                            final AbstractBeanDefinition cloneBeanDefinition = ((AbstractBeanDefinition) beanDefinition)
                                    .cloneBeanDefinition();
                            cloneBeanDefinition.setScope(AbstractBeanDefinition.SCOPE_DEFAULT);

                            this.shallowCloneManagedCollections(cloneBeanDefinition);

                            final String tenantBeanName = beanName + TenantBeanUtils.TENANT_BEAN_NAME_PATTERN
                                    + tenant;

                            LOGGER.debug("Adding clone of {} for tenant {}", templateBeanName, tenant);
                            registry.registerBeanDefinition(tenantBeanName, cloneBeanDefinition);
                        }
                    }
                } else {
                    LOGGER.warn("No template bean defined for {}", beanName);
                }
            }
        }
    }
}

From source file:org.rosenvold.spring.convention.ConventionBeanFactory.java

private synchronized String getAnnotatedScope(Class<?> type) {
    if (type != null) {
        final Scope annotation = type.getAnnotation(Scope.class);
        if (annotation != null) {
            return annotation.value();
        }/*from   www.j a  va  2 s.  c o m*/
    }
    return AbstractBeanDefinition.SCOPE_DEFAULT;
}