Class Proxy
- All Implemented Interfaces:
Cloneable
This Ant data type allows specification of a proxy host, port, type (e.g., HTTP), non-proxy hosts, and optional authentication credentials. Once declared, it is automatically registered with the project's repository system.
A proxy definition can also be referenced by refid, allowing reuse and modular build files.
When defined as a reference, no other attributes or nested elements may be set.
- See Also:
-
Field Summary
Fields inherited from class org.apache.tools.ant.types.DataType
checked, refFields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAuthentication(Authentication authentication) Allow Ant to add an<authentication>child element to configure credentials for the proxy.Returns theAuthenticationsettings associated with this proxy.getHost()Returns the proxy host name or IP address.Returns the non-proxy hosts setting, typically a pipe-delimited list.intgetPort()Returns the proxy port number.protected ProxygetRef()Resolves this object if defined as a reference and verifies that it is aProxyinstance.getType()Returns the proxy type, such ashttp.voidsetAuthRef(org.apache.tools.ant.types.Reference ref) Sets a reference to an existingAuthenticationelement to be used for this proxy.voidSets the proxy host name or IP address.voidsetNonProxyHosts(String nonProxyHosts) Sets the non-proxy hosts — hosts that should bypass the proxy.voidsetPort(int port) Sets the proxy port number.voidsetProject(org.apache.tools.ant.Project project) Sets the associated AntProjectand registers this proxy instance with the repository system.voidsetRefid(org.apache.tools.ant.types.Reference ref) Sets this proxy as a reference to another defined proxy.voidSets the proxy type (e.g.,http).Methods inherited from class org.apache.tools.ant.types.DataType
checkAttributesAllowed, checkChildrenAllowed, circularReference, clone, dieOnCircularReference, dieOnCircularReference, dieOnCircularReference, getCheckedRef, getCheckedRef, getCheckedRef, getCheckedRef, getCheckedRef, getDataTypeName, getRefid, invokeCircularReferenceCheck, isChecked, isReference, noChildrenAllowed, pushAndInvokeCircularReferenceCheck, setChecked, tooManyAttributes, toStringMethods inherited from class org.apache.tools.ant.ProjectComponent
getDescription, getLocation, getProject, log, log, setDescription, setLocation
-
Constructor Details
-
Proxy
public Proxy()Default constructor initializes the proxy with no settings. This allows attributes to be set before the project is assigned.
-
-
Method Details
-
setProject
public void setProject(org.apache.tools.ant.Project project) Sets the associated AntProjectand registers this proxy instance with the repository system.- Overrides:
setProjectin classorg.apache.tools.ant.ProjectComponent- Parameters:
project- the Ant project
-
getRef
Resolves this object if defined as a reference and verifies that it is aProxyinstance.- Returns:
- the referenced
Proxyinstance - Throws:
org.apache.tools.ant.BuildException- if the reference is invalid
-
setRefid
public void setRefid(org.apache.tools.ant.types.Reference ref) Sets this proxy as a reference to another defined proxy.This method must not be used in combination with any other attributes or nested
<authentication>elements.- Overrides:
setRefidin classorg.apache.tools.ant.types.DataType- Parameters:
ref- the reference to anotherProxydefinition- Throws:
org.apache.tools.ant.BuildException- if attributes or children are already set
-
getHost
Returns the proxy host name or IP address.- Returns:
- the proxy host
-
setHost
Sets the proxy host name or IP address.- Parameters:
host- the proxy host to use- Throws:
org.apache.tools.ant.BuildException- if this object is a reference
-
getPort
public int getPort()Returns the proxy port number.- Returns:
- the port number
-
setPort
public void setPort(int port) Sets the proxy port number. Must be within the range 1 to 65535.- Parameters:
port- the port number- Throws:
org.apache.tools.ant.BuildException- if the port is out of range or attributes are not allowed
-
getType
Returns the proxy type, such ashttp.- Returns:
- the proxy type, or
nullif not set
-
setType
Sets the proxy type (e.g.,http).- Parameters:
type- the proxy protocol type- Throws:
org.apache.tools.ant.BuildException- if this object is a reference
-
getNonProxyHosts
Returns the non-proxy hosts setting, typically a pipe-delimited list.- Returns:
- the non-proxy hosts
-
setNonProxyHosts
Sets the non-proxy hosts — hosts that should bypass the proxy. The format is usually a pipe-separated list (e.g.,localhost|*.example.com).- Parameters:
nonProxyHosts- the non-proxy hosts pattern- Throws:
org.apache.tools.ant.BuildException- if this object is a reference
-
getAuthentication
Returns theAuthenticationsettings associated with this proxy.- Returns:
- the authentication configuration, or
nullif none
-
addAuthentication
Allow Ant to add an<authentication>child element to configure credentials for the proxy.- Parameters:
authentication- the authentication element- Throws:
org.apache.tools.ant.BuildException- if multiple authentications are specified or children are not allowed
-
setAuthRef
public void setAuthRef(org.apache.tools.ant.types.Reference ref) Sets a reference to an existingAuthenticationelement to be used for this proxy.This allows the proxy to reuse a separately defined
<authentication>element via Ant'srefidmechanism, enabling modular and reusable configuration. If no authentication has been previously configured, a newAuthenticationinstance is created and associated with the project.- Parameters:
ref- the Ant reference pointing to an existingAuthenticationinstance- See Also:
-