Search in sources :

Example 71 with ClassPathXmlApplicationContext

use of org.springframework.context.support.ClassPathXmlApplicationContext in project sharding-jdbc by dangdangdotcom.

the class Main method main.

public static void main(final String[] args) {
    // CHECKSTYLE:ON
    ApplicationContext applicationContext = new ClassPathXmlApplicationContext("META-INF/mybatisContext.xml");
    OrderService orderService = applicationContext.getBean(OrderService.class);
    orderService.clear();
    orderService.fooService();
    orderService.select();
    //[order_id: , user_id: 10, status: UPDATED, order_id: , user_id: 11, status: UPDATED]
    orderService.clear();
    try {
        orderService.fooServiceWithFailure();
    } catch (final IllegalArgumentException e) {
        System.out.println("roll back");
    }
    //[]
    orderService.select();
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) OrderService(com.dangdang.ddframe.rdb.sharding.example.jdbc.service.OrderService)

Example 72 with ClassPathXmlApplicationContext

use of org.springframework.context.support.ClassPathXmlApplicationContext in project cradle by BingLau7.

the class Main method xmlLoadBean.

public static void xmlLoadBean() {
    ApplicationContext context = new ClassPathXmlApplicationContext(new String[] { "services.xml" });
    //        TestBean testBean = context.getBean("testBean", TestBean.class);
    //        System.out.println(testBean);
    TestStaticFactoryBean testStaticFactoryBean = context.getBean("testStaticFactoryBean", TestStaticFactoryBean.class);
    System.out.println(testStaticFactoryBean);
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) GenericGroovyApplicationContext(org.springframework.context.support.GenericGroovyApplicationContext) GenericApplicationContext(org.springframework.context.support.GenericApplicationContext) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext)

Example 73 with ClassPathXmlApplicationContext

use of org.springframework.context.support.ClassPathXmlApplicationContext in project Asqatasun by Asqatasun.

the class AbstractRuleImplementationTestCase method initialize.

private void initialize() {
    initializePath();
    // fully loaded, and the test spend at least 200ms for nothing
    if (APPLICATION_CONTEXT == null) {
        APPLICATION_CONTEXT = new ClassPathXmlApplicationContext(applicationContextFilePath);
        WEB_RESOURCE_FACTORY = (WebResourceFactory) APPLICATION_CONTEXT.getBean("webResourceFactory");
        CONTENT_FACTORY = (ContentFactory) APPLICATION_CONTEXT.getBean("contentFactory");
        PARAMETER_FACTORY = (ParameterFactory) APPLICATION_CONTEXT.getBean("parameterFactory");
        PARAMETER_ELEMENT_FACTORY = (ParameterElementFactory) APPLICATION_CONTEXT.getBean("parameterElementFactory");
        PARAMETER_FAMILY_FACTORY = (ParameterFamilyFactory) APPLICATION_CONTEXT.getBean("parameterFamilyFactory");
        AUDIT_FACTORY = (AuditFactory) APPLICATION_CONTEXT.getBean("auditFactory");
        TEST_FACTORY = (TestFactory) APPLICATION_CONTEXT.getBean("testFactory");
        CONTENT_LOADER_SERVICE = (ContentLoaderService) APPLICATION_CONTEXT.getBean("contentLoaderService");
        CONTENT_ADAPTER_SERVICE = (ContentAdapterService) APPLICATION_CONTEXT.getBean("contentAdapterService");
        PROCESSOR_SERVICE = (ProcessorService) APPLICATION_CONTEXT.getBean("processorService");
        CONSOLIDATOR_SERVICE = (ConsolidatorService) APPLICATION_CONTEXT.getBean("consolidatorService");
        URL_IDENTIFIER = ((URLIdentifierFactory) APPLICATION_CONTEXT.getBean("urlIdentifierFactory")).create();
        if (upperCaseTags) {
            HTMLCleanerFactoryImpl htmlCleanerFactory = (HTMLCleanerFactoryImpl) APPLICATION_CONTEXT.getBean("htmlCleanerFactory");
            htmlCleanerFactory.setRemoveLowerCaseTags(upperCaseTags);
        }
    }
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext)

Example 74 with ClassPathXmlApplicationContext

use of org.springframework.context.support.ClassPathXmlApplicationContext in project perun by CESNET.

the class DispatcherStarter method main.

/**
	 * Initialize stand-alone dispatcher.
	 *
	 * @param arg
	 */
public static void main(String[] arg) {
    DispatcherStarter starter = new DispatcherStarter();
    starter.springCtx = new ClassPathXmlApplicationContext("perun-core.xml", "perun-dispatcher.xml", "perun-dispatcher-scheduler.xml");
// no need to call init explicitly, gets called by spring when initializing this bean
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext)

Example 75 with ClassPathXmlApplicationContext

use of org.springframework.context.support.ClassPathXmlApplicationContext in project Dempsy by Dempsy.

the class TestAllClusterImpls method runAllCombinations.

private <T, N> void runAllCombinations(Checker checker) throws Throwable {
    for (String clusterManager : clusterManagers) {
        ClassPathXmlApplicationContext actx = new ClassPathXmlApplicationContext(clusterManager);
        actx.registerShutdownHook();
        ClusterInfoSessionFactory factory = (ClusterInfoSessionFactory) actx.getBean("clusterSessionFactory");
        if (checker != null)
            checker.check("pass for:" + clusterManager, factory);
        actx.stop();
        actx.destroy();
    }
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext)

Aggregations

ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)561 Test (org.junit.Test)265 ApplicationContext (org.springframework.context.ApplicationContext)167 Before (org.junit.Before)53 ConfigurableMessenger (org.springframework.scripting.ConfigurableMessenger)33 ITestBean (org.springframework.tests.sample.beans.ITestBean)30 Messenger (org.springframework.scripting.Messenger)29 CamelContext (org.apache.camel.CamelContext)25 Refreshable (org.springframework.aop.target.dynamic.Refreshable)23 AbstractXmlApplicationContext (org.springframework.context.support.AbstractXmlApplicationContext)22 DataSource (javax.sql.DataSource)18 SpringCamelContext (org.apache.camel.spring.SpringCamelContext)16 AbstractApplicationContext (org.springframework.context.support.AbstractApplicationContext)16 Bus (org.apache.cxf.Bus)14 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)14 ArrayList (java.util.ArrayList)13 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)12 DemoService (com.alibaba.dubbo.config.spring.api.DemoService)11 IOException (java.io.IOException)10 ProducerTemplate (org.apache.camel.ProducerTemplate)10