List of usage examples for org.springframework.core.io FileSystemResource FileSystemResource
public FileSystemResource(Path filePath)
From source file:dk.nsi.minlog.export.config.ApplicationRootConfig.java
@Bean public static PropertyPlaceholderConfigurer configuration() { final PropertyPlaceholderConfigurer props = new PropertyPlaceholderConfigurer(); props.setLocations(new Resource[] { new ClassPathResource("default.properties"), new FileSystemResource(getProperty("jboss.server.config.url") + "minlog." + getProperty("user.name") + ".properties"), new ClassPathResource("minlog." + getProperty("user.name") + ".properties"), new ClassPathResource("jdbc.default.properties"), new FileSystemResource(getProperty("jboss.server.config.url") + "jdbc." + getProperty("user.name") + ".properties"), new ClassPathResource("jdbc." + getProperty("user.name") + ".properties"), new FileSystemResource(getProperty("user.home") + "/.minlog/passwords.properties") }); props.setIgnoreResourceNotFound(true); props.setSystemPropertiesMode(PropertyPlaceholderConfigurer.SYSTEM_PROPERTIES_MODE_OVERRIDE); return props; }
From source file:com.joshlong.esb.springintegration.modules.net.sftp.Main.java
static void run(SFTPSessionFactory sftpSessionFactory, String lp, String rp) throws Throwable { // local path File local = new File(lp); // obviously this is just for test. Do what you need to do in your own // we are testing, after all if (local.exists() && (local.list().length > 0)) { for (File f : local.listFiles()) { if (!f.delete()) { logger.debug("couldn't delete " + f.getAbsolutePath()); }/* w w w . j a v a2 s.c om*/ } } Resource localDirectory = new FileSystemResource(local); // pool QueuedSFTPSessionPool queuedSFTPSessionPool = new QueuedSFTPSessionPool(sftpSessionFactory); queuedSFTPSessionPool.afterPropertiesSet(); ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler(); taskScheduler.setPoolSize(10); taskScheduler.setErrorHandler(new ErrorHandler() { public void handleError(Throwable t) { logger.debug("error! ", t); } }); taskScheduler.setWaitForTasksToCompleteOnShutdown(true); taskScheduler.initialize(); // synchronizer final SFTPInboundSynchronizer sftpInboundSynchronizer = new SFTPInboundSynchronizer(); sftpInboundSynchronizer.setLocalDirectory(localDirectory); sftpInboundSynchronizer.setRemotePath(rp); sftpInboundSynchronizer.setAutoCreatePath(true); sftpInboundSynchronizer.setPool(queuedSFTPSessionPool); sftpInboundSynchronizer.setShouldDeleteDownloadedRemoteFiles(false); sftpInboundSynchronizer.setTaskScheduler(taskScheduler); sftpInboundSynchronizer.afterPropertiesSet(); sftpInboundSynchronizer.start(); /* new Thread(new Runnable() { public void run() { try { Thread.sleep(60 * 1000); // 1 minute sftpInboundSynchronizer.stop(); } catch (InterruptedException e) { // don't care } } }).start(); */ }
From source file:infowall.infrastructure.PropertyFileLocationBean.java
public PropertyFileLocationBean(ConfigRoot configRoot) { File baseDir = configRoot.getDirectory(); File file = new File(baseDir, "app.properties"); if (!file.exists()) { throw new IllegalArgumentException("Properties file '" + file.getAbsolutePath() + "' does not exist."); }//ww w . j av a 2 s . c o m this.location = new FileSystemResource(file); }
From source file:springmvc.controller.PdfController.java
@RequestMapping(value = "/files/{file_name}", method = RequestMethod.GET) @ResponseBody/*from ww w .j a va 2 s .com*/ public FileSystemResource getFile(@PathVariable("file_name") String fileName) { return new FileSystemResource("/home/scripts/pdf/" + fileName + ".pdf"); }
From source file:org.archive.wayback.accesscontrol.ExternalExcluder.java
private static synchronized ExclusionFilterFactory getFactory(String configPath) { if (factory != null) { return factory; }/*from w ww . jav a 2s.c o m*/ Resource resource = new FileSystemResource(configPath); XmlBeanFactory xmlFactory = new XmlBeanFactory(resource); factory = (ExclusionFilterFactory) xmlFactory.getBean(CONFIG_ID); return factory; }
From source file:org.jtheque.i18n.I18NResourceFactory.java
/** * Construct a I18NResource from the given file. * * @param file The file to use to create the I18NResource. * * @return The I18NResource corresponding to the given file. *//*from w w w . j av a 2 s . com*/ public static I18NResource fromFile(File file) { return new I18NResourceImpl(file.getName(), new FileSystemResource(file)); }
From source file:com.wavemaker.tools.webapp.WebXmlSupportTest.java
public void testReadWrite() throws Exception { File f = new ClassPathResource("com/wavemaker/tools/webapp/" + ProjectConstants.WEB_XML).getFile(); assertTrue(f.exists());// w w w . j ava2 s .c o m WebAppType wat = WebXmlSupport.readWebXml(new FileSystemResource(f)); for (Object o : wat.getDescriptionAndDisplayNameAndIcon()) { if (o instanceof DisplayNameType) { DisplayNameType dnt = (DisplayNameType) o; assertEquals("ActiveGrid Studio", dnt.getValue()); } else if (o instanceof ServletType) { ServletType st = (ServletType) o; assertEquals("springapp", st.getServletName().getValue()); } else { // System.out.println("o: "+o); } } File fp = File.createTempFile("TestWebXmlSupport_testReadWrite", ".xml"); fp.deleteOnExit(); try { OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream(fp)); WebXmlSupport.writeWebXml(wat, osw); String fpContents = FileUtils.readFileToString(fp); assertTrue(fpContents.contains("ActiveGrid Studio")); assertTrue(fpContents.contains("springapp")); WebXmlSupport.readWebXml(new FileSystemResource(fp)); } finally { fp.delete(); } }
From source file:org.apache.uima.ruta.resource.ResourcePathResourceLoader.java
public Resource getResource(String location) { for (String parent : resourcePaths) { final File f = new File(parent, location); if (f.exists()) { return new FileSystemResource(f); }/*from w w w .j a v a 2 s . c o m*/ } return new DescriptiveResource(location + " was not found in resource paths"); }
From source file:example.helloworld.VaultTestConfiguration.java
@Override public SslConfiguration sslConfiguration() { return SslConfiguration.forTrustStore(new FileSystemResource(new File(findWorkDir(), "keystore.jks")), "changeit"); }
From source file:org.cloudfoundry.identity.uaa.config.YamlMapFactoryBeanTests.java
@Test(expected = IllegalStateException.class) public void testSetBarfOnResourceNotFound() throws Exception { factory.setResources(new FileSystemResource[] { new FileSystemResource("non-exsitent-file.yml") }); assertEquals(0, factory.getObject().size()); }