FileDocCategorySizeDatePackage
Service.javaAPI DocApache Ant 1.703913Wed Dec 13 06:16:18 GMT 2006org.apache.tools.ant.types.spi

Service

public class Service extends org.apache.tools.ant.ProjectComponent
ANT Jar-Task SPI extension
see
http://issues.apache.org/bugzilla/show_bug.cgi?id=31520

Fields Summary
private List
providerList
private String
type
Constructors Summary
Methods Summary
public voidaddConfiguredProvider(Provider provider)
Add a nested provider element.

param
provider a provider element.

        provider.check();
        providerList.add(provider);
    
public voidcheck()
Check if this object is configured correctly as a nested element.

        if (type == null) {
            throw new BuildException(
                "type attribute must be set for service element",
                getLocation());
        }
        if (type.length() == 0) {
            throw new BuildException(
                "Invalid empty type classname", getLocation());
        }
        if (providerList.size() == 0) {
            throw new BuildException(
                "provider attribute or nested provider element must be set!",
                getLocation());
        }
    
public java.io.InputStreamgetAsStream()
Return the implementations of this services as an inputstream.

return
an inputstream of the classname names encoded as UTF-8.
throws
IOException if there is an error.

        ByteArrayOutputStream arrayOut;
        Writer writer;
        Iterator providerIterator;
        Provider provider;

        arrayOut = new ByteArrayOutputStream();
        writer = new OutputStreamWriter(arrayOut, "UTF-8");
        providerIterator = providerList.iterator();
        while (providerIterator.hasNext()) {
            provider = (Provider) providerIterator.next();
            writer.write(provider.getClassName());
            writer.write("\n");
        }
        writer.close();
        return new ByteArrayInputStream(arrayOut.toByteArray());
    
public java.lang.StringgetType()

return
the service type.

        return type;
    
public voidsetProvider(java.lang.String className)
Set the provider classname.

param
className the classname of a provider of this service.


                       
        
        Provider provider = new Provider();
        provider.setClassName(className);
        providerList.add(provider);
    
public voidsetType(java.lang.String type)
Set the service type.

param
type the service type, a classname of an interface or a class (normally abstract).

        this.type = type;