Examples of AbstractApplicationContext


Examples of org.springframework.context.support.AbstractApplicationContext

   * @param args
   *            Command line arguments. This appliation does not check any of
   *            these arguments.
   */
  public static void main(String[] args) {
    AbstractApplicationContext ctx = ExampleUtils.getContext();
    ObjectContainer db = (ObjectContainer) ctx.getBean(ExampleUtils.CONTAINER_BEAN_ID);
    try {
      storeFirstPilot(db);
      storeSecondPilot(db);
      retrieveAllPilots(db);
      retrievePilotByName(db);
      retrievePilotByExactPoints(db);
      updatePilot(db);
      deleteFirstPilotByName(db);
      deleteSecondPilotByName(db);

    } finally {
      //closes the database file implicitly
      ctx.close();
    }
  }
View Full Code Here

Examples of org.springframework.context.support.AbstractApplicationContext

  private static final Log log = LogFactory.getLog(Main.class);
 
    public static void main(String[] args) {
       
      AbstractApplicationContext context = new ClassPathXmlApplicationContext("/applicationContext-repository.xml");
       
        //ResourceLoader loader = new DefaultResourceLoader();
        //Resource resource = loader.getResource("test.file");
       
        JcrService service = (JcrService)context.getBean("jcrService");

        //String node1Path = service.saveSmth("node1", "property1");
       
        String node2Path = null;
        try {
            node2Path = service.saveWithRollback("node2", "property2");
        } catch (RuntimeException e) {
            log.info("found exception " + e);
        }
       
        //log.info("is node 1 still committed "+ service.checkNode(node1Path));
        log.info("is node 2 still rolled back " + !service.checkNode("/node2"));
       
        context.close();

    }
View Full Code Here

Examples of org.springframework.context.support.AbstractApplicationContext

public class JmsToFileRouteTest extends Assert {
   
    @Test
    public void startRoute() throws Exception {
        AbstractApplicationContext applicationContext =
            new ClassPathXmlApplicationContext(new String[]{"/META-INF/spring/camelContext.xml"});
        CamelContext camelContext = applicationContext.getBean("camelContext", CamelContext.class);
        assertNotNull("The camel context should not be null", camelContext);
        Thread.sleep(2000);       
        camelContext.stop();
        applicationContext.stop();
    }
View Full Code Here

Examples of org.springframework.context.support.AbstractApplicationContext

    private CamelContext context2;
    private ProducerTemplate template2;

    @Before
    public void setUp() throws Exception {
        AbstractApplicationContext ac = new ClassPathXmlApplicationContext("org/apache/camel/component/cxf/jaxrs/CxfRsProducerClientFactoryCacheTest2.xml");
        context2 = SpringCamelContext.springCamelContext(ac, false);
        context2.start();

        template2 = context2.createProducerTemplate();
        template2.start();
View Full Code Here

Examples of org.springframework.context.support.AbstractApplicationContext

import org.springframework.context.support.AbstractApplicationContext;

public class NamespaceContextImplTest extends TestCase {

    public void testNsContext() throws Exception {
        AbstractApplicationContext springContext =
            new ClassPathXmlApplicationContext("org/apache/servicemix/eip/support/nscontext.xml");
        Object objNsContext = springContext.getBean("nsContext");
        assertNotNull(objNsContext);
        assertTrue(objNsContext instanceof NamespaceContextImpl);
        NamespaceContextImpl nsContext = (NamespaceContextImpl) objNsContext;
        assertEquals("urn:test", nsContext.getNamespaceURI("test"));
        assertEquals("test", nsContext.getPrefix("urn:test"));
View Full Code Here

Examples of org.springframework.context.support.AbstractApplicationContext

    private ProducerTemplate template1;
    private ProducerTemplate template2;

    @Before
    public void setUp() throws Exception {
        AbstractApplicationContext ac = new ClassPathXmlApplicationContext("org/apache/camel/component/cxf/jaxrs/CxfRsProducerClientFactoryCacheTest1.xml");
        context1 = SpringCamelContext.springCamelContext(ac, false);
        context1.start();
        template1 = context1.createProducerTemplate();
        template1.start();
View Full Code Here

Examples of org.springframework.context.support.AbstractApplicationContext

          + "\n    For more information please visit:                   "
          + "\n    http://www.springsource.org/spring-integration       "
          + "\n                                                         "
          + "\n=========================================================" );

    final AbstractApplicationContext context =
        new ClassPathXmlApplicationContext("classpath:META-INF/spring/integration/stateless-retry-advice-context.xml");

    context.registerShutdownHook();

    LOGGER.info("\n========================================================="
          + "\n                                                          "
          + "\n    This is the Stateless Sample -                        "
          + "\n                                                          "
          + "\n    Please enter some text and press return.              "
          + "\n    'fail 2' will fail twice, then succeed                "
          + "\n    'fail 3' will fail and never succeed                  "
          + "\n    Demo will terminate in 60 seconds.                    "
          + "\n                                                          "
          + "\n=========================================================" );

    Thread.sleep(60000);
    context.close();
  }
View Full Code Here

Examples of org.springframework.context.support.AbstractApplicationContext

          + "\n    For more information please visit:                   "
          + "\n    http://www.springsource.org/spring-integration       "
          + "\n                                                         "
          + "\n=========================================================" );

    final AbstractApplicationContext context =
        new ClassPathXmlApplicationContext("classpath:META-INF/spring/integration/circuit-breaker-advice-context.xml");

    context.registerShutdownHook();

    LOGGER.info("\n========================================================="
          + "\n                                                          "
          + "\n    This is the Circuit Breaker Sample -                  "
          + "\n                                                          "
          + "\n    Please enter some text and press return a few times.  "
          + "\n    Service will succeed only in the last quarter         "
          + "\n    minute. Breaker will open after 2 failures and        "
          + "\n    will go half-open after 15 seconds.                   "
          + "\n    Demo will terminate in 2 minutes.                     "
          + "\n                                                          "
          + "\n=========================================================" );

    Thread.sleep(120000);
    context.close();
  }
View Full Code Here

Examples of org.springframework.context.support.AbstractApplicationContext

          + "\n    For more information please visit:                   "
          + "\n    http://www.springsource.org/spring-integration       "
          + "\n                                                         "
          + "\n=========================================================" );

    final AbstractApplicationContext context =
        new ClassPathXmlApplicationContext("classpath:META-INF/spring/integration/stateful-retry-advice-context.xml");

    context.registerShutdownHook();

    LOGGER.info("\n========================================================="
          + "\n                                                          "
          + "\n    This is the Stateful Sample -                        "
          + "\n                                                          "
          + "\n    Please enter some text and press return.              "
          + "\n    'fail 2' will fail twice, then succeed                "
          + "\n    'fail 3' will fail and never succeed                  "
          + "\n    Demo will terminate in 60 seconds.                    "
          + "\n                                                          "
          + "\n=========================================================" );

    Thread.sleep(60000);
    context.close();
  }
View Full Code Here

Examples of org.springframework.context.support.AbstractApplicationContext

          + "\n    For more information please visit:                   "
          + "\n    http://www.springsource.org/spring-integration       "
          + "\n                                                         "
          + "\n=========================================================" );

    final AbstractApplicationContext context =
        new ClassPathXmlApplicationContext("classpath:META-INF/spring/integration/expression-advice-context.xml");

    context.registerShutdownHook();

    @SuppressWarnings("unchecked")
    SessionFactory<FTPFile> sessionFactory = context.getBean(SessionFactory.class);
    SourcePollingChannelAdapter fileInbound = context.getBean(SourcePollingChannelAdapter.class);

    when(sessionFactory.getSession()).thenThrow(new RuntimeException("Force Failure"));
    fileInbound.start();

    LOGGER.info("\n========================================================="
          + "\n                                                          "
          + "\n    This is the Expression Advice Sample -                "
          + "\n                                                          "
          + "\n    Press 'Enter' to terminate.                           "
          + "\n                                                          "
          + "\n    Place a file in ${java.io.tmpdir}/adviceDemo ending   "
          + "\n    with .txt                                             "
          + "\n    The demo simulates a file transfer failure followed   "
          + "\n    by the Advice renaming the file; the result of the    "
          + "\n    rename is logged.                                     "
          + "\n                                                          "
          + "\n=========================================================" );

    System.in.read();
    context.close();
    System.exit(0);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.