Top Description Inners Fields Constructors Methods
org.apache.tools.ant.types.resources

public abstract Class AbstractClasspathResource

extends Resource
Class Inheritance
Known Direct Subclasses
org.apache.tools.ant.types.resources.JavaConstantResource, org.apache.tools.ant.types.resources.JavaResource
Imports
java.io.FilterInputStream, .IOException, .InputStream, java.util.Stack, org.apache.tools.ant.AntClassLoader, .Project, org.apache.tools.ant.types.Path, .Reference, .Resource, org.apache.tools.ant.util.FileUtils

A Resource representation of anything that is accessed via a Java classloader. The core methods to set/resolve the classpath are provided.
Since
Ant 1.8.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
private Path
private Reference
private boolean
Inherited from org.apache.tools.ant.types.Resource:
MAGICUNKNOWN_DATETIMEUNKNOWN_SIZE

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Path

Returns:

The classpath to be configured
createClasspath
()

Add a classpath to use when looking up a resource.

protected synchronized void
dieOnCircularReference(Stack<Object>
the stack of references to check.
stk
,
Project
the project to use to dereference the references.
p
)

Overrides org.apache.tools.ant.types.DataType.dieOnCircularReference.

Check to see whether any DataType we hold references to is included in the Stack (which holds all DataType instances that directly or indirectly reference this instance, including this instance itself).
protected AbstractClasspathResource.ClassLoaderWithFlag

Returns:

ClassLoaderWithFlag
getClassLoader
()

combines the various ways that could specify a ClassLoader and potentially creates one that needs to be cleaned up when it is no longer needed so that classes can get garbage collected.

public Path

Returns:

The classpath
getClasspath
()

get the classpath used by this LoadProperties.

public InputStream

Returns:

an InputStream object.
getInputStream
()

Overrides org.apache.tools.ant.types.Resource.getInputStream.

Return an InputStream for reading the contents of this Resource.
public Reference

Returns:

the loader.
getLoader
()

Get the loader.

protected AbstractClasspathResource
getRef()

Overrides org.apache.tools.ant.types.Resource.getRef.

Perform the check for circular references and return the referenced Resource.
public boolean

Returns:

true if this resource exists.
isExists
()

Overrides org.apache.tools.ant.types.Resource.isExists.

Learn whether this resource exists.
protected abstract InputStream

Returns:

an open input stream for the resource
openInputStream
(ClassLoader
the classloader to use. Will be null if the system classloader is used
cl
)

open the input stream from a specific classloader

public void
setClasspath(Path
to add to any existing classpath
classpath
)

Set the classpath to use when looking up a resource.

public void
setClasspathRef(Reference
The reference value
r
)

Set the classpath to use when looking up a resource, given as reference to a <path> defined elsewhere

public void
setLoaderRef(Reference
the reference to locate the loader.
r
)

Use the reference to locate the loader.

public void
setParentFirst(boolean
boolean
b
)

Whether to consult the parent classloader first.

public void
setRefid(Reference
the Reference to set.
r
)

Overrides org.apache.tools.ant.types.Resource.setRefid.

Overrides the super version.
Inherited from org.apache.tools.ant.types.Resource:
asasOptionalclonecompareToequalsgetLastModifiedgetMagicNumbergetNamegetOutputStreamgetSizehashCodeisDirectoryisFilesystemOnlyiteratorsetDirectorysetExistssetLastModifiedsetNamesetSizesizetoLongStringtoString

Field Detail

classpathback to summary
private Path classpath
loaderback to summary
private Reference loader
parentFirstback to summary
private boolean parentFirst

Constructor Detail

AbstractClasspathResourceback to summary
public AbstractClasspathResource()

Method Detail

createClasspathback to summary
public Path createClasspath()

Add a classpath to use when looking up a resource.

Returns:Path

The classpath to be configured

dieOnCircularReferenceback to summary
protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p)

Overrides org.apache.tools.ant.types.DataType.dieOnCircularReference.

Doc from org.apache.tools.ant.types.DataType.dieOnCircularReference.

Check to see whether any DataType we hold references to is included in the Stack (which holds all DataType instances that directly or indirectly reference this instance, including this instance itself).

If one is included, throw a BuildException created by circularReference.

This implementation is appropriate only for a DataType that cannot hold other DataTypes as children.

The general contract of this method is that it shouldn't do anything if checked is true and set it to true on exit.

Parameters
stk:Stack<Object>

the stack of references to check.

p:Project

the project to use to dereference the references.

getClassLoaderback to summary
protected AbstractClasspathResource.ClassLoaderWithFlag getClassLoader()

combines the various ways that could specify a ClassLoader and potentially creates one that needs to be cleaned up when it is no longer needed so that classes can get garbage collected.

Returns:AbstractClasspathResource.ClassLoaderWithFlag

ClassLoaderWithFlag

getClasspathback to summary
public Path getClasspath()

get the classpath used by this LoadProperties.

Returns:Path

The classpath

getInputStreamback to summary
public InputStream getInputStream() throws IOException

Overrides org.apache.tools.ant.types.Resource.getInputStream.

Return an InputStream for reading the contents of this Resource.

Returns:InputStream

an InputStream object.

Exceptions
IOException:
if an error occurs.
getLoaderback to summary
public Reference getLoader()

Get the loader.

Returns:Reference

the loader.

getRefback to summary
protected AbstractClasspathResource getRef()

Overrides org.apache.tools.ant.types.Resource.getRef.

Doc from org.apache.tools.ant.types.Resource.getRef.

Perform the check for circular references and return the referenced Resource.

Returns:AbstractClasspathResource

Resource.

Annotations
@Override
isExistsback to summary
public boolean isExists()

Overrides org.apache.tools.ant.types.Resource.isExists.

Learn whether this resource exists. This implementation opens the input stream as the test.

Returns:boolean

true if this resource exists.

openInputStreamback to summary
protected abstract InputStream openInputStream(ClassLoader cl) throws IOException

open the input stream from a specific classloader

Parameters
cl:ClassLoader

the classloader to use. Will be null if the system classloader is used

Returns:InputStream

an open input stream for the resource

Exceptions
IOException:
if an error occurs.
setClasspathback to summary
public void setClasspath(Path classpath)

Set the classpath to use when looking up a resource.

Parameters
classpath:Path

to add to any existing classpath

setClasspathRefback to summary
public void setClasspathRef(Reference r)

Set the classpath to use when looking up a resource, given as reference to a <path> defined elsewhere

Parameters
r:Reference

The reference value

setLoaderRefback to summary
public void setLoaderRef(Reference r)

Use the reference to locate the loader. If the loader is not found, taskdef will use the specified classpath and register it with the specified name.

This allow multiple taskdef/typedef to use the same class loader, so they can be used together. It eliminate the need to put them in the CLASSPATH.

Parameters
r:Reference

the reference to locate the loader.

setParentFirstback to summary
public void setParentFirst(boolean b)

Whether to consult the parent classloader first.

Only relevant if a classpath has been specified.

Parameters
b:boolean

boolean

Since
Ant 1.8.0
setRefidback to summary
public void setRefid(Reference r)

Overrides org.apache.tools.ant.types.Resource.setRefid.

Overrides the super version.

Parameters
r:Reference

the Reference to set.

org.apache.tools.ant.types.resources back to summary

public Class AbstractClasspathResource.ClassLoaderWithFlag

extends Object
Class Inheritance
  • java.lang.Object
  • org.apache.tools.ant.types.resources.AbstractClasspathResource.ClassLoaderWithFlag

Field Summary

Modifier and TypeField and Description
private final boolean
private final ClassLoader

Constructor Summary

AccessConstructor and Description
pack-priv
ClassLoaderWithFlag(ClassLoader l, boolean needsCleanup)

Method Summary

Modifier and TypeMethod and Description
public void
public ClassLoader
public boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cleanupback to summary
private final boolean cleanup
loaderback to summary
private final ClassLoader loader

Constructor Detail

ClassLoaderWithFlagback to summary
pack-priv ClassLoaderWithFlag(ClassLoader l, boolean needsCleanup)

Method Detail

cleanupback to summary
public void cleanup()
getLoaderback to summary
public ClassLoader getLoader()
needsCleanupback to summary
public boolean needsCleanup()