本文整理匯總了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;
}
示例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());
}
示例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();
}
}
示例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");
}
示例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);
}
}
示例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;
}
});
}
示例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();
}
示例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");
}
示例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");
}
示例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");
}
示例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");
}
示例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);
}
示例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());
}
示例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");
}
示例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();
}