Example usage for org.springframework.beans.factory.config ConfigurableBeanFactory SCOPE_SINGLETON

List of usage examples for org.springframework.beans.factory.config ConfigurableBeanFactory SCOPE_SINGLETON

Introduction

In this page you can find the example usage for org.springframework.beans.factory.config ConfigurableBeanFactory SCOPE_SINGLETON.

Prototype

String SCOPE_SINGLETON

To view the source code for org.springframework.beans.factory.config ConfigurableBeanFactory SCOPE_SINGLETON.

Click Source Link

Document

Scope identifier for the standard singleton scope: "singleton".

Usage

From source file:io.redlink.solrlib.spring.boot.autoconfigure.SolrLibCloudAutoconfiguration.java

@Primary
@Bean(initMethod = "initialize", destroyMethod = "shutdown")
@Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
@ConditionalOnProperty("solrlib.zk-connection")
@ConditionalOnMissingBean(SolrCoreContainer.class)
public SolrCoreContainer solrCloudConnector() {
    log.debug("Creating solrCloudConnector");
    final SolrCloudConnectorConfiguration config = new SolrCloudConnectorConfiguration();
    config.setZkConnection(props.getZkConnection());
    config.setMaxShardsPerNode(props.getMaxShardsPerNode());
    config.setPrefix(props.getCollectionPrefix());
    config.setDeployCores(props.isDeployCores());

    return new SolrCloudConnector(coreDescriptors, config);
}

From source file:com.alliander.osgp.acceptancetests.config.OslpConfig.java

@Bean
@Scope(value = ConfigurableBeanFactory.SCOPE_SINGLETON)
public FirmwareLocation firmwareLocation() {
    return new FirmwareLocation(FIRMWARE_DOMAIN, FIRMWARE_PATH, FIRMWARE_FILE_EXTENSION);
}

From source file:se.ivankrizsan.messagecowboy.integrationtest.taskexecutionstatuscleanup.TaskExecutionStatusCleanupTestConfiguration.java

/**
 * Overrides properties configured on beans.
 *//*  ww  w .  j av  a2s  . c  o m*/
@Bean()
@Lazy(false)
@Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
public static BeanFactoryPostProcessor propertyOverrideConfigurer() {
    PropertyOverrideConfigurer theOverrideConfigurer = new PropertyOverrideConfigurer();

    final Properties thePropertiesHolder = new Properties();
    /* Task refresh interval. */
    thePropertiesHolder.put("starterService.taskReschedulingCronExpression", "* 4/30 * * * ?");
    /* Transport service configuration refresh interval. */
    thePropertiesHolder.put("starterService.transportServiceConfigurationRefreshCronExpression",
            "* 5/30 * * * ?");
    /* Task execution status reports cleanup interval. */
    thePropertiesHolder.put("starterService.taskExecutionStatusCleanupCronExpression", "0/5 * * * * ?");

    theOverrideConfigurer.setProperties(thePropertiesHolder);
    theOverrideConfigurer.setIgnoreInvalidKeys(false);
    theOverrideConfigurer.setIgnoreResourceNotFound(false);
    theOverrideConfigurer.setOrder(0);
    return theOverrideConfigurer;
}

From source file:org.agatom.springatom.data.xml.OXMLConfiguration.java

/**
 * <p>getJaxbMarshaller.</p>
 *
 * @return a {@link org.springframework.oxm.jaxb.Jaxb2Marshaller} object.
 *///w  w w  .j a  va  2s .co m
@Bean(name = "jaxbMarshaller")
@Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
public Jaxb2Marshaller getJaxbMarshaller() {
    final Jaxb2Marshaller jaxb2Marshaller = new Jaxb2Marshaller();
    jaxb2Marshaller.setLazyInit(this.environment.getProperty("springatom.oxm.lazyInit", Boolean.class));
    jaxb2Marshaller.setPackagesToScan(
            StringUtils.split(this.environment.getProperty("springatom.oxm.packagesToScan"), ","));
    jaxb2Marshaller.setCheckForXmlRootElement(true);
    jaxb2Marshaller.setProcessExternalEntities(true);
    return jaxb2Marshaller;
}

From source file:se.ivankrizsan.messagecowboy.services.transport.TransportServiceConfiguration.java

/**
 * Location of connector and transport service configuration files
 * for the Mule implementation of the transport service.<br/>
 * This bean should be overridden and appropriate configuration locations
 * should be provided.// w  w  w. ja v  a  2 s.co m
 * 
 * @return List of locations where the Mule transport service is to
 * search for configuration files.
 */
@Bean
@Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
public List<String> muleTransportServiceConfigLocations() {
    final List<String> theLocationsList = new ArrayList<String>();

    return theLocationsList;
}

From source file:se.ivankrizsan.messagecowboy.MessageCowboyConfiguration.java

/**
 * Override./* ww  w  .j a v a 2 s .  c  o m*/
 * Location of connector and transport service configuration files
 * for the Mule implementation of the transport service.<br/>
 * These values are the values that are to be used in a production
 * environment.
 * 
 * @return List of locations where the Mule transport service is to
 * search for configuration files.
 */
@Bean
@Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
public List<String> muleTransportServiceConfigLocations() {
    final List<String> theLocationsList = new ArrayList<String>();
    theLocationsList.add("file:production-configurations/mule/connectors/*.xml");
    theLocationsList.add("file:production-configurations/mule/transport-service-configurations/*.xml");
    return theLocationsList;
}

From source file:se.ivankrizsan.messagecowboy.MessageCowboyConfiguration.java

/**
 * Override./*from   w  w w . j av  a  2  s . co m*/
 * Location of component configuration files used for transport in the 
 * Camel implementation of the transport service.<br/>
 * These are the values to be used in a production environment.
 * 
 * @return List of locations where the Camel transport service is to search
 * for configuration files.
 */
@Bean
@Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
public List<String> camelTransportServiceConfigLocations() {
    final List<String> theLocationsList = new ArrayList<String>();
    theLocationsList.add("file:production-configurations/camel/*.xml");
    return theLocationsList;
}

From source file:org.apache.click.extras.spring.PageScopeResolver.java

/**
 * Return the scope meta data for the given bean definition. This scope meta
 * data resolver will resolve "prototype" scope for any Click Page bean
 * and will resolve "singleton" scope for other beans.
 *
 * @see ScopeMetadataResolver#resolveScopeMetadata(BeanDefinition)
 *
 * @param beanDef the component bean definition to resolve
 * @return the scope meta data for the given bean definition.
 *///from w w w.  j a  v  a  2  s .  com
public ScopeMetadata resolveScopeMetadata(BeanDefinition beanDef) {
    ScopeMetadata sm = new ScopeMetadata();

    try {
        Class<?> beanClass = ClickUtils.classForName(beanDef.getBeanClassName());

        if (Page.class.isAssignableFrom(beanClass)) {
            sm.setScopeName(ConfigurableBeanFactory.SCOPE_PROTOTYPE);

        } else {
            // TODO: see whether we can determine the default scope definition
            // from the beanDef and return this instead.
            sm.setScopeName(ConfigurableBeanFactory.SCOPE_SINGLETON);
        }

        return sm;

    } catch (Exception e) {
        String msg = "Could not load class for beanDef: " + beanDef;
        throw new RuntimeException(msg, e);
    }
}

From source file:com.logsniffer.app.CoreAppConfig.java

/**
 * Returns a general properties placeholder configurer based on
 * {@link #logSnifferProperties()}./*from ww w  .  ja v a2  s.  c  o  m*/
 * 
 * @param props
 *            autowired logSnifferProperties bean
 * @return A general properties placeholder configurer.
 * @throws IOException
 */
@Bean
@Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
@Autowired
public static PropertyPlaceholderConfigurer propertyPlaceholderConfigurer(
        @Qualifier(BEAN_LOGSNIFFER_PROPS) final Properties props) throws IOException {
    final PropertyPlaceholderConfigurer c = new PropertyPlaceholderConfigurer();
    c.setIgnoreResourceNotFound(true);
    c.setIgnoreUnresolvablePlaceholders(true);
    c.setSystemPropertiesMode(PropertyPlaceholderConfigurer.SYSTEM_PROPERTIES_MODE_OVERRIDE);
    c.setProperties(props);
    return c;
}

From source file:me.springframework.di.spring.SpringConfigurationLoader.java

/**
 * Loads a {@link MutableInstance} from one of the {@link BeanDefinition}s
 * provided by the {@link BeanDefinitionRegistry} passed in.
 * /*from  ww w  .j ava 2  s. co  m*/
 * @param instance
 *            A {@link MutableInstance} to be populated.
 * @param definition
 *            A {@link BeanDefinition}, providing the meta data.
 */
private static void load(MutableInstance instance, BeanDefinition definition, MutableContext context) {
    instance.setReferencedType(definition.getBeanClassName());
    instance.setPrimitive(false);
    instance.setLazyInit(definition.isLazyInit());
    instance.setId("source" + counter++);
    instance.setFactoryMethod(definition.getFactoryMethodName());
    instance.setFactoryInstance(definition.getFactoryBeanName());
    if (ConfigurableBeanFactory.SCOPE_SINGLETON.equals(definition.getScope())) {
        instance.setScope(Scope.SINGLETON);
    }
    if (ConfigurableBeanFactory.SCOPE_PROTOTYPE.equals(definition.getScope())) {
        instance.setScope(Scope.PROTOTYPE);
    }
    if (definition instanceof AbstractBeanDefinition) {
        instance.setInitMethod(((AbstractBeanDefinition) definition).getInitMethodName());
        instance.setDestroyMethod(((AbstractBeanDefinition) definition).getDestroyMethodName());
    }
    if (!definition.getConstructorArgumentValues().isEmpty()) {
        List<MutableConstructorArgument> arguments = new ArrayList<MutableConstructorArgument>();
        for (Object object : definition.getConstructorArgumentValues().getGenericArgumentValues()) {
            MutableConstructorArgument argument = new MutableConstructorArgument(instance);
            argument.setInstance(instance);
            ValueHolder holder = (ValueHolder) object;
            argument.setSource(loadSource(context, argument, holder.getValue()));
            argument.setType(holder.getType());
            arguments.add(argument);
        }
        instance.setConstructorArguments(arguments);
    }
    Set<MutablePropertySetter> setters = new HashSet<MutablePropertySetter>();
    for (Object object : definition.getPropertyValues().getPropertyValueList()) {
        MutablePropertySetter setter = new MutablePropertySetter(instance);
        setter.setInstance(instance);
        PropertyValue value = (PropertyValue) object;
        setter.setName(value.getName());
        setter.setSource(loadSource(context, setter, value.getValue()));
        setters.add(setter);
    }
    instance.setSetters(setters);

    // added by woj
    instance.setAutowireCandidate(definition.isAutowireCandidate());
    if (definition instanceof AbstractBeanDefinition) {
        instance.setAutowireMode(((AbstractBeanDefinition) definition).getResolvedAutowireMode());
    } else {
        instance.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_NO);
    }
}