com.gridsystems.innergrid.api
Interface Connection

All Known Implementing Classes:
AbstractConnection, DirectConnection, WrapperConnection

public interface Connection

Classes implementing this interface hold all the necessary data to establish an authenticated connection to a Server.

Version:
1.0
Author:
Rodrigo Ruiz

Field Summary
static int DEFAULT_TIMEOUT
          Default connection timeout.
static java.lang.String DIME
          DIME attachment format.
static java.lang.String MIME
          MIME attachment format.
static java.lang.String MTOM
          MTOM attachment format.
 
Method Summary
 void checkConnection()
          Checks that the connection is directed to an open port with the proper protocol.
 void close()
          Disposes the object and releases kept resources.
 java.lang.String getAttachmentFormat()
          Gets the attachment format (DIME, MIME or MTOM).
 java.lang.String getContextPath()
          Gets the connection context path.
 Credentials getCredentials()
          Gets the credentials for the connection.
 java.lang.String getHost()
          Gets the Host to connect to.
 int getPort()
          Gets Port to connect.
 int getTimeout()
          Gets the connection timeout.
 java.net.URL getUrl(java.lang.String apiName)
          Gets a target URL to the SOAP service for the specified API (Internal use only).
 boolean isChunkedTransferEnabled()
          Gets the value of the chunked transfer control flag.
 boolean isKeepAliveEnabled()
          Gets the keep-alive control flag value.
 boolean isSecured()
          Use a secured connection.
 void manageException(KernelException ke, int retry)
          Manages exceptions (Internal use only).
 void setAttachmentFormat(java.lang.String format)
          Sets the attachment format (DIME, MIME or MTOM).
 void setChunkedTransferEnabled(boolean enabled)
          Enables or disables chunked transfer encoding (it is enabled by default).
 void setKeepAliveEnabled(boolean enabled)
          Sets the keep-alive control flag value.
 void setTimeout(int timeout)
          Sets the connection timeout.
 void success()
          Notifies to the Connection instance that the target API has been reached.
 

Field Detail

DIME

static final java.lang.String DIME
DIME attachment format.

See Also:
Constant Field Values

MIME

static final java.lang.String MIME
MIME attachment format.

See Also:
Constant Field Values

MTOM

static final java.lang.String MTOM
MTOM attachment format.

See Also:
Constant Field Values

DEFAULT_TIMEOUT

static final int DEFAULT_TIMEOUT
Default connection timeout.

See Also:
Constant Field Values
Method Detail

getHost

java.lang.String getHost()
Gets the Host to connect to.

Returns:
the Host to connect to.

getPort

int getPort()
Gets Port to connect.

Returns:
Port to connect.

isSecured

boolean isSecured()
Use a secured connection.

Returns:
true if this connection uses SSL; false otherwise.

getContextPath

java.lang.String getContextPath()
Gets the connection context path.

By default, Kernel services are located in /kernel/api.

Returns:
The connection base context path

isChunkedTransferEnabled

boolean isChunkedTransferEnabled()
Gets the value of the chunked transfer control flag.

This flag is set to true by default.

Returns:
The current transfer control flag value

setChunkedTransferEnabled

void setChunkedTransferEnabled(boolean enabled)
Enables or disables chunked transfer encoding (it is enabled by default).

This flag must be set to false when connecting to servers that do not support this transfer encoding. In particular, simple servers used by MUSE for event notification require this flag to be disabled.

Embedded servers used during unit tests will usually require this encoding to be disabled too.

Parameters:
enabled - The new flag value

isKeepAliveEnabled

boolean isKeepAliveEnabled()
Gets the keep-alive control flag value.

Returns:
The current flag value

setKeepAliveEnabled

void setKeepAliveEnabled(boolean enabled)
Sets the keep-alive control flag value.

Keep-alive is disabled by default for scalability reasons. However, if several calls must be performed in a short time period, enabling it can drastically improve the performance.

Parameters:
enabled - The new flag value

getTimeout

int getTimeout()
Gets the connection timeout.

Returns:
The connection timeout in milliseconds

setTimeout

void setTimeout(int timeout)
Sets the connection timeout. By default, it is 30 seconds.

Parameters:
timeout - The connection timeout in milliseconds

getAttachmentFormat

java.lang.String getAttachmentFormat()
Gets the attachment format (DIME, MIME or MTOM).

Returns:
The attachment format to use

setAttachmentFormat

void setAttachmentFormat(java.lang.String format)
Sets the attachment format (DIME, MIME or MTOM). By default, the format is automatically selected through the Service deployment meta-data. By setting this value, the user can override these default values.

Parameters:
format - The attachment format to use

getUrl

java.net.URL getUrl(java.lang.String apiName)
                    throws KernelException
Gets a target URL to the SOAP service for the specified API (Internal use only).

Parameters:
apiName - the name of the API
Returns:
the target URL to apiName
Throws:
KernelException - CLT008 if the resulting URL is invalid

getCredentials

Credentials getCredentials()
Gets the credentials for the connection.

Returns:
the needed Credentials. They can be null.

manageException

void manageException(KernelException ke,
                     int retry)
                     throws KernelException
Manages exceptions (Internal use only).

Parameters:
ke - KernelException captured
retry - number of retries
Throws:
KernelException - the ke exception if it passes along the exception without managing

success

void success()
Notifies to the Connection instance that the target API has been reached.


checkConnection

void checkConnection()
                     throws KernelException
Checks that the connection is directed to an open port with the proper protocol.

Throws:
KernelException - CLT060 if the port cannot be reached.
KernelException - CLT061 if the port can be reached but the protocol is not valid.
KernelException - CLT062 if a valid URL to the port to check cannot be created.

close

void close()
Disposes the object and releases kept resources.



Copyright © 2007-2008 Grid Systems, S.A.. All Rights Reserved.