Package org.springframework.context

Examples of org.springframework.context.ApplicationContext.containsBean()


  }


  public View resolveViewName(String viewName, Locale locale) throws BeansException {
    ApplicationContext context = getApplicationContext();
    if (!context.containsBean(viewName)) {
      // Allow for ViewResolver chaining.
      return null;
    }
    return (View) context.getBean(viewName, View.class);
  }
View Full Code Here


                new Contribution("TestContribution", new File("src/main/resources/context/multiple/").toURI().toURL().toString()));
        node.start();
       
        // Method 1: To access the Spring Application Context instance
        ApplicationContext ctx = SCAApplicationContextProvider.getApplicationContext();
        if (ctx.containsBean("StockQuoteServiceBean"))
            System.out.println("StockQuoteServiceBean is now available for use...");       
       
        System.out.println("Press Enter to Exit...");
        Thread.sleep(1000);
View Full Code Here

                new Contribution("TestContribution", new File("src/main/resources/context/access/").toURI().toURL().toString()));
        node.start();
       
        // Code: To access the Spring Application Context instance
        ApplicationContext ctx = SCAApplicationContextProvider.getApplicationContext();
        if (ctx.containsBean("CalculatorServiceBean"))
            System.out.println("CalculatorServiceBean is now available for use...");
             
        CalculatorService calculatorService =
            node.getService(CalculatorService.class, "CalculatorServiceComponent");
               
View Full Code Here

        return windowFactory.createApplicationPage( this, descriptor );
    }

    protected PageDescriptor getPageDescriptor( String pageDescriptorId ) {
        ApplicationContext ctx = Application.instance().getApplicationContext();
        Assert.state( ctx.containsBean( pageDescriptorId ), "Do not know about page or view descriptor with name '"
                + pageDescriptorId + "' - check your context config" );
        Object desc = ctx.getBean( pageDescriptorId );
        if( desc instanceof PageDescriptor ) {
            return (PageDescriptor) desc;
        } else if( desc instanceof ViewDescriptor ) {
View Full Code Here

        }

        Class<? extends Page> pageClass = page.getClass();
        String beanName = toBeanName(pageClass);

        if (applicationContext.containsBean(beanName)
            || applicationContext.containsBean(pageClass.getName())) {

            // Beans are injected through Spring
        } else {
View Full Code Here

        Class<? extends Page> pageClass = page.getClass();
        String beanName = toBeanName(pageClass);

        if (applicationContext.containsBean(beanName)
            || applicationContext.containsBean(pageClass.getName())) {

            // Beans are injected through Spring
        } else {

            // Inject any Spring beans into the page instance
View Full Code Here

  }

  public void testClassPathXmlApplicationContext() throws IOException {
    ApplicationContext context = new ClassPathXmlApplicationContext(
        "/org/springframework/web/context/WEB-INF/applicationContext.xml");
    assertTrue("Has father", context.containsBean("father"));
    assertTrue("Has rod", context.containsBean("rod"));
    assertFalse("Hasn't kerry", context.containsBean("kerry"));
    assertTrue("Doesn't have spouse", ((TestBean) context.getBean("rod")).getSpouse() == null);
    assertTrue("myinit not evaluated", "Roderick".equals(((TestBean) context.getBean("rod")).getName()));
View Full Code Here

  public void testClassPathXmlApplicationContext() throws IOException {
    ApplicationContext context = new ClassPathXmlApplicationContext(
        "/org/springframework/web/context/WEB-INF/applicationContext.xml");
    assertTrue("Has father", context.containsBean("father"));
    assertTrue("Has rod", context.containsBean("rod"));
    assertFalse("Hasn't kerry", context.containsBean("kerry"));
    assertTrue("Doesn't have spouse", ((TestBean) context.getBean("rod")).getSpouse() == null);
    assertTrue("myinit not evaluated", "Roderick".equals(((TestBean) context.getBean("rod")).getName()));

    context = new ClassPathXmlApplicationContext(new String[] {
View Full Code Here

  public void testClassPathXmlApplicationContext() throws IOException {
    ApplicationContext context = new ClassPathXmlApplicationContext(
        "/org/springframework/web/context/WEB-INF/applicationContext.xml");
    assertTrue("Has father", context.containsBean("father"));
    assertTrue("Has rod", context.containsBean("rod"));
    assertFalse("Hasn't kerry", context.containsBean("kerry"));
    assertTrue("Doesn't have spouse", ((TestBean) context.getBean("rod")).getSpouse() == null);
    assertTrue("myinit not evaluated", "Roderick".equals(((TestBean) context.getBean("rod")).getName()));

    context = new ClassPathXmlApplicationContext(new String[] {
      "/org/springframework/web/context/WEB-INF/applicationContext.xml",
View Full Code Here

    assertTrue("myinit not evaluated", "Roderick".equals(((TestBean) context.getBean("rod")).getName()));

    context = new ClassPathXmlApplicationContext(new String[] {
      "/org/springframework/web/context/WEB-INF/applicationContext.xml",
      "/org/springframework/web/context/WEB-INF/context-addition.xml" });
    assertTrue("Has father", context.containsBean("father"));
    assertTrue("Has rod", context.containsBean("rod"));
    assertTrue("Has kerry", context.containsBean("kerry"));
  }

  public void testSingletonDestructionOnStartupFailure() throws IOException {
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.