Spring Framework FileSystemXmlApplicationContext - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework FileSystemXmlApplicationContext class.

This code example shows how to use the following methods:refresh, registerShutdownHook, setConfigLocation
    public static KieModuleModel fromXML(java.net.URL kModuleUrl){
        return fromXML(kModuleUrl, null, null);
    } 
 
    public static KieModuleModel fromXML(String kmoduleXML){
        FileSystemXmlApplicationContext context = new FileSystemXmlApplicationContext();
        //kieSpringApplicationListener = new KieSpringApplicationContext.KieSpringApplicationListener(); 
        //context.addApplicationListener(kieSpringApplicationListener); 
        try { 
            File tempFile = File.createTempFile("kmodule","springXML");
            tempFile.deleteOnExit();
            context.setConfigLocation(tempFile.getAbsolutePath());
        } catch (IOException e) {
            throw new RuntimeException(e);
        } 
        context.refresh();
        context.registerShutdownHook();
        return null;//kieSpringApplicationListener.getKieModuleModel(); 
    } 
 

7
CodeRank
This code example shows how to use the following methods:getBean
 
	} 
 
	@Test
	public void should_create_jgroups_inbound_channel_adapter_with_custom_header_mapper() { 
		FileSystemXmlApplicationContext context = new FileSystemXmlApplicationContext(
				"src/test/resources/custom-inbound-channel-adapter-header-mapper.xml"); 
 
		JGroupsHeaderMapper headerMapper = context.getBean("custom-header-mapper", JGroupsHeaderMapper.class);
 
		JGroupsInboundEndpoint clusterAdapter = context.getBean("cluster-adapter", JGroupsInboundEndpoint.class);
 
		assertThat(clusterAdapter.getHeaderMapper()).isSameAs(headerMapper);
 
	} 
 
	@Test
	public void should_create_jgroups_outbound_channel_adapter() throws Exception {
		FileSystemXmlApplicationContext context = new FileSystemXmlApplicationContext("src/test/resources/outbound-channel-adapter.xml");
 
6
CodeRank
This code example shows how to use the following methods:getBeanDefinitionCount
        URL pathToClasses = getClass().getResource("/FormBuilder.properties");
        String filePath = pathToClasses.toExternalForm();
        //assumes compilation is in target/classes 
        filePath = filePath.replace("target/classes/FormBuilder.properties", "src/main/webapp");
        filePath = filePath + "/WEB-INF/springComponents.xml";
        FileSystemXmlApplicationContext fileCtx = new FileSystemXmlApplicationContext(filePath);
        assertNotNull("fileCtx shouldn't be null", fileCtx);
        assertTrue("fileCtx should contain some beans", fileCtx.getBeanDefinitionCount() > 0);
    } 
} 
6
CodeRank
This code example shows how to use the following methods:
    public static void main(String[] args) {
 
        ApplicationContext ctx1 = new AnnotationConfigApplicationContext(ApplicationContextConfiguration.class);
        transfer(ctx1);
 
        ApplicationContext ctx2 = new FileSystemXmlApplicationContext(
                "classpath:/com/apress/prospringmvc/moneytransfer/annotation/application-context.xml"); 
        transfer(ctx2);
 
        ApplicationContextLogger.log(ctx1);
        ApplicationContextLogger.log(ctx2);
    } 
 
    private static void transfer(ApplicationContext ctx) {
        MoneyTransferService service = ctx.getBean("moneyTransferService", MoneyTransferService.class);
        Transaction transaction = service.transfer("123456", "654321", new BigDecimal("250.00"));
        logger.info("Money Transfered: {}", transaction);
    } 
} 
5
CodeRank
This code example shows how to use the following methods:
        super(parent); 
    } 
 
    public NimbusFileSystemXmlApplicationContext(String configLocation) 
            throws BeansException { 
        super(configLocation); 
    } 
 
    public NimbusFileSystemXmlApplicationContext(String[] configLocations) 
            throws BeansException { 
        super(configLocations); 
    } 
 
    public NimbusFileSystemXmlApplicationContext(String[] configLocations, ApplicationContext parent) 
            throws BeansException { 
        super(configLocations, parent); 
    } 
 
    public NimbusFileSystemXmlApplicationContext(String[] configLocations, boolean refresh) 
            throws BeansException { 
5
CodeRank
This code example shows how to use the following methods:getBean, registerShutdownHook
			System.out.println("Cache Server port " + port + " is not available. Is another instance running?");
			System.exit(1);
		} 
		logger.info("Starting Cache Server");
		@SuppressWarnings("resource") 
		FileSystemXmlApplicationContext context = new FileSystemXmlApplicationContext(path);
		context.registerShutdownHook();
		Cache cache = context.getBean(Cache.class);
		ManagementService ms = ManagementService.getExistingManagementService(cache);
		CacheServerMXBean cacheServerManager = ms.getLocalCacheServerMXBean(port);
		if (!cacheServerManager.isRunning()) {
			System.out.println("failed to start cache server ");
			System.exit(1);
		} 
		System.out.println("cache server running");
	} 
 
	public static boolean portAvailable(int port) {
		InetSocketAddress addr = new InetSocketAddress(port);
		try { 
5
CodeRank
This code example shows how to use the following methods:
        assertEquals("JMX value incorrect, should be 1", new Long(1), exchangesCompleted);
    } 
 
    @Before 
    public void setUp() throws Exception {
        applicationContext = new FileSystemXmlApplicationContext("src/main/webapp/WEB-INF/applicationContext.xml");
        applicationContext.start();
        Map<String, CamelContext> beansOfType = applicationContext.getBeansOfType(CamelContext.class);
        camelContext = beansOfType.isEmpty() ? null : beansOfType.values().iterator().next();
        assertNotNull("camelContext", camelContext);
    } 
 
    @After 
    public void tearDown() throws Exception {
        if (applicationContext != null) {
            applicationContext.stop();
        } 
    } 
} 
5
CodeRank
This code example shows how to use the following methods:
        log.info("XML is: " + xml);
    } 
 
    @Before 
    public void setUp() throws Exception {
        applicationContext = new FileSystemXmlApplicationContext("src/main/webapp/WEB-INF/applicationContext.xml");
        applicationContext.start();
        Map<String, CamelContext> beansOfType = applicationContext.getBeansOfType(CamelContext.class);
        camelContext = beansOfType.isEmpty() ? null : beansOfType.values().iterator().next();
        assertNotNull("camelContext", camelContext);
    } 
 
    @After 
    public void tearDown() throws Exception {
        if (applicationContext != null) {
            applicationContext.stop();
        } 
    } 
} 
5
CodeRank
This code example shows how to use the following methods:close
String contextPath = args[0];
        File outputFile = new File(args[1]);
         
        // Create the Spring context 
        FileSystemXmlApplicationContext context = new FileSystemXmlApplicationContext(contextPath);
        DbToXML dbToXML = new DbToXML(context, outputFile);
         
        dbToXML.execute();
         
        // Shutdown the Spring context 
        context.close();
    } 
} 
5
CodeRank
This code example shows how to use the following methods:
package org.cronhub.managesystem.commons.utils.container; 
 
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
 
public class Container { 
	private static ApplicationContext context = new FileSystemXmlApplicationContext("classpath:spring/*.xml");
	public static Object getBean(String beanId){
		return context.getBean(beanId);
	} 
	 
} 
4
CodeRank