Package org.springframework.context

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


 
    public void testContextAware() {
      assertTrue(broker instanceof XBeanBrokerService);
      assertTrue(broker instanceof ApplicationContextAware);
      ApplicationContext context = ((XBeanBrokerService)broker).getApplicationContext();
      assertTrue(context.containsBean("org.apache.activemq.xbean.XBeanBrokerService"));
    }
}
View Full Code Here


  protected static Object getScopeService(IScope scope, String name, Class<?> defaultClass) {
    if (scope != null) {
      final IContext context = scope.getContext();
      ApplicationContext appCtx = context.getApplicationContext();
      Object result;
      if (!appCtx.containsBean(name)) {
        if (defaultClass == null) {
          return null;
        }
        try {
          result = defaultClass.newInstance();
View Full Code Here

    }

    public Object getBean(String name)
    {
        ApplicationContext appContext = WebApplicationContextUtils.getRequiredWebApplicationContext(context);
        if (appContext.containsBean(name))
        {
            return appContext.getBean(name);
        }
        else
        {
View Full Code Here

        final ApplicationContext ctx = ((ConfigurableApplicationContext) schedulerContext.get("applicationContext"));

        // Try to re-create job bean from underlying task (useful for managing
        // failover scenarios)
        if (!ctx.containsBean(bundle.getJobDetail().getName())) {
            Long taskId = JobInstanceLoader.getTaskIdFromJobName(bundle.getJobDetail().getName());
            if (taskId != null) {
                TaskDAO taskDAO = ctx.getBean(TaskDAO.class);
                SchedTask task = taskDAO.find(taskId);
View Full Code Here

  @Test
  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

  @Test
  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"));
  }

  @Test
View Full Code Here

    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"));
  }

  @Test
  public void testSingletonDestructionOnStartupFailure() throws IOException {
View Full Code Here

    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"));
  }

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