Examples of SpringApplicationContext


Examples of org.apache.xbean.spring.context.SpringApplicationContext

            // set the server base directory system property
            System.setProperty("xbean.base.dir", baseDirectory.getAbsolutePath());

            // load the configuration file
            SpringApplicationContext factory;
            File file = new File(configurationFile);
            if (!file.isAbsolute()) {
                file = new File(baseDirectory, configurationFile);
            }
            if (file.canRead()) {
                try {
                    // configuration file is on the local file system
                    factory = new FileSystemXmlApplicationContext(file.toURL().toString());
                } catch (MalformedURLException e) {
                    throw new FatalStartupError("Error creating url for bootstrap file", e);
                }
            } else {
                // assume it is a classpath resource
                factory = new ClassPathXmlApplicationContext(configurationFile);
            }

            // get the main service from the configuration file
            String[] names = factory.getBeanNamesForType(Main.class);
            Main main = null;
            if (names.length == 0) {
                throw new FatalStartupError("No bean of type: " + Main.class.getName() + " found in the bootstrap file: " + configurationFile, 10);
            }
            main = (Main) factory.getBean(names[0]);
            return main;
        }
        finally {
            Thread.currentThread().setContextClassLoader(oldClassLoader);
        }
View Full Code Here

Examples of org.jtester.annotations.SpringApplicationContext

  public static JTesterBeanFactory initSpringContext(Class testClazz, ApplicationContextFactory contextFactory) {
    JTesterBeanFactory beanFactory = (JTesterBeanFactory) TestedObject.getSpringBeanFactory();
    if (beanFactory != null) {
      return beanFactory;
    }
    SpringApplicationContext annotation = AnnotationUtils.getClassLevelAnnotation(SpringApplicationContext.class,
        testClazz);
    if (annotation == null) {
      return null;
    }

    long startTime = System.currentTimeMillis();

    String[] locations = annotation.value();
    boolean ignoreNoSuchBean = annotation.ignoreNoSuchBean();
    JTesterSpringContext context = contextFactory.createApplicationContext(Arrays.asList(locations),
        ignoreNoSuchBean);

    context.refresh();
    long duration = System.currentTimeMillis() - startTime;
View Full Code Here

Examples of org.jtester.annotations.SpringApplicationContext

   * 注入spring bean
   */
  public SpringFixture() {
    DbFitContext.setRunIn(RunIn.FitNesse);

    SpringApplicationContext anotations = AnnotationUtils.getClassLevelAnnotation(SpringApplicationContext.class,
        this.getClass());
    if (anotations == null) {
      return;
    }
    try {
      String[] locations = anotations.value();
      boolean ignoreNoSuchBean = anotations.ignoreNoSuchBean();
      ctx = new FixtureSpringApplicationContext(locations, this.getClass(), ignoreNoSuchBean);
      FixtureBeanInjector.injectBeans(ctx, this);
      RemoteInvokerRegister.injectSpringBeanRemote(ctx, this);
    } catch (Throwable e) {
      e.printStackTrace();
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.