Package groovy.util

Interface ResourceConnector

All Known Implementing Classes:
AbstractHttpServlet, GroovyScriptEngine, GroovyServlet, TemplateServlet

public interface ResourceConnector
Base interface for customizing where resources can be found for the GroovyScriptEngine.
  • Method Summary

    Modifier and Type
    Method
    Description
    Retrieve a URLConnection to a script referenced by name.
  • Method Details

    • getResourceConnection

      URLConnection getResourceConnection(String name) throws ResourceException
      Retrieve a URLConnection to a script referenced by name.

      Two shapes of name are passed. Most lookups use a resource name relative to whatever roots the connector searches, with package separators written as '/' on every platform, for example com/example/Foo.groovy. Staleness checks and dependency resolution during recompilation instead pass back a name the connector itself resolved earlier, in the external form of that resource's URL, for example file:/srv/scripts/com/example/Foo.groovy. An implementation that resolves names against a base should therefore cope with an already-absolute name; URI.resolve(String), which GroovyScriptEngine itself uses, has that behaviour.

      The caller may close the returned connection once it has what it needs, which for some call sites is only URLConnection.getURL().

      Parameters:
      name - the resource to resolve, as described above
      Returns:
      an open connection to the resource, never null
      Throws:
      ResourceException - if the resource cannot be found or opened