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


Java FileSystemXmlApplicationContext.getBean方法代碼示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: initialize

import org.springframework.context.support.FileSystemXmlApplicationContext; //導入方法依賴的package包/類
@Before
public void initialize(){

    String contextFile = "/Users/ilinca/IdeaProjects/PhenoImageShare/PhIS/WebContent/WEB-INF/app-config.xml";
    File f = new File(contextFile);
    if (!f.isFile() || !f.canRead()) {
        System.err.println("Context file " + contextFile + " not readable.");
    } else {
        logger.info("--context OK");
    }
    applicationContext = new FileSystemXmlApplicationContext("file:" + contextFile);

    updateService = (GenericUpdateService) applicationContext.getBean("genericUpdateService");
    cs = (ChannelService) applicationContext.getBean("channelService");
    is = (ImageService) applicationContext.getBean("imageService");
    rs = (RoiService) applicationContext.getBean("roiService");

}
 
開發者ID:PhenoImageShare,項目名稱:PhenoImageShare,代碼行數:19,代碼來源:GenericUpdateServiceTest.java

示例5: execute

import org.springframework.context.support.FileSystemXmlApplicationContext; //導入方法依賴的package包/類
@Override
public void execute(ActionMessagePrinter printer)
      throws CmdLineActionException {

   FileSystemXmlApplicationContext appContext = new FileSystemXmlApplicationContext(
         this.beanRepo);

   try {
      ProductCrawler pc = (ProductCrawler) appContext
            .getBean(crawlerId != null ? crawlerId : getName());
      pc.setApplicationContext(appContext);
      if (pc.getDaemonPort() != -1 && pc.getDaemonWait() != -1) {
         new CrawlDaemon(pc.getDaemonWait(), pc, pc.getDaemonPort())
               .startCrawling();
      } else {
         pc.crawl();
      }
   } catch (Exception e) {
      throw new CmdLineActionException("Failed to launch crawler : "
            + e.getMessage(), e);
   }
}
 
開發者ID:apache,項目名稱:oodt,代碼行數:23,代碼來源:CrawlerLauncherCliAction.java

示例6: main

import org.springframework.context.support.FileSystemXmlApplicationContext; //導入方法依賴的package包/類
public static void main(String[] args) throws Base64DecodingException {
	AesCipherService aesCipherService = new AesCipherService();
	aesCipherService.setKeySize(128); 
	FileSystemXmlApplicationContext context = new FileSystemXmlApplicationContext("src/main/resources/applicationContext.xml");
	JdbcTemplate template = (JdbcTemplate) context.getBean("jdbcTemplate");
	Key key = aesCipherService.generateNewKey();
	final byte[] bytes = key.getEncoded();
	final String password = aesCipherService.encrypt(ByteSource.Util.bytes("123456").getBytes(), bytes).toBase64();
	
	System.out.println(password);
	System.out.println(new String(Base64.decode(aesCipherService.decrypt(Base64.decode(password), bytes).toBase64())));
	for(byte b : bytes){
		System.out.print(b+",");
	}
	template.execute("insert into security_user(password,username,password_key) values(?,?,?)", new PreparedStatementCallback(){

		@Override
		public Object doInPreparedStatement(PreparedStatement ps)
				throws SQLException, DataAccessException {
			ps.setString(1, password);
			ps.setString(2, "admin");
			ps.setBytes(3, bytes);
			ps.execute();
			return null;
		}
		
	});
}
 
開發者ID:luozhengjie,項目名稱:RLCMS,代碼行數:29,代碼來源:CrateSecurityUser.java

示例7: JarContainerServer

import org.springframework.context.support.FileSystemXmlApplicationContext; //導入方法依賴的package包/類
public JarContainerServer(String filename) {
	FileSystemXmlApplicationContext serverContext = new FileSystemXmlApplicationContext(filename);
	HapporServerElement element = serverContext.getBean(HapporServerElement.class);
	server = element.getServer();
	containerConfig = element.getConfigs().get("container");
	log4jConfig = element.getConfigs().get("log4j");
	serverContext.close();
}
 
開發者ID:xphh,項目名稱:happor,代碼行數:9,代碼來源:JarContainerServer.java

示例8: getJazzSVNHookService

import org.springframework.context.support.FileSystemXmlApplicationContext; //導入方法依賴的package包/類
/**
 * Recupera a implementação de JazzSVNHookService, para processamento dos hooks de commit do svn
 * 
 * @return
 */
protected static JazzSVNHookService getJazzSVNHookService() {
	FileSystemXmlApplicationContext applicationContext = getApplicationContext();

	//loga beans registrados em FileSystemXmlApplicationContext
	if (log.isDebugEnabled()) {
		log.debug("BEANS REGISTRADOS EM FileSystemXmlApplicationContext");
		String[] names = applicationContext.getBeanDefinitionNames();
		for (String string : names) {
			log.debug(string);
		}
	}

	return (JazzSVNHookService) applicationContext.getBean("jazzSVNHookServiceImpl");
}
 
開發者ID:darciopacifico,項目名稱:omr,代碼行數:20,代碼來源:HookMain.java

示例9: main

import org.springframework.context.support.FileSystemXmlApplicationContext; //導入方法依賴的package包/類
public static void main(String args[]) throws Exception
{
    FileSystemXmlApplicationContext factory = 
        new FileSystemXmlApplicationContext(
            "src/conf/springtest-applicationcontext.xml");

    SpringTestMessage stm = (SpringTestMessage) factory
            .getBean("springtestmessage");
}
 
開發者ID:rwebaz,項目名稱:Java-Lessons-Project,代碼行數:10,代碼來源:SpringTest.java

示例10: IntiRes

import org.springframework.context.support.FileSystemXmlApplicationContext; //導入方法依賴的package包/類
@Before
public void IntiRes() {
    DOMConfigurator.configure("res/appConfig/log4j.xml");
    System.setProperty("java.net.preferIPv4Stack", "true"); //Disable IPv6 in JVM
    springContext = new FileSystemXmlApplicationContext("res/springConfig/spring-context.xml");
    /**初始化spring容器*/
    testPubSub = (TestPubSub) springContext.getBean("testPubSub");

}
 
開發者ID:chenleijava,項目名稱:springJredisCache,代碼行數:10,代碼來源:TestPubSub.java

示例11: main

import org.springframework.context.support.FileSystemXmlApplicationContext; //導入方法依賴的package包/類
public static void main(String[] args) {
	// Load the Spring context. After initialization the
	// afterPropertiesSet() method is called.
	FileSystemXmlApplicationContext context = new FileSystemXmlApplicationContext(
			"application_context.xml");
	
	@SuppressWarnings("unused")
	GigaSpace space = (GigaSpace)context.getBean("space");

}
 
開發者ID:Gigaspaces,項目名稱:xap-tutorial,代碼行數:11,代碼來源:SpringService.java

示例12: EgovPasswordLoad

import org.springframework.context.support.FileSystemXmlApplicationContext; //導入方法依賴的package包/類
/**
 * EgovPasswordLoad Class 생성자
 */
public EgovPasswordLoad()
{
	passwordEncryptor = new ConfigurablePasswordEncryptor();
	context = new FileSystemXmlApplicationContext(default_path);
	cryptoConfig = (CryptoConfig)context.getBean("config");
	String pwdAlgorithm = cryptoConfig.getPasswordAlgorithm();
	if(pwdAlgorithm.trim().length() <=0)
	  passwordEncryptor.setAlgorithm("SHA-1");  
	else
	  passwordEncryptor.setAlgorithm(pwdAlgorithm);   	
	passwordEncryptor.setPlainDigest(true);
}
 
開發者ID:eGovFrame,項目名稱:egovframework.rte.root,代碼行數:16,代碼來源:EgovPasswordLoad.java

示例13: test

import org.springframework.context.support.FileSystemXmlApplicationContext; //導入方法依賴的package包/類
public void test() throws Throwable {
    System.setProperty("port2", "3333");
    
    FileSystemXmlApplicationContext ctx = new FileSystemXmlApplicationContext(
            "src/test/resources/spring-config/config-property-placeholder.xml");

    DefaultFtpServer server = (DefaultFtpServer) ctx.getBean("server");

    assertEquals(2222, server.getListener("listener0").getPort());
    assertEquals(3333, server.getListener("listener1").getPort());
}
 
開發者ID:saaconsltd,項目名稱:mina-ftpserver,代碼行數:12,代碼來源:PropertyPlaceholderTest.java

示例14: setUp

import org.springframework.context.support.FileSystemXmlApplicationContext; //導入方法依賴的package包/類
@Override
protected void setUp() throws Exception {
	super.setUp();
	FileSystemXmlApplicationContext context = new FileSystemXmlApplicationContext("src/main/resources/spring-beans.xml");
	producer = (Producer)context.getBean("producer");
}
 
開發者ID:giuseppeurso-eu,項目名稱:activemq,代碼行數:7,代碼來源:ScheduledConsumerTest.java

示例15: main

import org.springframework.context.support.FileSystemXmlApplicationContext; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
       FileSystemXmlApplicationContext context = new FileSystemXmlApplicationContext("src/main/resources/SpringBeans.xml");
       Producer producer = (Producer)context.getBean("producer");
       producer.start();
}
 
開發者ID:giuseppeurso-eu,項目名稱:activemq,代碼行數:6,代碼來源:App.java


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