use of org.grails.io.support.UrlResource in project grails-core by grails.
the class ArtefactHandlerAdapter method isArtefact.
/**
* Default implementation of {@link grails.core.ArtefactHandler#isArtefact(org.codehaus.groovy.ast.ClassNode)} which returns true if the ClassNode passes the
* {@link #isArtefactResource(org.grails.io.support.Resource)} method and the name of the ClassNode ends with the {@link #artefactSuffix}
*
* @param classNode The ClassNode instance
* @return True if the ClassNode is an artefact of this type
*/
@Override
public boolean isArtefact(ClassNode classNode) {
int modifiers = classNode.getModifiers();
URL url = GrailsASTUtils.getSourceUrl(classNode);
if (url == null)
return false;
try {
UrlResource resource = new UrlResource(url);
if (!isArtefactResource(resource))
return false;
} catch (IOException e) {
return false;
}
if (isValidArtefactClassNode(classNode, modifiers)) {
String name = classNode.getName();
if (name != null && this.artefactSuffix != null && name.endsWith(artefactSuffix)) {
return true;
}
}
return false;
}
use of org.grails.io.support.UrlResource in project grails-core by grails.
the class GrailsResourceUtilsTests method testGetClassNameResource.
public void testGetClassNameResource() throws Exception {
Resource r = new UrlResource(new URL(TEST_URL));
assertEquals("Test", GrailsResourceUtils.getClassName(r));
}
Aggregations