當前位置: 首頁>>代碼示例>>Java>>正文


Java FileSystemXmlApplicationContext類代碼示例

本文整理匯總了Java中org.springframework.context.support.FileSystemXmlApplicationContext的典型用法代碼示例。如果您正苦於以下問題:Java FileSystemXmlApplicationContext類的具體用法?Java FileSystemXmlApplicationContext怎麽用?Java FileSystemXmlApplicationContext使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


FileSystemXmlApplicationContext類屬於org.springframework.context.support包,在下文中一共展示了FileSystemXmlApplicationContext類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: verifyEmbeddedConfigurationContext

import org.springframework.context.support.FileSystemXmlApplicationContext; //導入依賴的package包/類
@Test
public void verifyEmbeddedConfigurationContext() {
    final PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer();
    final Properties properties = new Properties();
    properties.setProperty("mongodb.host", "ds061954.mongolab.com");
    properties.setProperty("mongodb.port", "61954");
    properties.setProperty("mongodb.userId", "casuser");
    properties.setProperty("mongodb.userPassword", "Mellon");
    properties.setProperty("cas.service.registry.mongo.db", "jasigcas");
    configurer.setProperties(properties);

    final FileSystemXmlApplicationContext ctx = new FileSystemXmlApplicationContext(
            new String[]{"src/main/resources/META-INF/spring/mongo-services-context.xml"}, false);
    ctx.getBeanFactoryPostProcessors().add(configurer);
    ctx.refresh();

    final MongoServiceRegistryDao dao = new MongoServiceRegistryDao();
    dao.setMongoTemplate(ctx.getBean("mongoTemplate", MongoTemplate.class));
    cleanAll(dao);
    assertTrue(dao.load().isEmpty());
    saveAndLoad(dao);
}
 
開發者ID:hsj-xiaokang,項目名稱:springboot-shiro-cas-mybatis,代碼行數:23,代碼來源:MongoServiceRegistryDaoTests.java

示例2: main

import org.springframework.context.support.FileSystemXmlApplicationContext; //導入依賴的package包/類
public static void main(String[] args)
{
    if (args.length != 2)
    {
        System.err.println("Usage:");
        System.err.println("java " + DbToXML.class.getName() + " <context.xml> <output.xml>");
        System.exit(1);
    }
    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();
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:21,代碼來源:DbToXML.java

示例3: fileSystemXmlApplicationContext

import org.springframework.context.support.FileSystemXmlApplicationContext; //導入依賴的package包/類
@Test
public void fileSystemXmlApplicationContext() throws IOException {
	ClassPathResource xml = new ClassPathResource(XML_PATH);
	File tmpFile = File.createTempFile("test", "xml");
	FileCopyUtils.copy(xml.getFile(), tmpFile);

	// strange - FSXAC strips leading '/' unless prefixed with 'file:'
	ConfigurableApplicationContext ctx =
			new FileSystemXmlApplicationContext(new String[] {"file:" + tmpFile.getPath()}, false);
	ctx.setEnvironment(prodEnv);
	ctx.refresh();
	assertEnvironmentBeanRegistered(ctx);
	assertHasEnvironment(ctx, prodEnv);
	assertEnvironmentAwareInvoked(ctx, ctx.getEnvironment());
	assertThat(ctx.containsBean(DEV_BEAN_NAME), is(false));
	assertThat(ctx.containsBean(PROD_BEAN_NAME), is(true));
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:18,代碼來源:EnvironmentSystemIntegrationTests.java

示例4: main

import org.springframework.context.support.FileSystemXmlApplicationContext; //導入依賴的package包/類
public static void main(String[] args) throws IOException {
        ClassPathResource classPathResource = new ClassPathResource("beans.xml");
        DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
        XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(factory);

        reader.loadBeanDefinitions(classPathResource);

        Person person = factory.getBean("person",Person.class);
        System.out.println(person.getHand());

        System.out.println(person.getName());
        System.out.println(classPathResource.getURL());
        System.out.println(classPathResource.getFile().getAbsolutePath());

        String fileUrl = classPathResource.getFile().getAbsolutePath();
        ApplicationContext context = new FileSystemXmlApplicationContext("/Users/fahai/soft/project/meta/src/main/resources/beans.xml");
        Person person1 = (Person) factory.getBean("person");
//        System.out.println(person1.getName());
//        DefaultListableBeanFactory


    }
 
開發者ID:programTang,項目名稱:meta,代碼行數:23,代碼來源:TestDefaultListableBeanFactory.java

示例5: init

import org.springframework.context.support.FileSystemXmlApplicationContext; //導入依賴的package包/類
/**
 * Initialize the security manager using the spring security configuration.
 */
public void init(Properties properties) throws SecurityException {
	String configLocation = properties.getProperty(SPRING_SECURITY_CONFIG_LOCATION, "security-config.xml");
	if (logger.isLoggable(Level.CONFIG)) {
	    logger.config("spring-security-config-location: " + configLocation + ", absolute path: " + new File(configLocation).getAbsolutePath());
	}
	
	/*
	 * Extract Spring AuthenticationManager definition
	 */
	applicationContext = new FileSystemXmlApplicationContext(configLocation);
	Map<String, AuthenticationManager> beansOfType = applicationContext.getBeansOfType(AuthenticationManager.class);
	if (beansOfType.isEmpty()) {
	    throw new SecurityException("No bean of type '"+AuthenticationManager.class.getName()+"' is defined in " + configLocation);
	}
	if (beansOfType.size() > 1) {
	    throw new SecurityException("More than one bean of type '"+AuthenticationManager.class.getName()+"' is defined in " + configLocation);
	}
	authenticationManager = beansOfType.values().iterator().next();
}
 
開發者ID:Gigaspaces,項目名稱:xap-openspaces,代碼行數:23,代碼來源:SpringSecurityManager.java

示例6: readConfigFromXmlFile

import org.springframework.context.support.FileSystemXmlApplicationContext; //導入依賴的package包/類
private static ApplicationConfig readConfigFromXmlFile(final String applicationFilePath) throws BeansException {
    ApplicationConfig config;
   
    // Convert to URL to workaround the "everything is a relative paths problem"
    // see spring documentation 5.7.3 FileSystemResource caveats.
    String fileUri = new File(applicationFilePath).toURI().toString();
    final FileSystemXmlApplicationContext context = new FileSystemXmlApplicationContext(fileUri);
            
    try {
        //CR: Catch runtime exceptions. convert to AdminException(s)
        context.refresh();
        config = context.getBean(ApplicationConfig.class);
    }
    finally {
        if (context.isActive()) {
            context.close();
        }
    }
    return config;
}
 
開發者ID:Gigaspaces,項目名稱:xap-openspaces,代碼行數:21,代碼來源:ApplicationFileDeployment.java

示例7: main

import org.springframework.context.support.FileSystemXmlApplicationContext; //導入依賴的package包/類
public static void main(String[] args) {
	if (args.length == 0 || "".equals(args[0])) {
		System.out.println(
				"You need to specify an order ID and optionally a number of calls, e.g. for order ID 1000: " +
				"'client 1000' for a single call per service or 'client 1000 10' for 10 calls each");
	}
	else {
		int orderId = Integer.parseInt(args[0]);
		int nrOfCalls = 1;
		if (args.length > 1 && !"".equals(args[1])) {
			nrOfCalls = Integer.parseInt(args[1]);
		}
		ListableBeanFactory beanFactory = new FileSystemXmlApplicationContext(CLIENT_CONTEXT_CONFIG_LOCATION);
		OrderServiceClient client = new OrderServiceClient(beanFactory);
		client.invokeOrderServices(orderId, nrOfCalls);
	}
}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:18,代碼來源:OrderServiceClient.java

示例8: main

import org.springframework.context.support.FileSystemXmlApplicationContext; //導入依賴的package包/類
/**
 * The standard main method which is used by JVM to start execution of the Java class.
 * @param args
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
		
		// Start Spring context for the Consumer 
		FileSystemXmlApplicationContext context = new FileSystemXmlApplicationContext("src/main/resources/SpringBeans.xml");
		
        String total = null;
        String host = "localhost";
        try {
        	host = args[0];
        	total = args[1];
        	_log.info("-------------------------------------");
        	_log.info("Active MQ host >>>> "+host);
        	_log.info("Total messages to send >>>> "+total);
        	_log.info("-------------------------------------");
        	// Start the  publishing of some  messages using regular HTTP POST
        	sendMessage(host, Integer.valueOf(total));
		} catch (Exception e) {
			_log.info("------------------------------------------------------------------------------------------------------------------");
        	_log.info("PAY ATTENTION!!! You must enter the Active MQ host and a number representing the total  messages to produce");
        	_log.info("------------------------------------------------------------------------------------------------------------------");
        	_log.info("Example: mvn exec:java -Dexec.args=\"localhost 10\"");
			System.exit(1);
		}
	}
 
開發者ID:giuseppeurso-eu,項目名稱:activemq,代碼行數:30,代碼來源:Demo.java

示例9: HapporSpringContext

import org.springframework.context.support.FileSystemXmlApplicationContext; //導入依賴的package包/類
public HapporSpringContext(final ClassLoader classLoader, String filename) {
	this.classLoader = classLoader;
	
	ctx = new FileSystemXmlApplicationContext(filename) {
		@Override
		protected void initBeanDefinitionReader(XmlBeanDefinitionReader reader) {
            super.initBeanDefinitionReader(reader);
            reader.setBeanClassLoader(classLoader);
            setClassLoader(classLoader);
		}
	};
	
	registerAllBeans();

	setServer(ctx.getBean(HapporWebserver.class));

	try {
		setWebserverHandler(ctx.getBean(WebserverHandler.class));
	} catch (NoSuchBeanDefinitionException e) {
		logger.warn("has no WebserverHandler");
	}
	

}
 
開發者ID:xphh,項目名稱:happor,代碼行數:25,代碼來源:HapporSpringContext.java

示例10: startNodes

import org.springframework.context.support.FileSystemXmlApplicationContext; //導入依賴的package包/類
/**
 *
 * @throws Exception If failed.
 */
private void startNodes() throws Exception {
    AbstractApplicationContext ctxSpring = new FileSystemXmlApplicationContext(springCfgFileOutTmplName + 0);

    // We have to deploy Services for service is available at the bean creation time for other nodes.
    Ignite ignite = (Ignite)ctxSpring.getBean("testIgnite");

    ignite.services().deployMultiple(SERVICE_NAME, new DummyServiceImpl(), NODES, 1);

    // Add other nodes.
    for (int i = 1; i < NODES; ++i)
        new FileSystemXmlApplicationContext(springCfgFileOutTmplName + i);

    assertEquals(NODES, G.allGrids().size());
    assertEquals(NODES, ignite.cluster().nodes().size());
}
 
開發者ID:apache,項目名稱:ignite,代碼行數:20,代碼來源:GridServiceInjectionSpringResourceTest.java

示例11: main

import org.springframework.context.support.FileSystemXmlApplicationContext; //導入依賴的package包/類
public static void main(String[] args) {
		FileSystemXmlApplicationContext applicationContext=new FileSystemXmlApplicationContext("classpath:applicationContext.xml");
		
//		MemcachedCache cache=(MemcachedCache) applicationContext.getBean("memClient");
//		IMemcachedCache cc=cache.getCache();
		
	//cache.put("1111", object)''
	//	System.out.println(cache.get("emp1"));
		AService a=(AService) applicationContext.getBean("aimpl");
	//	AService B=(AService) applicationContext.getBean("bimpl");
		System.out.println((String)a.testaop("test2"));
	//	B.before();
//		System.out.println(emp.getCompanyName());
		
		
	}
 
開發者ID:Yaccc,項目名稱:spring_mem_plugin,代碼行數:17,代碼來源:Main.java

示例12: WebServiceProxy

import org.springframework.context.support.FileSystemXmlApplicationContext; //導入依賴的package包/類
/**
 * Initializes the web service proxy based on the handle to the File.
 * 
 * @param configurationFile
 *            The File handle to the configuration file.
 */
public WebServiceProxy(File configurationFile) {
	String path = configurationFile.getAbsolutePath();
	FileSystemXmlApplicationContext applicationContext = new FileSystemXmlApplicationContext(
			"file:" + path);

	try {
		this.webProxyConfiguration = applicationContext
				.getBean(WebProxyConfiguration.class);

		Map<String, ModuleConfiguration> moduleConfigurations = applicationContext
				.getBeansOfType(ModuleConfiguration.class);

		initializeModules(moduleConfigurations.values());
	} finally {
		applicationContext.close();
	}
}
 
開發者ID:datacleaner,項目名稱:easydq_webservice_proxy,代碼行數:24,代碼來源:WebServiceProxy.java

示例13: testInjection

import org.springframework.context.support.FileSystemXmlApplicationContext; //導入依賴的package包/類
@Test
	public void testInjection(){
		System.setProperty("log.path", ProjectConfig.getProperty("log.path"));
		
		@SuppressWarnings("resource")
		ApplicationContext context = new FileSystemXmlApplicationContext("src/main/webapp/WEB-INF/spring/applicationContext.xml");
	
		SysSettingService sysSettingService = (SysSettingService)context.getBean("sysSettingService");
	
//		SysSetting sysSetting = new SysSetting();
//		
//		sysSetting.setCreateperson(1);
//		sysSetting.setEditperson(1);
//		sysSetting.setCreatetime(new Date());
//		sysSetting.setEdittime(new Date());
//		sysSetting.setPropKey("係統安全級別");
//		sysSetting.setPropValue("高級");
//		sysSetting.setRemark("在此安全級別下,任何未授權訪問都會被拒絕。");
//		
//		sysSettingService.save(sysSetting);
		
		System.err.println(Util.getJsonObject(sysSettingService.selectAll()));
				
	}
 
開發者ID:doomdagger,項目名稱:s_framework,代碼行數:25,代碼來源:TestModelUnitTest.java

示例14: fileSystemXmlApplicationContext

import org.springframework.context.support.FileSystemXmlApplicationContext; //導入依賴的package包/類
@Test
public void fileSystemXmlApplicationContext() throws IOException {
	ClassPathResource xml = new ClassPathResource(XML_PATH);
	File tmpFile = File.createTempFile("test", "xml");
	FileCopyUtils.copy(xml.getFile(), tmpFile);

	// strange - FSXAC strips leading '/' unless prefixed with 'file:'
	ConfigurableApplicationContext ctx =
		new FileSystemXmlApplicationContext(new String[] { "file:"+tmpFile.getPath() }, false);
	ctx.setEnvironment(prodEnv);
	ctx.refresh();
	assertEnvironmentBeanRegistered(ctx);
	assertHasEnvironment(ctx, prodEnv);
	assertEnvironmentAwareInvoked(ctx, ctx.getEnvironment());
	assertThat(ctx.containsBean(DEV_BEAN_NAME), is(false));
	assertThat(ctx.containsBean(PROD_BEAN_NAME), is(true));
}
 
開發者ID:deathspeeder,項目名稱:class-guard,代碼行數:18,代碼來源:EnvironmentIntegrationTests.java

示例15: loadCxt

import org.springframework.context.support.FileSystemXmlApplicationContext; //導入依賴的package包/類
public static ApplicationContext loadCxt(String path)
{
	try
	{
		return new ClassPathXmlApplicationContext(path);
	}
	catch(Throwable t)
	{
		try
		{
			if(t.getCause() instanceof FileNotFoundException)
				return new FileSystemXmlApplicationContext(path);
		}
		catch(Throwable t1)
		{
			lg.error("loading spring context fail",t1);
			return null;
		}
		lg.error("loading spring context fail",t);
	}
	return null;
}
 
開發者ID:zhanggh,項目名稱:mtools,代碼行數:23,代碼來源:SpringUtil.java


注:本文中的org.springframework.context.support.FileSystemXmlApplicationContext類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。