Package com.kheops.jmap.net
Class JMapNetworkConnection
java.lang.Object
com.kheops.jmap.net.JMapConnection
com.kheops.jmap.net.JMapBaseNetworkConnection
com.kheops.jmap.net.JMapNetworkConnection
- All Implemented Interfaces:
KSchedulerClient
This class represents a network connection between a client application and
JMapServer.
- See Also:
-
Field Summary
Fields inherited from class com.kheops.jmap.net.JMapBaseNetworkConnection
autoReconnect, autoSendPendingRequests, CONN_DIRECT_ALWAYS, CONN_PROXY_ALWAYS, CONN_PROXY_IFNEEDED, CONNECTION_DIRECT, CONNECTION_PROXY, connectionListeners, connectionMode, DEFAULT_DIRECT_CONNECTION_TIMEOUT, DEFAULT_PROXY_CONNECTION_TIMEOUT, DEFAULT_READ_TIMEOUT, directConnectionTimeout, host, httpPort, JMAP_PROXY_SERVLET_PATH, port, protocol, proxyConnectionTimeout, proxyPath, READ_TIMEOUT, serverId, useProxy, verbose, workingOffline -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreates a raw network connection that won't be initialized until initConnection() is called. -
Method Summary
Modifier and TypeMethodDescriptionbooleancancelRequest(JMapRequest pushedRequest) Method that cancels a previously pushed request.voidclose()Closes the connection.voiddestroy()byte[]executeRequest(byte[] requestBytes) Blocking method that sends a pre-serialized request (byte array) to JMapServer and returns the serialized response object (byte array) obtained from JMapServer.executeRequest(JMapRequest request) Blocking method that sends a request to JMapServer and returns the response object obtained from JMapServer.
Notes about the offline mode :
- If working offline and the auto reconnect option istrue, it will try to reconnect before sending the request;
- If working offline, the OfflineRequestHandler will process the request;
- If offline mode is not allowed and the connection is lost, anullresponse will be returned;intbooleanThis function will force the offline mode.booleangoOnline()This function will force the online mode.protected voidbooleanvoidOpens a raw network connection with JMapServer using the specified host and port information.voidvoidOpens a HTTP network connection with JMapServer using the specified host, port, proxy path and serverId.voidopen(String protocol, String host, int port, int httpPort, String proxyPath, String serverId, int connectionMode) voidpushRequest(JMapRequest request) Non-blocking method that pushes a request in the queue.static byte[]static voidrawSend(byte[] bytes, DataOutputStream os) voidsetReadTimeout(int readTimeout) Methods inherited from class com.kheops.jmap.net.JMapBaseNetworkConnection
addConnectionListener, finalize, fireConnectionActivity, fireConnectionEvent, fireDisconnectionEvent, getVerbose, isAutoReconnect, isAutoSendPendingRequests, isOpen, isWorkingOffline, removeConnectionListener, schCallback, setAutoReconnect, setAutoSendPendingRequests, setVerboseMethods inherited from class com.kheops.jmap.net.JMapConnection
pingServer
-
Constructor Details
-
JMapNetworkConnection
protected JMapNetworkConnection()Creates a raw network connection that won't be initialized until initConnection() is called.
-
-
Method Details
-
open
Opens a raw network connection with JMapServer using the specified host and port information.- Specified by:
openin classJMapBaseNetworkConnection- Parameters:
host- IP address or name of JMapServer hostport- network port to use- Throws:
IOException
-
open
Opens a HTTP network connection with JMapServer using the specified host, port, proxy path and serverId. This will create a URL of the form http://host:port/proxyPath?serverId=serverId that will be used for communication between the client application and JMapServer.- Specified by:
openin classJMapBaseNetworkConnection- Parameters:
host- IP address or name of JMapServer hostport- network port to useproxyPath- the path of the proxy servletserverId- the server to connect to behind the proxy- Throws:
IOException
-
open
public void open(String host, int port, int httpPort, String proxyPath, String serverId, int connectionMode) throws IOException - Specified by:
openin classJMapBaseNetworkConnection- Throws:
IOException
-
open
public void open(String protocol, String host, int port, int httpPort, String proxyPath, String serverId, int connectionMode) throws IOException - Specified by:
openin classJMapBaseNetworkConnection- Throws:
IOException
-
isConnected
public boolean isConnected()- Specified by:
isConnectedin classJMapConnection
-
initConnection
- Throws:
IOException
-
goOffline
public boolean goOffline()This function will force the offline mode.- Specified by:
goOfflinein classJMapBaseNetworkConnection- Returns:
trueif successful,falseif the connection is already in offline mode
-
goOnline
public boolean goOnline()This function will force the online mode.- Specified by:
goOnlinein classJMapBaseNetworkConnection- Returns:
trueif successful
-
pushRequest
Non-blocking method that pushes a request in the queue. Requests placed in the queue are sent to JMapServer one after the other. When the response is obtained from JMapServer, the client specified in the request object is notified through itscallbackmethod.- Specified by:
pushRequestin classJMapConnection- Parameters:
request- the request to send to JMapServer- See Also:
-
executeRequest
Blocking method that sends a request to JMapServer and returns the response object obtained from JMapServer.
Notes about the offline mode :
- If working offline and the auto reconnect option istrue, it will try to reconnect before sending the request;
- If working offline, the OfflineRequestHandler will process the request;
- If offline mode is not allowed and the connection is lost, anullresponse will be returned;- Specified by:
executeRequestin classJMapConnection- Parameters:
request- the request to send to JMapServer- Returns:
- response from JMapServer (working online) or OfflineRequestHandler (worling offline).
nullwill be return if disconnected and offline mode is not allowed - Throws:
IOException
-
cancelRequest
Method that cancels a previously pushed request. The request will be cancelled ONLY if it is NOT currently in execution.- Parameters:
pushedRequest-- Returns:
- true if the cancel was successful
-
executeRequest
Blocking method that sends a pre-serialized request (byte array) to JMapServer and returns the serialized response object (byte array) obtained from JMapServer.- Specified by:
executeRequestin classJMapConnection- Parameters:
requestBytes- the request bytes to send to JMapServer- Returns:
- the response from JMapServer
- Throws:
IOException
-
rawSend
- Throws:
IOException
-
rawReceive
- Throws:
IOException
-
close
public void close()Closes the connection.- Specified by:
closein classJMapConnection
-
destroy
public void destroy()- Overrides:
destroyin classJMapBaseNetworkConnection
-
getReadTimeout
public int getReadTimeout() -
setReadTimeout
public void setReadTimeout(int readTimeout)
-