当前位置: 首页>>代码示例>>Java>>正文


Java FileSystemResourceLoader类代码示例

本文整理汇总了Java中org.springframework.core.io.FileSystemResourceLoader的典型用法代码示例。如果您正苦于以下问题:Java FileSystemResourceLoader类的具体用法?Java FileSystemResourceLoader怎么用?Java FileSystemResourceLoader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FileSystemResourceLoader类属于org.springframework.core.io包,在下文中一共展示了FileSystemResourceLoader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import org.springframework.core.io.FileSystemResourceLoader; //导入依赖的package包/类
@BeforeMethod(groups = TestGroup.UNIT)
public void setUp() throws Exception {
  _uriInfo = new MockUriInfo(true);
  _secMaster = new InMemorySecurityMaster();
  _secLoader = new AbstractSecurityLoader() {
    @Override
    protected SecurityLoaderResult doBulkLoad(SecurityLoaderRequest request) {
      throw new UnsupportedOperationException("load security not supported");
    }
  };
  _orgMaster = new InMemoryLegalEntityMaster();
  
  HistoricalTimeSeriesMaster htsMaster = new InMemoryHistoricalTimeSeriesMaster();
  addSecurity(WebResourceTestUtils.getEquitySecurity());
  addSecurity(WebResourceTestUtils.getBondFutureSecurity());
      
  _webSecuritiesResource = new WebSecuritiesResource(_secMaster, _secLoader, htsMaster, _orgMaster);
  MockServletContext sc = new MockServletContext("/web-engine", new FileSystemResourceLoader());
  Configuration cfg = FreemarkerOutputter.createConfiguration();
  cfg.setServletContextForTemplateLoading(sc, "WEB-INF/pages");
  FreemarkerOutputter.init(sc, cfg);
  _webSecuritiesResource.setServletContext(sc);
  _webSecuritiesResource.setUriInfo(_uriInfo);
  
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:26,代码来源:AbstractWebSecurityResourceTestCase.java

示例2: configureLogging

import org.springframework.core.io.FileSystemResourceLoader; //导入依赖的package包/类
/**
    * configures logging using custom properties file if specified, or the default one.
    * Log4j also uses any file called log4.properties in the classpath
    *
    * <p>To configure a custom logging file, set a JVM system property on using -D. For example
    * -Dalt.log4j.config.location=file:/home/me/kuali/test/dev/log4j.properties
    * </p>
    *
    * <p>The above option can also be set in the run configuration for the unit test in the IDE.
    * To avoid log4j using files called log4j.properties that are defined in the classpath, add the following system property:
    * -Dlog4j.defaultInitOverride=true
    * </p>
    * @throws IOException
    */
protected void configureLogging() throws IOException {
       ResourceLoader resourceLoader = new FileSystemResourceLoader();
       String altLog4jConfigLocation = System.getProperty(ALT_LOG4J_CONFIG_LOCATION_PROP);
       Resource log4jConfigResource = null;
       if (!StringUtils.isEmpty(altLog4jConfigLocation)) { 
           log4jConfigResource = resourceLoader.getResource(altLog4jConfigLocation);
       }
       if (log4jConfigResource == null || !log4jConfigResource.exists()) {
           System.out.println("Alternate Log4j config resource does not exist! " + altLog4jConfigLocation);
           System.out.println("Using default log4j configuration: " + DEFAULT_LOG4J_CONFIG);
           log4jConfigResource = resourceLoader.getResource(DEFAULT_LOG4J_CONFIG);
       } else {
           System.out.println("Using alternate log4j configuration at: " + altLog4jConfigLocation);
       }
       Properties p = new Properties();
       p.load(log4jConfigResource.getInputStream());
       PropertyConfigurator.configure(p);
   }
 
开发者ID:kuali,项目名称:kc-rice,代码行数:33,代码来源:RiceTestCase.java

示例3: setUp

import org.springframework.core.io.FileSystemResourceLoader; //导入依赖的package包/类
@Override
@Before
public void setUp() throws Exception {
	super.setUp();
	ServletContext servletContext = new MockServletContext(
			new FileSystemResourceLoader());
	requestService = new MockHttpServletRequest("PUT", "/service");
	applicationContext = new XmlWebApplicationContext();
	applicationContext.setServletContext(servletContext);
	applicationContext.setConfigLocations(new String[] {
			"src/main/webapp/WEB-INF/handler-servlet.xml",
			"src/main/webapp/WEB-INF/applicationContext.xml" });
	try{
	applicationContext.refresh();
	}
	catch (Throwable e){
		e.printStackTrace();
	}
	handler = (GWTHandler) applicationContext.getBean("urlMapping", GWTHandler.class);
}
 
开发者ID:ggeorgovassilis,项目名称:gwt-sl,代码行数:21,代码来源:HandlerTest.java

示例4: testSchedulerWithSpringBeanJobFactoryAndJobSchedulingData

import org.springframework.core.io.FileSystemResourceLoader; //导入依赖的package包/类
@Test
public void testSchedulerWithSpringBeanJobFactoryAndJobSchedulingData() throws Exception {
	Assume.group(TestGroup.PERFORMANCE);
	DummyJob.param = 0;
	DummyJob.count = 0;

	SchedulerFactoryBean bean = new SchedulerFactoryBean();
	bean.setJobFactory(new SpringBeanJobFactory());
	bean.setJobSchedulingDataLocation("org/springframework/scheduling/quartz/job-scheduling-data.xml");
	bean.setResourceLoader(new FileSystemResourceLoader());
	bean.afterPropertiesSet();
	bean.start();

	Thread.sleep(500);
	assertEquals(10, DummyJob.param);
	assertTrue(DummyJob.count > 0);

	bean.destroy();
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:20,代码来源:QuartzSupportTests.java

示例5: getResource

import org.springframework.core.io.FileSystemResourceLoader; //导入依赖的package包/类
public static Resource getResource(String sourcePath) {
	String pathToUse = StringUtils.cleanPath(sourcePath);
	if (pathToUse == null) {
		return null;
	}
	Resource resource = null;
	try {
		if (pathToUse.startsWith(org.springframework.core.io.ResourceLoader.CLASSPATH_URL_PREFIX)) {
			resource = new ClassRelativeResourceLoader(ResourceLoader.class).getResource(pathToUse);
		}
		if (resource == null) {
			resource = new FileSystemResourceLoader().getResource(pathToUse);
		}
	} catch (Exception e) {
		log.error("getResource error.", e);
	}
	return resource;
}
 
开发者ID:liufeiit,项目名称:sharding,代码行数:19,代码来源:ResourceLoader.java

示例6: routerResourceLoader

import org.springframework.core.io.FileSystemResourceLoader; //导入依赖的package包/类
@Bean
protected RouterResourceLoader routerResourceLoader() {
    Map<String, ResourceLoader> routerMap = new HashMap<>(RESOURCE_LOADERS_CAPACITY);
    routerMap.put(CLASSPATH_URL_PREFIX, resourceLoader);
    routerMap.put(XM_MS_CONFIG_URL_PREFIX, cfgResourceLoader());
    routerMap.put(FILE_URL_PREFIX, new FileSystemResourceLoader());
    return new RouterResourceLoader(routerMap);
}
 
开发者ID:xm-online,项目名称:xm-commons,代码行数:9,代码来源:LepSpringConfiguration.java

示例7: before

import org.springframework.core.io.FileSystemResourceLoader; //导入依赖的package包/类
@Before
public void before() throws IOException {
    oldUserHome = System.getProperty(USER_HOME);

    // init temp folder
    testScriptDir = folder.newFolder("home", "xm-online", "config", "tenants",
                                     TENANT_KEY_VALUE.toUpperCase(), APP_NAME,
                                     "lep", "resource", "service");


    // init system property
    File userHomeDir = Paths.get(folder.getRoot().toPath().toString(), "home").toFile();
    System.setProperty(USER_HOME, userHomeDir.getAbsolutePath());

    // copy script from classpath to file system tmp folder
    File scriptFile = Paths.get(testScriptDir.getAbsolutePath(), "Script$$before.groovy").toFile();
    if (!scriptFile.createNewFile()) {
        throw new IllegalStateException("Can't create file: " + scriptFile.getAbsolutePath());
    }
    InputStream scriptIn = resourceLoader.getResource(SCRIPT_CLASSPATH_URL).getInputStream();
    Files.copy(scriptIn, scriptFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
    scriptIn.close();

    // init resource service
    Map<String, ResourceLoader> urlPrefixToResourceLoader = new HashMap<>();
    urlPrefixToResourceLoader.put("file:", new FileSystemResourceLoader());
    RouterResourceLoader routerResourceLoader = new RouterResourceLoader(urlPrefixToResourceLoader);
    resourceService = new XmLepResourceService(APP_NAME, FILE, routerResourceLoader);
}
 
开发者ID:xm-online,项目名称:xm-commons,代码行数:30,代码来源:XmLepResourceServiceFileUnitTest.java

示例8: testFileWithSpecialCharsInTheNameBeingResolved

import org.springframework.core.io.FileSystemResourceLoader; //导入依赖的package包/类
public void testFileWithSpecialCharsInTheNameBeingResolved() throws Exception {
       String name = Thread.currentThread().getContextClassLoader().getResource( "test-file" ).toString();
	FileSystemResourceLoader fileLoader = new FileSystemResourceLoader();
	fileLoader.setClassLoader(getClass().getClassLoader());

	Resource fileRes = fileLoader.getResource(name);
	resource = new OsgiBundleResource(bundle, name);

	testFileVsOsgiFileResolution(fileRes, resource);
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:11,代码来源:OsgiBundleResourceTest.java

示例9: testFileWithEmptyCharsInTheNameBeingResolved

import org.springframework.core.io.FileSystemResourceLoader; //导入依赖的package包/类
public void testFileWithEmptyCharsInTheNameBeingResolved() throws Exception {
	String name = Thread.currentThread().getContextClassLoader().getResource( "test file" ).toString();
	FileSystemResourceLoader fileLoader = new FileSystemResourceLoader();
	fileLoader.setClassLoader(getClass().getClassLoader());

	Resource fileRes = fileLoader.getResource(name);
	resource = new OsgiBundleResource(bundle, name);

	testFileVsOsgiFileResolution(fileRes, resource);
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:11,代码来源:OsgiBundleResourceTest.java

示例10: testFileWithNormalCharsInTheNameBeingResolved

import org.springframework.core.io.FileSystemResourceLoader; //导入依赖的package包/类
public void testFileWithNormalCharsInTheNameBeingResolved() throws Exception {
	String name = Thread.currentThread().getContextClassLoader().getResource( "normal" ).toString();
	FileSystemResourceLoader fileLoader = new FileSystemResourceLoader();
	fileLoader.setClassLoader(getClass().getClassLoader());

	Resource fileRes = fileLoader.getResource(name);

	resource = new OsgiBundleResource(bundle, name);
	testFileVsOsgiFileResolution(fileRes, resource);
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:11,代码来源:OsgiBundleResourceTest.java

示例11: resourceLoader

import org.springframework.core.io.FileSystemResourceLoader; //导入依赖的package包/类
@Bean
public ResourceLoader resourceLoader() {
	MavenProperties mavenProperties = new MavenProperties();
	mavenProperties.setRemoteRepositories(new HashMap<>(Collections.singletonMap("springRepo",
			new MavenProperties.RemoteRepository("https://repo.spring.io/libs-snapshot"))));

	Map<String, ResourceLoader> resourceLoaders = new HashMap<>();
	resourceLoaders.put("maven", new MavenResourceLoader(mavenProperties));
	resourceLoaders.put("file", new FileSystemResourceLoader());

	DelegatingResourceLoader delegatingResourceLoader = new DelegatingResourceLoader(resourceLoaders);
	return delegatingResourceLoader;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dashboard,代码行数:14,代码来源:TestDependencies.java

示例12: setUp

import org.springframework.core.io.FileSystemResourceLoader; //导入依赖的package包/类
@Before
public void setUp() {
	this.context = new StaticWebApplicationContext();
	this.context.setServletContext(new MockServletContext(new FileSystemResourceLoader()));
	this.context.registerSingleton("controller", TestController.class);

	this.config = new TestWebMvcConfigurationSupport();
	this.config.setApplicationContext(this.context);
	this.config.setServletContext(this.context.getServletContext());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:11,代码来源:WebMvcConfigurationSupportExtensionTests.java

示例13: initLogging

import org.springframework.core.io.FileSystemResourceLoader; //导入依赖的package包/类
private void initLogging(String location, boolean refreshInterval) {
	MockServletContext sc = new MockServletContext("", new FileSystemResourceLoader());
	sc.addInitParameter(Log4jWebConfigurer.CONFIG_LOCATION_PARAM, location);
	if (refreshInterval) {
		sc.addInitParameter(Log4jWebConfigurer.REFRESH_INTERVAL_PARAM, "10");
	}
	Log4jWebConfigurer.initLogging(sc);

	try {
		assertLogOutput();
	} finally {
		Log4jWebConfigurer.shutdownLogging(sc);
	}
	assertTrue(MockLog4jAppender.closeCalled);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:16,代码来源:Log4jWebConfigurerTests.java

示例14: testLog4jConfigListener

import org.springframework.core.io.FileSystemResourceLoader; //导入依赖的package包/类
@Test
public void testLog4jConfigListener() {
	Log4jConfigListener listener = new Log4jConfigListener();

	MockServletContext sc = new MockServletContext("", new FileSystemResourceLoader());
	sc.addInitParameter(Log4jWebConfigurer.CONFIG_LOCATION_PARAM, RELATIVE_PATH);
	listener.contextInitialized(new ServletContextEvent(sc));

	try {
		assertLogOutput();
	} finally {
		listener.contextDestroyed(new ServletContextEvent(sc));
	}
	assertTrue(MockLog4jAppender.closeCalled);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:16,代码来源:Log4jWebConfigurerTests.java

示例15: createServletContext

import org.springframework.core.io.FileSystemResourceLoader; //导入依赖的package包/类
private ServletContext createServletContext () throws Exception {
  	// Establish the servlet context and config
      final MockServletContext servletContext = new MockServletContext(WEB_APP_PATH, new FileSystemResourceLoader());
      final MockServletConfig servletConfig = new MockServletConfig(servletContext);
      
      // Create a WebApplicationContext and initialize it with the xml and servlet configuration.
      final XmlWebApplicationContext webApplicationContext = new XmlWebApplicationContext();
      servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, webApplicationContext);
      webApplicationContext.setServletConfig(servletConfig);
      
      // Create a DispatcherServlet that uses the previously established WebApplicationContext.
      @SuppressWarnings("serial")
final DispatcherServlet dispatcherServlet = new DispatcherServlet() {
              @Override
              protected WebApplicationContext createWebApplicationContext(ApplicationContext parent) {
                      return webApplicationContext;
              }
      };
      
      // Prepare the context.
      webApplicationContext.refresh();
      webApplicationContext.registerShutdownHook();
      
      // Initialize the servlet.
      dispatcherServlet.setContextConfigLocation("");
      dispatcherServlet.init(servletConfig);
      
      return dispatcherServlet.getServletContext();
  }
 
开发者ID:xenit-eu,项目名称:move2alf,代码行数:30,代码来源:RootMap.java


注:本文中的org.springframework.core.io.FileSystemResourceLoader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。