|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jasig.portal.utils.AddressTester
public class AddressTester
This class checks a URL or a webserver hosting a URL. It only allows a specific time allocated for
connecting to the URL rather than waiting for a timeout.
This class uses the java.util.Timer
to schedule a task which is cancelling the attempt of calling
httpURLConnection.
Nested Class Summary | |
---|---|
(package private) class |
AddressTester.RemindTask
Class RemidTask |
Field Summary | |
---|---|
private int |
connectionCode
The connectioncode returned from connetion attempt |
(package private) java.lang.Thread |
connectionThread
The connection thread inwhich the connection attempt is made |
private static boolean |
DEBUG
Debug the code |
(package private) static int |
defaultTimeToWait
|
private boolean |
headOnly
Get header data only |
private static org.apache.commons.logging.Log |
log
|
private static java.util.Timer |
timer
The timer object that takes a timerTask as a parameter when constructed |
(package private) int |
timeToWait
The amount of time connection attempt can take, the default is 100 ms |
private java.net.HttpURLConnection |
urlConnect
|
private java.lang.String |
urlToTry
This the url to try. |
Constructor Summary | |
---|---|
AddressTester(int milliSeconds,
java.lang.String urlString)
Constructor |
|
AddressTester(java.lang.String urlString)
Constructor |
|
AddressTester(java.lang.String urlString,
boolean getHead)
Constructor |
|
AddressTester(java.lang.String urlString,
int milliSeconds,
boolean getHead)
Constructor |
Method Summary | |
---|---|
void |
disconnect()
Shut down the connection |
java.net.URLConnection |
getConnection()
Get the (valid) URL connection |
int |
getResponseCode()
This method returns the response code that was set in checkURL () |
static void |
main(java.lang.String[] args)
This is the main method and is left as a usage sample |
boolean |
URLAvailable()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final org.apache.commons.logging.Log log
private static final java.util.Timer timer
java.lang.Thread connectionThread
private java.net.HttpURLConnection urlConnect
private int connectionCode
private java.lang.String urlToTry
int timeToWait
static final int defaultTimeToWait
private boolean headOnly
private static boolean DEBUG
Constructor Detail |
---|
public AddressTester(java.lang.String urlString, int milliSeconds, boolean getHead) throws java.lang.Exception
milliSeconds
- the number of milliseconds to let the connectioon attempt runurlString
- the String representing a URLgetHead
- use setRequestMathod("HEAD")
java.lang.Exception
public AddressTester(java.lang.String urlString, boolean getHead) throws java.lang.Exception
urlString
- getHead
-
java.lang.Exception
public AddressTester(int milliSeconds, java.lang.String urlString) throws java.lang.Exception
milliSeconds
- - the number of milliseconds to let the connectioon attempt runurlString
- - the String representing a URL
java.lang.Exception
public AddressTester(java.lang.String urlString) throws java.lang.Exception
urlString
- the String representing a URL
java.lang.Exception
Method Detail |
---|
public int getResponseCode()
public java.net.URLConnection getConnection()
public void disconnect()
public boolean URLAvailable()
false
if the address is not available. True
otherwisepublic static void main(java.lang.String[] args)
args
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |