Examples of GenericApplicationContext


Examples of com.khs.sherpa.context.GenericApplicationContext

      } catch (NoSuchMethodException e) {
        e.printStackTrace();
        throw new SherpaRuntimeException(e);
      }
    } else {
      applicationContext = new GenericApplicationContext();
    }
   
    ManagedBeanFactory managedBeanFactory = applicationContext.getManagedBeanFactory();
   
    applicationContext.setAttribute(ApplicationContext.CONTEXT_PATH,
View Full Code Here

Examples of org.springframework.context.support.GenericApplicationContext

        SynapseLog synLog) {

        if (synLog.isTraceOrDebugEnabled()) {
            synLog.traceOrDebug("Creating Spring ApplicationContext from key : " + configKey);
        }
        GenericApplicationContext appContext = new GenericApplicationContext();
        XmlBeanDefinitionReader xbdr = new XmlBeanDefinitionReader(appContext);
        xbdr.setValidating(false);

        Object springConfig = synCtx.getEntry(configKey);
        if(springConfig == null) {
          String errorMessage = "Cannot look up Spring configuration " + configKey;
          log.error(errorMessage);
          throw new SynapseException(errorMessage);
        }

        xbdr.loadBeanDefinitions(
            new InputStreamResource(
                SynapseConfigUtils.getStreamSource(springConfig).getInputStream()));
        appContext.refresh();
        if (synLog.isTraceOrDebugEnabled()) {
            synLog.traceOrDebug("Spring ApplicationContext from key : " + configKey + " created");
        }
        this.appContext = appContext;
    }
View Full Code Here

Examples of org.springframework.context.support.GenericApplicationContext



    static GenericApplicationContext getContext() {
        log.info("Creating Spring Application Context ...");
        GenericApplicationContext ctx = new GenericApplicationContext();
        XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(ctx);
        reader.loadBeanDefinitions(new ClassPathResource("/applicationContext.xml"));

        ctx.refresh();
        return ctx;
    }
View Full Code Here

Examples of org.springframework.context.support.GenericApplicationContext

     * @return
     */
    public static ApplicationContext getApplicationContext(List<String> additionalFilePathnames) {
        BusApplicationContext busApplicationContext = BusFactory.getDefaultBus()
            .getExtension(BusApplicationContext.class);
        GenericApplicationContext appContext = new GenericApplicationContext(busApplicationContext);
        XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(appContext);
        List<URL> urls = ClassLoaderUtils.getResources("META-INF/cxf/java2wsbeans.xml",
                                                       SpringServiceBuilderFactory.class);
        for (URL url : urls) {
            reader.loadBeanDefinitions(new UrlResource(url));
        }
       
        for (String pathname : additionalFilePathnames) {
            try {
                reader.loadBeanDefinitions(new FileSystemResource(pathname));
            } catch (BeanDefinitionStoreException bdse) {
                throw new ToolException("Unable to open bean definition file " + pathname, bdse.getCause());
            }
        }
        appContext.refresh();
        return appContext;
    }
View Full Code Here

Examples of org.springframework.context.support.GenericApplicationContext

    DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
    beanFactory.registerBeanDefinition("addressRepository", getRepositoryBeanDefinition(AddressRepository.class));
    beanFactory.registerBeanDefinition("personRepository", getRepositoryBeanDefinition(PersonRepository.class));

    context = new GenericApplicationContext(beanFactory);
    context.refresh();
  }
View Full Code Here

Examples of org.springframework.context.support.GenericApplicationContext

            context.setParent(parent);
            context.setClassLoader(classLoader);
            return context;
        } catch (ClassNotFoundException e) {
            // create generic application context
            GenericApplicationContext context = new GenericApplicationContext(parent);
            context.setClassLoader(classLoader);
            ResourceLoader resourceLoader = new DefaultResourceLoader(classLoader);
            context.setResourceLoader(resourceLoader);
            BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
            for (String resource : resources) {
                reader.loadBeanDefinitions(resourceLoader.getResource(resource));
            }
            context.refresh();
            return context;
        }

    }
View Full Code Here

Examples of org.springframework.context.support.GenericApplicationContext

    when(factory.getObject()).thenReturn(repository);
    when(factory.getObjectType()).thenReturn(PersonRepository.class);
    when(factory.getEntityInformation()).thenReturn(entityInformation);
    when(factory.getRepositoryInformation()).thenReturn(information);

    GenericApplicationContext context = new GenericApplicationContext(beanFactory);
    context.refresh();
    assertThat(context.getBeansOfType(RepositoryFactoryInformation.class).values().size(), is(1));

    DomainClassConverter converter = new DomainClassConverter(new DefaultConversionService());
    converter.setApplicationContext(context);

    assertThat(converter.matches(TypeDescriptor.valueOf(String.class), TypeDescriptor.valueOf(Person.class)), is(true));
View Full Code Here

Examples of org.springframework.context.support.GenericApplicationContext

    builder.addPropertyValue("repositoryInterface", EntityRepository.class);

    DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
    factory.registerBeanDefinition("provider", builder.getBeanDefinition());

    context = new GenericApplicationContext(factory);
    context.refresh();
    registrar = new DomainClassPropertyEditorRegistrar();
  }
View Full Code Here

Examples of org.springframework.context.support.GenericApplicationContext

  }

  @Test
  public void matchFailsIfNoDaoAvailable() throws Exception {

    GenericApplicationContext ctx = new GenericApplicationContext();
    ctx.refresh();
    converter.setApplicationContext(ctx);
    assertMatches(false);
  }
View Full Code Here

Examples of org.springframework.context.support.GenericApplicationContext

   */
  @Test
  public void discoversFactoryAndRepoFromParentApplicationContext() {

    ApplicationContext parent = initContextWithRepo();
    GenericApplicationContext context = new GenericApplicationContext(parent);
    context.refresh();

    when(service.canConvert(String.class, Long.class)).thenReturn(true);

    converter.setApplicationContext(context);
    assertThat(converter.matches(sourceDescriptor, targetDescriptor), is(true));
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.