Search in sources :

Example 1 with ClassPathXmlApplicationContext

use of org.apache.xbean.spring.context.ClassPathXmlApplicationContext in project activemq-artemis by apache.

the class Consumer method setUp.

/**
 * @throws java.lang.Exception
 */
@Override
protected void setUp() throws Exception {
    LOG.info("setUp() called.");
    ClassPathXmlApplicationContext context1 = null;
    BrokerFactoryBean brokerFactory = new BrokerFactoryBean(new ClassPathResource(config));
    assertNotNull(brokerFactory);
    /* start up first broker instance */
    try {
        // resolve broker1
        Thread.currentThread().setContextClassLoader(NetworkedSyncTest.class.getClassLoader());
        context1 = new ClassPathXmlApplicationContext(config);
        broker1 = (BrokerService) context1.getBean("broker1");
        // start the broker
        if (!broker1.isStarted()) {
            LOG.info("Broker broker1 not yet started. Kicking it off now.");
            broker1.start();
        } else {
            LOG.info("Broker broker1 already started. Not kicking it off a second time.");
            broker1.waitUntilStopped();
        }
    } catch (Exception e) {
        LOG.error("Error: " + e.getMessage());
        throw e;
    // brokerService.stop();
    }
    /* start up second broker instance */
    try {
        Thread.currentThread().setContextClassLoader(NetworkedSyncTest.class.getClassLoader());
        context1 = new ClassPathXmlApplicationContext(config);
        broker2 = (BrokerService) context1.getBean("broker2");
        // start the broker
        if (!broker2.isStarted()) {
            LOG.info("Broker broker2 not yet started. Kicking it off now.");
            broker2.start();
        } else {
            LOG.info("Broker broker2 already started. Not kicking it off a second time.");
            broker2.waitUntilStopped();
        }
    } catch (Exception e) {
        LOG.error("Error: " + e.getMessage());
        throw e;
    }
    // setup network connector from broker1 to broker2
    connector = broker1.addNetworkConnector(networkConnectorURL);
    connector.setBrokerName(broker1.getBrokerName());
    connector.setDuplex(true);
    connector.start();
    LOG.info("Network connector created.");
}
Also used : ClassPathXmlApplicationContext(org.apache.xbean.spring.context.ClassPathXmlApplicationContext) BrokerFactoryBean(org.apache.activemq.xbean.BrokerFactoryBean) ClassPathResource(org.springframework.core.io.ClassPathResource)

Example 2 with ClassPathXmlApplicationContext

use of org.apache.xbean.spring.context.ClassPathXmlApplicationContext in project webofneeds by researchstudio-sat.

the class BotContextTests method setup.

@Before
public void setup() throws IllegalAccessException, InstantiationException {
    ApplicationContext ctx = new ClassPathXmlApplicationContext("/botContext.xml");
    botContext = (BotContext) ctx.getBean(botContextClass);
}
Also used : ClassPathXmlApplicationContext(org.apache.xbean.spring.context.ClassPathXmlApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) ClassPathXmlApplicationContext(org.apache.xbean.spring.context.ClassPathXmlApplicationContext) Before(org.junit.Before)

Example 3 with ClassPathXmlApplicationContext

use of org.apache.xbean.spring.context.ClassPathXmlApplicationContext in project geronimo-xbean by apache.

the class ComponentTest method test.

protected void test(String file) {
    BeanFactory f = new ClassPathXmlApplicationContext(file);
    ContainerBean container = (ContainerBean) f.getBean("container");
    assertNotNull(container);
    assertNotNull(container.getBeans());
    assertEquals(1, container.getBeans().length);
}
Also used : ContainerBean(org.apache.xbean.spring.example.ContainerBean) ClassPathXmlApplicationContext(org.apache.xbean.spring.context.ClassPathXmlApplicationContext) BeanFactory(org.springframework.beans.factory.BeanFactory)

Example 4 with ClassPathXmlApplicationContext

use of org.apache.xbean.spring.context.ClassPathXmlApplicationContext in project geronimo-xbean by apache.

the class JndiTest method testConfigureJndiInsideSpringXml.

public void testConfigureJndiInsideSpringXml() throws Exception {
    // lets load a spring context
    BeanFactory factory = new ClassPathXmlApplicationContext("org/apache/xbean/spring/jndi/spring.xml");
    Object test = factory.getBean("restaurant");
    assertNotNull("Should have found the test object", test);
    Object jndi = factory.getBean("jndi");
    assertNotNull("Should have found the jndi object", jndi);
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY, SpringInitialContextFactory.class.getName());
    InitialContext context = new InitialContext(env);
    assertEntryExists(context, "test");
    assertEntryExists(context, "test/restaurant");
    assertSame(test, context.lookup("test/restaurant"));
}
Also used : ClassPathXmlApplicationContext(org.apache.xbean.spring.context.ClassPathXmlApplicationContext) Hashtable(java.util.Hashtable) BeanFactory(org.springframework.beans.factory.BeanFactory) InitialContext(javax.naming.InitialContext)

Example 5 with ClassPathXmlApplicationContext

use of org.apache.xbean.spring.context.ClassPathXmlApplicationContext in project webofneeds by researchstudio-sat.

the class BotContextWrapperTests method setup.

@Before
public void setup() throws IllegalAccessException, InstantiationException {
    ApplicationContext ctx = new ClassPathXmlApplicationContext("classpath:spring/component/botContext/memoryBotContext.xml");
    botContext = (BotContext) ctx.getBean(botContextClass);
    botContextWrapper = new BotContextWrapper(botContext, BOT_NAME, LIST_NAME_1, LIST_NAME_2);
}
Also used : ClassPathXmlApplicationContext(org.apache.xbean.spring.context.ClassPathXmlApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) ClassPathXmlApplicationContext(org.apache.xbean.spring.context.ClassPathXmlApplicationContext) Before(org.junit.Before)

Aggregations

ClassPathXmlApplicationContext (org.apache.xbean.spring.context.ClassPathXmlApplicationContext)5 Before (org.junit.Before)2 BeanFactory (org.springframework.beans.factory.BeanFactory)2 ApplicationContext (org.springframework.context.ApplicationContext)2 Hashtable (java.util.Hashtable)1 InitialContext (javax.naming.InitialContext)1 BrokerFactoryBean (org.apache.activemq.xbean.BrokerFactoryBean)1 ContainerBean (org.apache.xbean.spring.example.ContainerBean)1 ClassPathResource (org.springframework.core.io.ClassPathResource)1