Package org.apache.xbean.spring.context

Examples of org.apache.xbean.spring.context.ResourceXmlApplicationContext


        } else if (ResourceUtils.isUrl(uri)) {
            resource = new UrlResource(uri);
        } else {
            resource = new ClassPathResource(uri);
        }
        return new ResourceXmlApplicationContext(resource);
    }
View Full Code Here


    public void afterPropertiesSet() throws Exception {
        if (config == null) {
            throw new IllegalArgumentException("config property must be set");
        }
        context = new ResourceXmlApplicationContext(config, parentContext);

        try {
            broker = (XBeanBrokerService)context.getBean("broker");
        } catch (BeansException e) {
            // ignore...
View Full Code Here

        } else if (ResourceUtils.isUrl(uri)) {
            resource = new UrlResource(uri);
        } else {
            resource = new ClassPathResource(uri);
        }
        return new ResourceXmlApplicationContext(resource) {
            @Override
            protected void initBeanDefinitionReader(XmlBeanDefinitionReader reader) {
                reader.setValidating(isValidate());
            }
        };
View Full Code Here

   
    public void setUp() throws Exception {
      url = getClass().getClassLoader().getResource("org/mortbay/jetty/xbean/xbean.xml");
        assertNotNull("Could not find xbean.xml on the classpath!", url);
       
        context = new ResourceXmlApplicationContext(new UrlResource(url));
    }
View Full Code Here

    protected ApplicationContext createApplicationContext(String uri) throws MalformedURLException {
        Resource resource = Utils.resourceFromString(uri);
        LOG.debug("Using " + resource + " from " + uri);
        try {
            return new ResourceXmlApplicationContext(resource) {
                @Override
                protected void initBeanDefinitionReader(XmlBeanDefinitionReader reader) {
                    reader.setValidating(isValidate());
                }
            };
View Full Code Here

        } else if (ResourceUtils.isUrl(uri)) {
            resource = new UrlResource(uri);
        } else {
            resource = new ClassPathResource(uri);
        }
        return new ResourceXmlApplicationContext(resource) {
            @Override
            protected void initBeanDefinitionReader(XmlBeanDefinitionReader reader) {
                reader.setValidating(isValidate());
            }
        };
View Full Code Here

    public void afterPropertiesSet() throws Exception {
        if (config == null) {
            throw new IllegalArgumentException("config property must be set");
        }
        context = new ResourceXmlApplicationContext(config, parentContext);

        try {
            broker = (XBeanBrokerService)context.getBean("broker");
        } catch (BeansException e) {
            // ignore...
View Full Code Here

   
    public void afterPropertiesSet() throws Exception {
        if (config == null) {
            throw new IllegalArgumentException("config property must be set");
        }
        context = new ResourceXmlApplicationContext(config, parentContext);

        try {
            broker = (XBeanBrokerService) context.getBean("broker");
        }
        catch (BeansException e) {
View Full Code Here

     */
    public static Descriptor buildDescriptor(URL url) {
        ClassLoader cl = Thread.currentThread().getContextClassLoader();
        try {
            Thread.currentThread().setContextClassLoader(DescriptorFactory.class.getClassLoader());
            ResourceXmlApplicationContext context = new ResourceXmlApplicationContext(
                            new UrlResource(url),
                            Arrays.asList(new Object[] { new XBeanProcessor() }));
            Descriptor descriptor = (Descriptor) context.getBean("jbi");
            checkDescriptor(descriptor);
            return descriptor;
        } finally {
            Thread.currentThread().setContextClassLoader(cl);
        }
View Full Code Here

        try {
            Thread.currentThread().setContextClassLoader(BrokerService.class.getClassLoader());
            Resource resource = Utils.resourceFromString(config);

            ResourceXmlApplicationContext ctx = new ResourceXmlApplicationContext(resource, Collections.EMPTY_LIST, null, Collections.EMPTY_LIST, false) {
                protected void initBeanDefinitionReader(XmlBeanDefinitionReader reader) {
                    reader.setValidating(false);
                }
            };

            // Handle properties in configuration
            PropertyPlaceholderConfigurer configurator =
                        new PropertyPlaceholderConfigurer();

            //convert dictionary to properties. Is there a better way?
            Properties props = new Properties();
            Enumeration elements = properties.keys();
            while (elements.hasMoreElements()) {
                Object key = elements.nextElement();
                props.put(key, properties.get(key));
            }

            configurator.setProperties(props);
            configurator.setIgnoreUnresolvablePlaceholders(true);

            ctx.addBeanFactoryPostProcessor(configurator);

            ctx.refresh();

            // Start the broker
            BrokerService broker = ctx.getBean(BrokerService.class);
            if (broker == null) {
                throw new ConfigurationException(null, "Broker not defined");
            }
            //TODO deal with multiple brokers
View Full Code Here

TOP

Related Classes of org.apache.xbean.spring.context.ResourceXmlApplicationContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.