net.rim.device.api.io.transport
Interface ConnectionAttemptListener


public interface ConnectionAttemptListener

This interface prescribes methods for a class that listens for connection attempts performed by a ConnectionFactory object.

You can implement this interface if you want to create a class that is notified about the status of connection attempts made by a ConnectionFactory object. The methods of the interface are called as the connection attempt proceeds. Your class might use that information to create a connection attempt log for example.

Note that the listener is only notified when a connection is actually attempted. If the specified transport type is not available, the factory will not attempt to make a connection and the listener will not be notified. The TransportInfo.isTransportTypeAvailable(int) method enables you to check if a certain transport type is available.

A class that implements this interface should not block and should return as quickly as possible.

See Also:
ConnectionFactory.setConnectionAttemptListener(ConnectionAttemptListener connectionAttemptListener)
Since:
BlackBerry API 5.0.0

Method Summary
 void attemptAborted(String url, Exception exception)
          The ConnectionFactory will call this method if no connection can be attempted (for example, no transport is available, invalid arguments, etc.)
 void attemptFailed(TransportDescriptor transport, int attemptNumber, String url, Exception exception)
          The ConnectionFactory will call this method if the call to Connector.open() failed.
 void attemptSucceeded(int attemptNumber, ConnectionDescriptor connection)
          The ConnectionFactory will call this method if the call to Connector.open() was successful.
 boolean attempting(TransportDescriptor transport, int attemptNumber, String url)
          The ConnectionFactory will call this method just before attempting the connection.
 



Method Detail

attempting

boolean attempting(TransportDescriptor transport,
                   int attemptNumber,
                   String url)
The ConnectionFactory will call this method just before attempting the connection.

Parameters:
transport - a TransportDescriptor that describes the exact transport instance being attempted
attemptNumber - a number identifying the attempt in the case of multiple retries
url - a String with the full URL passed to Connector.open()
Returns:
true if the attempt should proceed.
false if the attempt should be canceled. Note that returning false will cause the factory to return null immediately.
Since:
BlackBerry API 5.0.0

attemptSucceeded

void attemptSucceeded(int attemptNumber,
                      ConnectionDescriptor connection)
The ConnectionFactory will call this method if the call to Connector.open() was successful.

Parameters:
attemptNumber - a number identifying the attempt in the case of multiple retries
connection - a ConnectionDescriptor of the opened connection
Since:
BlackBerry API 5.0.0

attemptFailed

void attemptFailed(TransportDescriptor transport,
                   int attemptNumber,
                   String url,
                   Exception exception)
The ConnectionFactory will call this method if the call to Connector.open() failed.

Parameters:
transport - a TransportDescriptor that describes the exact transport attempted
attemptNumber - a number identifying the attempt in the case of multiple retries
url - a String with the full URL passed to Connector.open()
exception - an Exception if available (i.e. exception may be null)
Since:
BlackBerry API 5.0.0

attemptAborted

void attemptAborted(String url,
                    Exception exception)
The ConnectionFactory will call this method if no connection can be attempted (for example, no transport is available, invalid arguments, etc.)

Parameters:
url - a String with the URL passed to the factory
exception - an Exception if available (i.e. exception may be null)
Since:
BlackBerry API 5.0.0





Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal