Package org.springframework.context.support

Examples of org.springframework.context.support.GenericApplicationContext


  // internal helpers

  private void initLocalFlowContext() {
    Resource[] contextResources = parseContextResources(getFlowModel().getBeanImports());
    GenericApplicationContext flowContext = createFlowApplicationContext(contextResources);
    setLocalContext(new LocalFlowBuilderContext(getContext(), flowContext));
  }
View Full Code Here


    }
  }

  private GenericApplicationContext createFlowApplicationContext(Resource[] resources) {
    ApplicationContext parent = getContext().getApplicationContext();
    GenericApplicationContext flowContext;
    if (parent instanceof WebApplicationContext) {
      GenericWebApplicationContext webContext = new GenericWebApplicationContext();
      webContext.setServletContext(((WebApplicationContext) parent).getServletContext());
      flowContext = webContext;
    } else {
      flowContext = new GenericApplicationContext();
    }
    flowContext.setDisplayName("Flow ApplicationContext [" + getContext().getFlowId() + "]");
    flowContext.setParent(parent);
    flowContext.getBeanFactory().registerScope("request", new RequestScope());
    flowContext.getBeanFactory().registerScope("flash", new FlashScope());
    flowContext.getBeanFactory().registerScope("view", new ViewScope());
    flowContext.getBeanFactory().registerScope("flow", new FlowScope());
    flowContext.getBeanFactory().registerScope("conversation", new ConversationScope());
    Resource flowResource = flowModelHolder.getFlowModelResource();
    flowContext.setResourceLoader(new FlowRelativeResourceLoader(flowResource));
    if (JdkVersion.isAtLeastJava15()) {
      AnnotationConfigUtils.registerAnnotationConfigProcessors(flowContext);
    }
    new XmlBeanDefinitionReader(flowContext).loadBeanDefinitions(resources);
    registerFlowBeans(flowContext.getBeanFactory());
    registerMessageSource(flowContext, flowResource);
    flowContext.refresh();
    return flowContext;
  }
View Full Code Here

public class SimpleScopeTests extends TestCase {

  private GenericApplicationContext applicationContext;
 
  protected void setUp() {
    applicationContext = new GenericApplicationContext();
    Scope scope = new NoOpScope() {
      private int index;
      private List objects = new LinkedList(); {
        objects.add(new TestBean());
        objects.add(new TestBean());
View Full Code Here

     * @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));
View Full Code Here

            System.setProperty("org.apache.cxf.transports.http_jetty.DontClosePort", close);
        }
    }
   
    public void setUpBus(boolean includeService) throws Exception {
        applicationContext = new GenericApplicationContext();
        readBeans(new ClassPathResource("/org/apache/cxf/systest/http_jetty/cxf.xml"));
        readBeans(new ClassPathResource("META-INF/cxf/cxf.xml"));
        readBeans(new ClassPathResource("jetty-engine.xml", getClass()));
        if (includeService) {
            readBeans(new ClassPathResource("server-lifecycle-beans.xml", getClass()));
View Full Code Here

            //throw new ServletException(e);
        }
       
        if (is != null) {
            LOG.log(Level.INFO, "BUILD_ENDPOINTS_FROM_CONFIG_LOCATION", new Object[]{location});
            childCtx = new GenericApplicationContext(ctx);
           
            XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(childCtx);
            reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_XSD);
            reader.loadBeanDefinitions(new InputStreamResource(is, location));
           
View Full Code Here

*/

public class GenericApplicationContextUtil {
    public static GenericApplicationContext getSpringApplicationContext(
            InputStream applicationContxtInStream, String springBeansFilePath) throws AxisFault {
        GenericApplicationContext appContext = new GenericApplicationContext();

        XmlBeanDefinitionReader xbdr = new XmlBeanDefinitionReader(appContext);
        xbdr.setValidating(false);
        xbdr.loadBeanDefinitions(new InputStreamResource(applicationContxtInStream));
        appContext.refresh();
        return appContext;
    }
View Full Code Here

        return appContext;
    }

    public static GenericApplicationContext getSpringApplicationContextClassPath(
            ClassLoader classLoader, String relPath) throws AxisFault {
        GenericApplicationContext appContext = new GenericApplicationContext();
        appContext.setClassLoader(classLoader);
        ClassLoader prevCl = Thread.currentThread().getContextClassLoader();
        try {
            Thread.currentThread().setContextClassLoader(classLoader);
            XmlBeanDefinitionReader xbdr = new XmlBeanDefinitionReader(appContext);
            xbdr.setValidating(false);
            InputStream in = classLoader.getResourceAsStream(relPath);
            if (in == null) {
                throw new AxisFault("Spring context cannot be located for AxisService");
            }
            xbdr.loadBeanDefinitions(new InputStreamResource(in));
            appContext.refresh();
        } catch (Exception e) {
            throw AxisFault.makeFault(e);
        } finally {
            // Restore
            Thread.currentThread().setContextClassLoader(prevCl);
View Full Code Here

        return appContext;
    }

    public static GenericApplicationContext getSpringApplicationContext(
            String applicationContxtFilePath, ClassLoader springBeansClassLoader) throws AxisFault {
        GenericApplicationContext appContext = new GenericApplicationContext();

        appContext.setClassLoader(springBeansClassLoader);

        ClassLoader prevCl = Thread.currentThread().getContextClassLoader();

        try {
            // Save the class loader so that you can restore it later
            Thread.currentThread()
                    .setContextClassLoader(
                            new MultiParentClassLoader(new URL[]{}, new ClassLoader[]{
                                    springBeansClassLoader, prevCl}));
            XmlBeanDefinitionReader xbdr = new XmlBeanDefinitionReader(appContext);
            xbdr.setValidating(false);
            xbdr.loadBeanDefinitions(new InputStreamResource(
                    new FileInputStream(new File(applicationContxtFilePath))));
            appContext.refresh();
        } catch (FileNotFoundException e) {
            throw AxisFault.makeFault(e);
        } finally {
            // Restore
            Thread.currentThread().setContextClassLoader(prevCl);
View Full Code Here

*/

public class GenericApplicationContextUtil {
    public static GenericApplicationContext getSpringApplicationContext(
            InputStream applicationContxtInStream, String springBeansFilePath) throws AxisFault {
        GenericApplicationContext appContext = new GenericApplicationContext();

        XmlBeanDefinitionReader xbdr = new XmlBeanDefinitionReader(appContext);
        xbdr.setValidating(false);
        xbdr.loadBeanDefinitions(new InputStreamResource(applicationContxtInStream));
        appContext.refresh();
        return appContext;
    }
View Full Code Here

TOP

Related Classes of org.springframework.context.support.GenericApplicationContext

Copyright © 2018 www.massapicom. 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.