Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jasig.portal.utils
Class AddressTester

    java.lang.Object
      org.jasig.portal.utils.AddressTester

    public class AddressTester

extends java.lang.Object

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.

Since:
  uPortal 2.2
Version:
  $Revision: 1.8 $
Author:
  Kazem Naderi

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

### log

    private static final org.apache.commons.logging.Log log

### timer

    private static final java.util.Timer timer

  The timer object that takes a timerTask as a parameter when constructed

### connectionThread

    java.lang.Thread connectionThread

  The connection thread inwhich the connection attempt is made

### urlConnect

    private java.net.HttpURLConnection urlConnect

### connectionCode

    private int connectionCode

  The connectioncode returned from connetion attempt

### urlToTry

    private java.lang.String urlToTry

  This the url to try. the value is set through the class constructor

### timeToWait

    int timeToWait

  The amount of time connection attempt can take, the default is 100 ms

### defaultTimeToWait

    static final int defaultTimeToWait

See Also:
  Constant Field Values

### headOnly

    private boolean headOnly

  Get header data only

### DEBUG

    private static boolean DEBUG

  Debug the code

Constructor Detail

### AddressTester

    public AddressTester(java.lang.String urlString,
                         int milliSeconds,
                         boolean getHead)
                  throws java.lang.Exception

  Constructor

  Parameters:
    `milliSeconds` - the number of milliseconds to let the connectioon attempt run
    `urlString` - the String representing a URL
    `getHead` - use setRequestMathod("HEAD")
  Throws:
    `java.lang.Exception`

### AddressTester

    public AddressTester(java.lang.String urlString,
                         boolean getHead)
                  throws java.lang.Exception

  Constructor

  Parameters:
    `urlString` -
    `getHead` -
  Throws:
    `java.lang.Exception`

### AddressTester

    public AddressTester(int milliSeconds,
                         java.lang.String urlString)
                  throws java.lang.Exception

  Constructor

  Parameters:
    `milliSeconds` - - the number of milliseconds to let the connectioon attempt run
    `urlString` - - the String representing a URL
  Throws:
    `java.lang.Exception`

### AddressTester

    public AddressTester(java.lang.String urlString)
                  throws java.lang.Exception

  Constructor

  Parameters:
    `urlString` - the String representing a URL
  Throws:
    `java.lang.Exception`

Method Detail

### getResponseCode

    public int getResponseCode()

  This method returns the response code that was set in checkURL ()

  Returns:
    the response code

### getConnection

    public java.net.URLConnection getConnection()

  Get the (valid) URL connection

  Returns:
    URL connection

### disconnect

    public void disconnect()

  Shut down the connection

### URLAvailable

    public boolean URLAvailable()

  Returns:
    `false` if the address is not available. `True` otherwise

### main

    public static void main(java.lang.String[] args)

  This is the main method and is left as a usage sample

  Parameters:
    `args` -

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD