Example usage for org.springframework.beans.factory.support RootBeanDefinition getPropertyValues

List of usage examples for org.springframework.beans.factory.support RootBeanDefinition getPropertyValues

Introduction

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

Prototype

@Override
public MutablePropertyValues getPropertyValues() 

Source Link

Document

Return property values for this bean (never null ).

Usage

From source file:fr.xebia.management.config.ServletContextAwareMBeanServerDefinitionParser.java

/**
 * Logic taken from/*from www. j  av  a  2s. c  om*/
 * <code>org.springframework.context.config.MBeanServerBeanDefinitionParser.findServerForSpecialEnvironment()</code>
 */
static AbstractBeanDefinition findServerForSpecialEnvironment() {
    boolean weblogicPresent = ClassUtils.isPresent("weblogic.management.Helper",
            ServletContextAwareMBeanServerDefinitionParser.class.getClassLoader());

    boolean webspherePresent = ClassUtils.isPresent("com.ibm.websphere.management.AdminServiceFactory",
            ServletContextAwareMBeanServerDefinitionParser.class.getClassLoader());

    if (weblogicPresent) {
        RootBeanDefinition bd = new RootBeanDefinition(JndiObjectFactoryBean.class);
        bd.getPropertyValues().add("jndiName", "java:comp/env/jmx/runtime");
        return bd;
    } else if (webspherePresent) {
        return new RootBeanDefinition(WebSphereMBeanServerFactoryBean.class);
    } else {
        return null;
    }
}

From source file:fr.xebia.management.config.ProfileAspectDefinitionParser.java

/**
 * Logic taken from// ww w .  j  a va 2  s .c o  m
 * <code>org.springframework.context.config.MBeanServerBeanDefinitionParser.findServerForSpecialEnvironment()</code>
 */
static AbstractBeanDefinition findServerForSpecialEnvironment() {
    boolean weblogicPresent = ClassUtils.isPresent("weblogic.management.Helper",
            ProfileAspectDefinitionParser.class.getClassLoader());

    boolean webspherePresent = ClassUtils.isPresent("com.ibm.websphere.management.AdminServiceFactory",
            ProfileAspectDefinitionParser.class.getClassLoader());

    if (weblogicPresent) {
        RootBeanDefinition bd = new RootBeanDefinition(JndiObjectFactoryBean.class);
        bd.getPropertyValues().add("jndiName", "java:comp/env/jmx/runtime");
        return bd;
    } else if (webspherePresent) {
        return new RootBeanDefinition(WebSphereMBeanServerFactoryBean.class);
    } else {
        return null;
    }
}

From source file:org.jdal.aop.SerializableProxyUtils.java

public static BeanDefinitionHolder createSerializableProxy(BeanDefinitionHolder definition,
        BeanDefinitionRegistry registry, boolean proxyTargetClass) {

    String originalBeanName = definition.getBeanName();
    BeanDefinition targetDefinition = definition.getBeanDefinition();

    // Create a scoped proxy definition for the original bean name,
    // "hiding" the target bean in an internal target definition.
    RootBeanDefinition proxyDefinition = new RootBeanDefinition(SerializableProxyFactoryBean.class);
    proxyDefinition.setOriginatingBeanDefinition(definition.getBeanDefinition());
    proxyDefinition.setSource(definition.getSource());
    proxyDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);

    String targetBeanName = getTargetBeanName(originalBeanName);
    proxyDefinition.getPropertyValues().add("targetBeanName", targetBeanName);

    if (proxyTargetClass) {
        targetDefinition.setAttribute(AutoProxyUtils.PRESERVE_TARGET_CLASS_ATTRIBUTE, Boolean.TRUE);
    } else {/*  w  w  w  .j  av  a2  s .  com*/
        proxyDefinition.getPropertyValues().add("proxyTargetClass", Boolean.FALSE);
    }

    // Copy autowire settings from original bean definition.
    proxyDefinition.setAutowireCandidate(targetDefinition.isAutowireCandidate());
    proxyDefinition.setPrimary(targetDefinition.isPrimary());
    if (targetDefinition instanceof AbstractBeanDefinition) {
        proxyDefinition.copyQualifiersFrom((AbstractBeanDefinition) targetDefinition);
    }

    // Set singleton property of FactoryBean
    proxyDefinition.getPropertyValues().add("singleton", !targetDefinition.isPrototype());

    // The target bean should be ignored in favor of the scoped proxy.
    targetDefinition.setAutowireCandidate(false);
    targetDefinition.setPrimary(false);

    // Register the target bean as separate bean in the factory.
    registry.registerBeanDefinition(targetBeanName, targetDefinition);

    // Return the scoped proxy definition as primary bean definition
    // (potentially an inner bean).
    return new BeanDefinitionHolder(proxyDefinition, originalBeanName, definition.getAliases());
}

From source file:org.solmix.runtime.support.spring.AbstractRootBeanDefinitionParser.java

protected static void parseMultiRef(String property, String value, RootBeanDefinition beanDefinition,
        ParserContext parserContext) {/*from w  w  w .ja  v a  2s  . co  m*/
    String[] values = value.split("\\s*[,]+\\s*");
    ManagedList<Object> list = null;
    for (int i = 0; i < values.length; i++) {
        String v = values[i];
        if (v != null && v.length() > 0) {
            if (list == null) {
                list = new ManagedList<Object>();
            }
            list.add(new RuntimeBeanReference(v));
        }
    }
    beanDefinition.getPropertyValues().addPropertyValue(property, list);
}

From source file:com.weibo.api.motan.config.springsupport.MotanBeanDefinitionParser.java

@SuppressWarnings({ "unchecked", "rawtypes" })
private static void parseMultiRef(String property, String value, RootBeanDefinition beanDefinition,
        ParserContext parserContext) {/*from  w  w w.  ja  v  a  2 s .c o m*/
    String[] values = value.split("\\s*[,]+\\s*");
    ManagedList list = null;
    for (int i = 0; i < values.length; i++) {
        String v = values[i];
        if (v != null && v.length() > 0) {
            if (list == null) {
                list = new ManagedList();
            }
            list.add(new RuntimeBeanReference(v));
        }
    }
    beanDefinition.getPropertyValues().addPropertyValue(property, list);
}

From source file:com.weibo.api.motan.config.springsupport.MotanBeanDefinitionParser.java

private static void parseProperties(NodeList nodeList, RootBeanDefinition beanDefinition) {
    if (nodeList != null && nodeList.getLength() > 0) {
        for (int i = 0; i < nodeList.getLength(); i++) {
            Node node = nodeList.item(i);
            if (node instanceof Element) {
                if ("property".equals(node.getNodeName()) || "property".equals(node.getLocalName())) {
                    String name = ((Element) node).getAttribute("name");
                    if (name != null && name.length() > 0) {
                        String value = ((Element) node).getAttribute("value");
                        String ref = ((Element) node).getAttribute("ref");
                        if (value != null && value.length() > 0) {
                            beanDefinition.getPropertyValues().addPropertyValue(name, value);
                        } else if (ref != null && ref.length() > 0) {
                            beanDefinition.getPropertyValues().addPropertyValue(name,
                                    new RuntimeBeanReference(ref));
                        } else {
                            throw new UnsupportedOperationException("Unsupported <property name=\"" + name
                                    + "\"> sub tag, Only supported <property name=\"" + name
                                    + "\" ref=\"...\" /> or <property name=\"" + name + "\" value=\"...\" />");
                        }/*from www  .  j a  v a2 s.com*/
                    }
                }
            }
        }
    }
}

From source file:org.springmodules.jcr.config.JcrNamespaceHandlerTests.java

private Object getPropertyValue(RootBeanDefinition beanDefinition, String propertyName) {
    return beanDefinition.getPropertyValues().getPropertyValue(propertyName).getValue();
}

From source file:org.hummer.spring.ReferenceParser.java

public BeanDefinition parse(Element ele, ParserContext context) {
    //?/*from ww w  .j a  v a 2s.  c o m*/
    service = ele.getAttribute(ATTR_SERVICE);
    version = ele.getAttribute(ATTR_VERSION);
    if (service == null || version == null) {
        throw new RuntimeException("?!");
    }
    timeout = ele.getAttribute(ATTR_TIMEOUT) == null ? 3000 : Integer.parseInt(ele.getAttribute(ATTR_TIMEOUT));
    unit = ele.getAttribute(ATTR_UNIT) == null ? false : Boolean.parseBoolean(ele.getAttribute(ATTR_UNIT));
    retry = ele.getAttribute(ATTR_RETRY) == null ? 3 : Integer.parseInt(ele.getAttribute(ATTR_RETRY));
    RootBeanDefinition root = new RootBeanDefinition(ReferenceBean.class);
    root.getPropertyValues().add("service", service);
    root.getPropertyValues().add("version", version);
    root.getPropertyValues().add("timeout", timeout);
    root.getPropertyValues().add("unit", unit);
    root.getPropertyValues().add("retry", retry);
    context.getRegistry().registerBeanDefinition(ele.getAttribute("id"), root);
    return root;
}

From source file:org.hummer.spring.ServicePaser.java

public BeanDefinition parse(Element ele, ParserContext context) {
    //?/* w  ww.j a va  2  s .co  m*/
    service = ele.getAttribute(ATTR_SERVICE);
    version = ele.getAttribute(ATTR_VERSION);
    ref = ele.getAttribute(ATTR_REF);

    RootBeanDefinition root = new RootBeanDefinition(ServiceBean.class);
    root.setLazyInit(false);
    root.getPropertyValues().add("service", service);
    root.getPropertyValues().add("version", version);
    root.getPropertyValues().add("ref", new RuntimeBeanReference(ref));
    context.getRegistry()
            .registerBeanDefinition(beanNameGenerator.generateBeanName(root, context.getRegistry()), root);
    return null;
}

From source file:com.newlandframework.rpc.spring.NettyRpcRegisteryParser.java

public BeanDefinition parse(Element element, ParserContext parserContext) {
    String id = element.getAttribute("id");
    String ipAddr = element.getAttribute("ipAddr");
    String protocolType = element.getAttribute("protocol");

    RootBeanDefinition beanDefinition = new RootBeanDefinition();
    beanDefinition.setBeanClass(NettyRpcRegistery.class);
    beanDefinition.getPropertyValues().addPropertyValue("ipAddr", ipAddr);
    beanDefinition.getPropertyValues().addPropertyValue("protocol", protocolType);
    parserContext.getRegistry().registerBeanDefinition(id, beanDefinition);

    return beanDefinition;
}