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

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

Introduction

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

Prototype

String SCOPE_SINGLETON

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

Click Source Link

Document

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

Usage

From source file:br.com.caelum.vraptor.ioc.spring.VRaptorScopeResolver.java

public VRaptorScopeResolver() {
    scopes.put(RequestScoped.class.getName(), WebApplicationContext.SCOPE_REQUEST);
    scopes.put(SessionScoped.class.getName(), WebApplicationContext.SCOPE_SESSION);
    scopes.put(ApplicationScoped.class.getName(), BeanDefinition.SCOPE_SINGLETON);
    scopes.put(PrototypeScoped.class.getName(), BeanDefinition.SCOPE_PROTOTYPE);
}

From source file:com.gwtplatform.dispatch.rpc.server.spring.utils.SpringUtils.java

private static <B> RootBeanDefinition createBeanDefinition(B instance) {
    RootBeanDefinition bd = new RootBeanDefinition(instance.getClass(),
            AbstractBeanDefinition.AUTOWIRE_CONSTRUCTOR, false);
    bd.setScope(BeanDefinition.SCOPE_SINGLETON);
    return bd;/*www .jav a2  s  . c  om*/
}

From source file:org.xmatthew.spy2servers.component.config.ActiveMQJmxSpyComponentParser.java

protected void doParse(Element element, BeanDefinitionBuilder builder) {
    super.doParse(element, builder);

    Set destinationNames = null;/*from ww  w. j a va 2  s . co  m*/
    Set llegalIps = null;

    NodeList childNodes = element.getChildNodes();
    for (int i = 0; i < childNodes.getLength(); i++) {
        Node child = childNodes.item(i);
        if (child.getNodeType() == Node.ELEMENT_NODE) {
            String localName = child.getLocalName();
            if (DESTINATION_NAMES_TO_WATCH_PROPERTY.equals(localName)) {
                destinationNames = IntegrationNamespaceUtils.parseDestinationNamesToWatch((Element) child);
            } else if (LLEGAL_IP_PROPERTY.equals(localName)) {
                llegalIps = IntegrationNamespaceUtils.parseLegalIps((Element) child);
            }
        }
    }

    if (destinationNames != null) {
        builder.addPropertyValue(DESTINATION_NAMES_TO_WATCH_PROPERTY, destinationNames);
    }
    if (llegalIps != null) {
        builder.addPropertyValue(LLEGAL_IP_PROPERTY, llegalIps);
    }

    builder.setScope(BeanDefinition.SCOPE_SINGLETON);
}

From source file:org.agatom.springatom.cmp.action.ActionsConfiguration.java

@Lazy(false)
@Bean(name = "actionsModelReader")
@Scope(BeanDefinition.SCOPE_SINGLETON)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public ActionsModelReader getActionsModelReader() {
    final DefaultActionsModelReader modelReader = new DefaultActionsModelReader();
    modelReader.setModelFile(this.environment.getProperty("springatom.actions.modelSource"));
    modelReader.setParseOnLoad(this.environment.getProperty("springatom.actions.parseOnLoad", Boolean.class));
    modelReader.setObjectMapper(this.mapper);
    modelReader.setMessageSource(this.messageSource);
    return modelReader;
}

From source file:org.xmatthew.spy2servers.component.config.TomcatJmxSpyComponentParser.java

protected void doParse(Element element, BeanDefinitionBuilder builder) {
    super.doParse(element, builder);

    DataSourcesSpy dataSourcesSpy = null;
    WebModuleSpy webModuleSpy = null;// w w  w  .  j av  a 2 s .  co  m

    NodeList childNodes = element.getChildNodes();
    for (int i = 0; i < childNodes.getLength(); i++) {
        Node child = childNodes.item(i);
        if (child.getNodeType() == Node.ELEMENT_NODE) {
            String localName = child.getLocalName();
            if (DATASOURCES_SPY_PROPERTY.equals(localName)) {
                dataSourcesSpy = IntegrationNamespaceUtils.parseDataSourcesSpy((Element) child);
            } else if (WEB_MODULES_PROPERTY.equals(localName)) {
                webModuleSpy = IntegrationNamespaceUtils.parseWebModuleSpy((Element) child);
            }
        }
    }

    if (dataSourcesSpy != null) {
        builder.addPropertyValue(DATASOURCES_SPY_PROPERTY, dataSourcesSpy);
    }
    if (webModuleSpy != null) {
        builder.addPropertyValue(WEB_MODULES_PROPERTY, webModuleSpy);
    }
    builder.setScope(BeanDefinition.SCOPE_SINGLETON);
}

From source file:org.xmatthew.spy2servers.component.config.EmailAlertComponentParser.java

protected void doParse(Element element, BeanDefinitionBuilder builder) {
    super.doParse(element, builder);

    EmailAccount emailAccount = null;/*from   w  w w .jav  a 2s . c om*/
    Set emails = null;

    NodeList childNodes = element.getChildNodes();
    for (int i = 0; i < childNodes.getLength(); i++) {
        Node child = childNodes.item(i);
        if (child.getNodeType() == Node.ELEMENT_NODE) {
            String localName = child.getLocalName();
            if (EMAIL_ACCOUNT_PROPERTY.equals(localName)) {
                emailAccount = IntegrationNamespaceUtils.parseEmailAccount((Element) child);
            } else if (EMAILS_PROPERTY.equals(localName)) {
                emails = IntegrationNamespaceUtils.parseEmails((Element) child);
            }
        }
    }

    if (emails != null) {
        builder.addPropertyValue(EMAILS_PROPERTY, emails);
    }
    if (emailAccount == null) {
        throw new RuntimeException("emailAccount must set in beans defination <emailAlert />");
    }
    builder.addPropertyValue(EMAIL_ACCOUNT_PROPERTY, emailAccount);
    builder.setScope(BeanDefinition.SCOPE_SINGLETON);
}

From source file:br.com.caelum.vraptor.ioc.spring.VRaptorScopeResolverTest.java

@Test
public void shouldResolveApplicationScopedAnnotationToSingletonScope() {
    ScopeMetadata scopeMetadata = readScopeMetadata(ApplicationScopedComponent.class);
    Assert.assertEquals(ScopedProxyMode.NO, scopeMetadata.getScopedProxyMode());
    Assert.assertEquals(BeanDefinition.SCOPE_SINGLETON, scopeMetadata.getScopeName());
}

From source file:net.hasor.rsf.spring.parser.RsfDefinitionParser.java

/** ?Xml  */
@Override//w  w  w .  j a  v  a 2s  .com
public BeanDefinition parse(Element element, ParserContext parserContext) {
    // Spring 
    String version = SpringVersion.getVersion();
    version = StringUtils.isBlank(version) ? "?" : version;
    Map customEditors = null;
    if (version.charAt(0) == '4' || version.charAt(0) == '5') {
        customEditors = new HashMap<Class<?>, Class<? extends java.beans.PropertyEditor>>();
        customEditors.put(InterAddress.class, RsfAddressPropertyEditor.class);
    } else {
        customEditors = new HashMap();
        customEditors.put("net.hasor.rsf.InterAddress", new RsfAddressPropertyEditor());
    }
    //
    // . Bean 
    BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition();
    builder.getRawBeanDefinition().setBeanClass(CustomEditorConfigurer.class);
    builder.setScope(BeanDefinition.SCOPE_SINGLETON);//?
    builder.addPropertyValue("customEditors", customEditors);
    //
    //  .,BeanID net.hasor.rsf.spring.RsfAddressPropertyEditor
    AbstractBeanDefinition propEditors = builder.getBeanDefinition();
    String beanID = RsfAddressPropertyEditor.class.getName();
    BeanDefinitionHolder holder = new BeanDefinitionHolder(propEditors, beanID);
    BeanDefinitionReaderUtils.registerBeanDefinition(holder, parserContext.getRegistry());
    parserContext.registerComponent(new BeanComponentDefinition(holder));
    //
    //
    NamedNodeMap attributes = element.getAttributes();
    //
    return null;
}

From source file:org.xmatthew.spy2servers.component.config.SunJVMJmxSpyComponentParser.java

protected void doParse(Element element, BeanDefinitionBuilder builder) {
    super.doParse(element, builder);

    String host = element.getAttribute("host");
    builder.addPropertyValue("host", host);

    if (element.hasAttribute("port")) {
        String port = element.getAttribute("port");
        builder.addPropertyValue("port", port);
    }/*from w  w  w  . j a  v a 2s.c o  m*/
    if (element.hasAttribute("detectInterval")) {
        String detectInterval = element.getAttribute("detectInterval");
        builder.addPropertyValue("detectInterval", detectInterval);
    }
    if (element.hasAttribute("queueSuspendNotifyTime")) {
        String queueSuspendNotifyTime = element.getAttribute("queueSuspendNotifyTime");
        builder.addPropertyValue("queueSuspendNotifyTime", queueSuspendNotifyTime);
    }

    MemorySpy heapMemorySpy = null;
    MemorySpy noneHeapMemorySpy = null;
    FileSpy fileSpy = null;

    NodeList childNodes = element.getChildNodes();
    for (int i = 0; i < childNodes.getLength(); i++) {
        Node child = childNodes.item(i);
        if (child.getNodeType() == Node.ELEMENT_NODE) {
            String localName = child.getLocalName();
            if (HEAP_MEMORY_ELEMENT.equals(localName)) {
                heapMemorySpy = IntegrationNamespaceUtils.parseMemorySpy((Element) child);
            } else if (NONE_HEAP_MEMORY_ELEMENT.equals(localName)) {
                noneHeapMemorySpy = IntegrationNamespaceUtils.parseMemorySpy((Element) child);
            } else if (FILE_SPY_ELEMENT.equals(localName)) {
                fileSpy = IntegrationNamespaceUtils.parseFileSpy((Element) child);
            }
        }
    }

    if (heapMemorySpy != null) {
        builder.addPropertyValue("heapMemorySpy", heapMemorySpy);
    }
    if (noneHeapMemorySpy != null) {
        builder.addPropertyValue("noneHeapMemorySpy", noneHeapMemorySpy);
    }
    if (fileSpy != null) {
        builder.addPropertyValue(FILE_SPY_ELEMENT, fileSpy);
    }
    builder.setScope(BeanDefinition.SCOPE_SINGLETON);
}

From source file:org.jnap.core.persistence.factory.DaoFactory.java

protected BeanDefinition createDaoDefinition(Class<? extends PersistentModel> entityClass,
        EntityManagerFactory factory) {/*  w  ww  . ja  va 2  s  .co m*/
    Class daoClass = IndexedModel.class.isAssignableFrom(entityClass) ? GenericFullTextDao.class
            : GenericDao.class;
    return BeanDefinitionBuilder.genericBeanDefinition(daoClass).addConstructorArgValue(entityClass)
            .addPropertyValue("entityManagerFactory", factory).setScope(BeanDefinition.SCOPE_SINGLETON)
            .getBeanDefinition();
}