List of usage examples for org.springframework.core.io DescriptiveResource DescriptiveResource
public DescriptiveResource(@Nullable String description)
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); }// w ww .ja v a2 s . com } return new DescriptiveResource(location + " was not found in resource paths"); }
From source file:ch.rasc.edsutil.optimizer.WebResourceProcessor.java
private List<WebResource> createWebResources(VariableConfig variableConfig) { List<WebResource> webResources = new ArrayList<>(); String varName = variableConfig.variable; for (WebResourceConfig config : variableConfig.resources) { String path = replaceVariables(config.path); if (!this.production && config.isDevScriptOrLink()) { DescriptiveResource resource = new DescriptiveResource(path); webResources.add(new WebResource(varName, path, resource, false)); } else if (this.production && config.isProd()) { if (config.isProdScriptOrLink()) { DescriptiveResource resource = new DescriptiveResource(path); webResources.add(new WebResource(varName, path, resource, false)); } else { try { boolean jsProcessing = varName.endsWith(JS_EXTENSION); List<Resource> enumeratedResources; String suffix = jsProcessing ? ".js" : ".css"; if (StringUtils.hasText(config.classpath)) { enumeratedResources = enumerateResourcesFromClasspath(config.classpath, path, suffix); } else { enumeratedResources = enumerateResourcesFromWebapp(path, suffix); }//from ww w.ja v a2 s . co m if (jsProcessing && enumeratedResources.size() > 1) { enumeratedResources = reorder(enumeratedResources); } for (Resource resource : enumeratedResources) { String resourcePath = resource.getURL().toString(); int pathIx = resourcePath.indexOf(path); if (pathIx != -1) { resourcePath = resourcePath.substring(pathIx); } webResources.add(new WebResource(varName, resourcePath, resource, true)); } } catch (IOException e) { throw new RuntimeException(e); } } } } return webResources; }
From source file:org.data.support.beans.factory.xml.XmlQueryDefinitionReader.java
/** * Load query definitions from the specified XML file. * @param inputSource the SAX InputSource to read from * @param resourceDescription a description of the resource * (can be <code>null</code> or empty) * @return the number of query definitions found * @throws QueryDefinitionStoreException in case of loading or parsing errors *//*from ww w . j a v a 2s. c o m*/ public int loadQueryDefinitions(InputSource inputSource, String resourceDescription) throws QueryDefinitionStoreException { return doLoadQueryDefinitions(inputSource, new DescriptiveResource(resourceDescription)); }
From source file:org.springframework.beans.factory.groovy.GroovyBeanDefinitionReader.java
/** * Define a Spring XML namespace definition to use. * @param definition the namespace definition *//*from w ww . j a v a 2 s. c o m*/ public void xmlns(Map<String, String> definition) { if (!definition.isEmpty()) { for (Map.Entry<String, String> entry : definition.entrySet()) { String namespace = entry.getKey(); String uri = entry.getValue(); if (uri == null) { throw new IllegalArgumentException("Namespace definition must supply a non-null URI"); } NamespaceHandler namespaceHandler = this.groovyDslXmlBeanDefinitionReader .getNamespaceHandlerResolver().resolve(uri); if (namespaceHandler == null) { throw new BeanDefinitionParsingException( new Problem("No namespace handler found for URI: " + uri, new Location(new DescriptiveResource(("Groovy"))))); } this.namespaces.put(namespace, uri); } } }
From source file:org.springframework.beans.factory.groovy.GroovyBeanDefinitionReader.java
private GroovyDynamicElementReader createDynamicElementReader(String namespace) { XmlReaderContext readerContext = this.groovyDslXmlBeanDefinitionReader .createReaderContext(new DescriptiveResource("Groovy")); BeanDefinitionParserDelegate delegate = new BeanDefinitionParserDelegate(readerContext); boolean decorating = (this.currentBeanDefinition != null); if (!decorating) { this.currentBeanDefinition = new GroovyBeanDefinitionWrapper(namespace); }//from www.jav a2s . c o m return new GroovyDynamicElementReader(namespace, this.namespaces, delegate, this.currentBeanDefinition, decorating) { @Override protected void afterInvocation() { if (!this.decorating) { currentBeanDefinition = null; } } }; }
From source file:org.springframework.beans.factory.parsing.FailFastProblemReporterTests.java
@Test(expected = BeanDefinitionParsingException.class) public void testError() throws Exception { FailFastProblemReporter reporter = new FailFastProblemReporter(); reporter.error(new Problem("VGER", new Location(new DescriptiveResource("here")), null, new IllegalArgumentException())); }
From source file:org.springframework.beans.factory.parsing.FailFastProblemReporterTests.java
@Test public void testWarn() throws Exception { Problem problem = new Problem("VGER", new Location(new DescriptiveResource("here")), null, new IllegalArgumentException()); Log log = mock(Log.class); FailFastProblemReporter reporter = new FailFastProblemReporter(); reporter.setLogger(log);/*from w w w . java 2 s . co m*/ reporter.warning(problem); verify(log).warn(any(), isA(IllegalArgumentException.class)); }