org.springframework.web.context.WebApplicationContext.getResource()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(6.2k)|赞(0)|评价(0)|浏览(84)

本文整理了Java中org.springframework.web.context.WebApplicationContext.getResource()方法的一些代码示例,展示了WebApplicationContext.getResource()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebApplicationContext.getResource()方法的具体详情如下:
包路径:org.springframework.web.context.WebApplicationContext
类名称:WebApplicationContext
方法名:getResource

WebApplicationContext.getResource介绍

暂无

代码示例

代码示例来源:origin: spring-projects/spring-framework

@Test
public void webApplicationContextIsLoaded() {
  // from: src/test/webapp/resources/Spring.js
  Resource resource = wac.getResource("/resources/Spring.js");
  assertNotNull(resource);
  assertTrue(resource.exists());
}

代码示例来源:origin: stackoverflow.com

public void loadDataFixtures() {
   if (loadDataFixtures) {
    ResourceDatabasePopulator populator = new ResourceDatabasePopulator(context.getResource("classpath:/data.sql"));
    DatabasePopulatorUtils.execute(populator, ds);
    loadDataFixtures = false;

代码示例来源:origin: epam/NGB

protected final Resource getTemplateResource(final String name) {
  return trimToNull(name) == null ? null : wac.getResource(TEMPLATES_CLASSPATH + name);
}

代码示例来源:origin: org.apache.cocoon/cocoon-sitemap-impl

/**
 * Get all includes for properties from the sitemap.
 * @param sitemap
 * @return
 */
protected static List getPropertiesIncludes(WebApplicationContext webAppContext,
                      String                contextUrl,
                      Configuration         sitemap)
throws ConfigurationException {
  final List includes = new ArrayList();
  if ( isUsingDefaultIncludes(sitemap) ) {
    final Resource rsrc = webAppContext.getResource(contextUrl + DEFAULT_CHILD_PROPERTIES_LOCATION);
    if ( rsrc.exists() ) {
      includes.add(DEFAULT_CHILD_PROPERTIES_LOCATION);
    }
  }
  final Configuration[] includeConfigs = sitemap.getChild("components").getChildren("include-properties");
  for(int i = 0 ; i < includeConfigs.length; i++ ) {
    final String dir = includeConfigs[i].getAttribute("dir");
    includes.add(dir);
  }
  return includes;
}

代码示例来源:origin: org.apache.cocoon/cocoon-sitemap-impl

/**
 * Get all includes for bean configurations from the sitemap.
 * @param sitemap
 * @return
 */
protected static List getBeanIncludes(WebApplicationContext webAppContext,
                   String                contextUrl,
                   Configuration         sitemap)
throws ConfigurationException {
  final List includes = new ArrayList();
  if ( isUsingDefaultIncludes(sitemap) ) {
    final Resource rsrc = webAppContext.getResource(contextUrl + DEFAULT_CHILD_SPRING_CONFIGURATION_LOCATION);
    if ( rsrc.exists() ) {
      includes.add(DEFAULT_CHILD_SPRING_CONFIGURATION_LOCATION);
    }
  }
  final Configuration[] includeConfigs = sitemap.getChild("components").getChildren("include-beans");
  for(int i = 0 ; i < includeConfigs.length; i++ ) {
    final String dir = includeConfigs[i].getAttribute("dir");
    includes.add(dir);
  }
  return includes;
}

代码示例来源:origin: com.trifork.emobility.shared/TokenParser

@Override
public void init(FilterConfig config) throws ServletException {
  ServletContext servletContext = config.getServletContext();
  WebApplicationContext webApplicationContext = WebApplicationContextUtils.getWebApplicationContext(servletContext);
  AutowireCapableBeanFactory autowireCapableBeanFactory = webApplicationContext.getAutowireCapableBeanFactory();
  autowireCapableBeanFactory.autowireBean(this);
  X509Certificate certificate;
  try {
    Resource resource = webApplicationContext.getResource(tokenConfig.getCertificateLocation());
    CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
    certificate = (X509Certificate) certificateFactory.generateCertificate(resource.getInputStream());
  } catch (Exception ex) {
    throw new ServletException(ex);
  }
  
  Configuration configuration = Configuration.getInstance();
  configuration.setMaxTokenValidityInMinutes(tokenConfig.getMaxTokenValidityInMinutes());
  configuration.setCertificate(certificate);
}

代码示例来源:origin: com.trifork.emobility.shared/TokenParser

@Override
  public void init(FilterConfig config) throws ServletException {
    ServletContext servletContext = config.getServletContext();
    WebApplicationContext webApplicationContext = WebApplicationContextUtils.getWebApplicationContext(servletContext);
    AutowireCapableBeanFactory autowireCapableBeanFactory = webApplicationContext.getAutowireCapableBeanFactory();
    autowireCapableBeanFactory.autowireBean(this);

    X509Certificate certificate;
    try {
      Resource resource = webApplicationContext.getResource(tokenConfig.getCertificateLocation());
      CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
      certificate = (X509Certificate) certificateFactory.generateCertificate(resource.getInputStream());
    } catch (Exception ex) {
      throw new ServletException(ex);
    }
    
    Configuration configuration = Configuration.getInstance();
    configuration.setMaxTokenValidityInMinutes(tokenConfig.getMaxTokenValidityInMinutes());
    configuration.setCertificate(certificate);
  }
}

代码示例来源:origin: org.eagle-i/eagle-i-search-gwt

inputStream = ctx.getResource( "/buildversion.properties" ).getInputStream();
    logger.debug( "/buildversion.properties not found" );
  inputStream = ctx.getResource( "/institution/buildversion.properties" ).getInputStream();
  if ( inputStream == null ) {
    if ( DEBUG ) {
      logger.debug( "/institution/buildversion.properties not found" );
    inputStream = ctx.getResource( "/central/buildversion.properties" ).getInputStream();
    if ( inputStream == null && DEBUG ) {
      logger.debug( "/central/buildversion.properties not found" );

代码示例来源:origin: epam/NGB

@Before
public void setup() throws Exception {
  super.setup();
  Chromosome testChromosome = EntityHelper.createNewChromosome();
  testChromosome.setSize(TEST_CHROMOSOME_SIZE);
  testReference = EntityHelper.createNewReference(testChromosome,
      referenceGenomeManager.createReferenceId());
  referenceGenomeManager.register(testReference);
  referenceId = testReference.getId();
  Resource resource = wac.getResource(CLASSPATH_TEMPLATES_GENES_SORTED);
  FeatureIndexedFileRegistrationRequest request = new FeatureIndexedFileRegistrationRequest();
  request.setReferenceId(referenceId);
  request.setPath(resource.getFile().getAbsolutePath());
  geneFile = gffManager.registerGeneFile(request);
  Assert.assertNotNull(geneFile);
  Assert.assertNotNull(geneFile.getId());
  referenceGenomeManager.updateReferenceGeneFileId(testReference.getId(), geneFile.getId());
  resource = wac.getResource(CLASSPATH_TEMPLATES_FELIS_CATUS_VCF);
  request = new FeatureIndexedFileRegistrationRequest();
  request.setReferenceId(referenceId);
  request.setPath(resource.getFile().getAbsolutePath());
  vcfFile = vcfManager.registerVcfFile(request);
}

相关文章