Package com.kheops.jmap.net
Class JMapSrvConnection
java.lang.Object
com.kheops.jmap.net.JMapConnection
com.kheops.jmap.net.JMapBaseNetworkConnection
com.kheops.jmap.net.JMapSrvConnection
- All Implemented Interfaces:
KSchedulerClient
A JMapSrvConnection object is responsible for handling all communications
between a JMap application (client) and JMapServer (server). It provides some
high level services for executing specific requests like user authentication
and geographic data requests. It also provides general services for executing
any other type of requests.
All communications between the client and the server follow a simple request-response pattern where the request contains informations about the requested resources and the response contains the execution status (success, failure, etc.), an optional status message and any data that may result from the execution of the request.
By default, all requests are placed in a queue (FIFO) and executed sequentially in the order they were placed in the queue. When a request is executed and a response is received by the server, the initiator of the request is notified by calling its callback method. It can then process the response and do any useful work with it.
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsFields 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidclose()Closes all opened resources used by the connection.voidCloses the session on JMapServer.voidDeletes all pending requests of the current logged user.voiddestroy()voidExecutes all pending requests of the current logged user.byte[]executeRequest(byte[] requestBytes) Non-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) Sends the specified request and waits for the response from JMapServer.<T extends JMapResponse>
TexecuteRequest(JMapRequest req, Class<T> resType) Execute JMapServer request and return a generic response.protected voidfinalize()Returns the current authenticated user info.Get the UID from the currently connected JMapServerReturns the message of the last request made to JMapServer.intReturns the status of the last request made to JMapServer.getLayerInfo(String projectName, String layerName) Gets the layer info for a specific layer that is part of a specific project.getLayersConfig(int projectId) final Object[]getLogos()intReturns the number of pending requests.Returns the password passed to the last openSession(String, String) method.Returns the current server id.longintReturns the session token for the current authenticated user.Returns the current session info.intReturns information about the users present in JMapServer.booleanForce the offline mode on all pool connections.booleangoOnline()Force the online mode on all pool connections.booleanMonitor the connection status.booleanbooleanvoidopen(ConnectionConfig config) Opens a new connection to JMapServer using the specified connection configuration.voidOpens an direct connection to JMapServer.voidOpens an HTTP connection to JMapServer through JMapProxy servlet.voidOpens an HTTP connection to JMapServer through JMapProxy servlet.voidopen(String protocol, String host, int port, int httpPort, String proxyPath, String serverId, int connectionMode) Opens a new connection to JMapServer.intopenSession(int sessionId) Opens a new desktop session on JMapServer using the information related to the specified valid session id.intopenSession(int sessionId, boolean closeSession, SessionType sessionType) Opens a new session on JMapServer using the information related to the specified valid session id.intopenSession(AuthenticationToken authenticationToken, SessionType sessionType) intopenSession(String username, String password) Opens a new desktop session on JMapServer for the specified user.intopenSession(String username, String password, SessionType sessionType) voidpushRequest(JMapRequest request) Non-blocking method that push the request execution on a separate thread.readFromByteArray(byte[] byteArray) voidvoidsetReadTimeout(int readTimeout) intuseExistingSession(int sessionId) Attach to an existing session using the specified session id.Methods inherited from class com.kheops.jmap.net.JMapBaseNetworkConnection
addConnectionListener, fireConnectionActivity, fireConnectionEvent, fireDisconnectionEvent, getVerbose, isAutoReconnect, isAutoSendPendingRequests, isOpen, isWorkingOffline, removeConnectionListener, schCallback, setAutoReconnect, setAutoSendPendingRequests, setVerboseMethods inherited from class com.kheops.jmap.net.JMapConnection
pingServer
-
Field Details
-
offlineRequestHandler
-
-
Constructor Details
-
JMapSrvConnection
public JMapSrvConnection() -
JMapSrvConnection
public JMapSrvConnection(int initialPoolSize, int maxPoolSize)
-
-
Method Details
-
open
Opens an direct connection to JMapServer.- Specified by:
openin classJMapBaseNetworkConnection- Parameters:
host- the name or IP address of the server to connect toport- the direct connection port- Throws:
Exception
-
open
Opens an HTTP connection to JMapServer through JMapProxy servlet.- Specified by:
openin classJMapBaseNetworkConnection- Parameters:
host- the name or IP address of the server to connect tohttpPort- the httpPort used by the proxyproxyPath- the proxy servlet path to use (e.g. /servlet/jmapproxy)serverId- the id of the server to connect to- Throws:
Exception
-
open
public void open(String host, int port, int httpPort, String proxyPath, String serverId, int connectionMode) throws Exception Opens an HTTP connection to JMapServer through JMapProxy servlet.- Specified by:
openin classJMapBaseNetworkConnection- Parameters:
host- the name or IP address of the server to connect toport- the direct port used for a direct connection to the serverhttpPort- the httpPort used by the proxyproxyPath- the proxy servlet path to use (e.g. /servlet/jmapproxy)serverId- the id of the server to connect toconnectionMode- the type of connection to open- Throws:
Exception
-
open
Opens a new connection to JMapServer using the specified connection configuration.- Parameters:
config- the connection configuration to use- Throws:
ExceptionIOException
-
open
public void open(String protocol, String host, int port, int httpPort, String proxyPath, String serverId, int connectionMode) throws IOException Opens a new connection to JMapServer. The connection mode (direct or through JMapProxy) is determined by the connectionMode value specified.- Specified by:
openin classJMapBaseNetworkConnection- Parameters:
protocol- the proxy connection protocol to use (http ou https)host- the name or IP address of the server to connect toport- the direct port used for a direct connection to the serverhttpPort- the httpPort used by the proxyproxyPath- the proxy servlet path to use if directPort is -1serverId- the id of the server to connect toconnectionMode- the type of connection to open- Throws:
ExceptionIOException
-
getProductManager
-
getProjectionManager
-
openSession
Opens a new desktop session on JMapServer for the specified user. The username must correspond to a valid user and the password must be match that user's password. The username is not case-sensitive but the password is case-sensitive.- Parameters:
username- the username used to open the sessionpassword- the password of the user- Returns:
- the id of the new session if successful or -1 otherwise
-
openSession
-
openSession
-
openSession
public int openSession(int sessionId) Opens a new desktop session on JMapServer using the information related to the specified valid session id.- Parameters:
sessionId- the owner's session id.- Returns:
- the id of the new session if successful or -1 otherwise
-
openSession
Opens a new session on JMapServer using the information related to the specified valid session id.- Parameters:
sessionId- the owner's session id.closeSession- specified whether to close the JMap session related the specified session id before opening the new session.sessionType- the session type to open.- Returns:
- the id of the new session if successful or -1 otherwise
-
useExistingSession
public int useExistingSession(int sessionId) Attach to an existing session using the specified session id. The corresponding session must be already open on JMapServer.- Parameters:
sessionId- the session id to attach to- Returns:
- the same session id if successful or -1 otherwise
-
closeSession
public void closeSession()Closes the session on JMapServer. The session should always be closed when the application exists to free resources on JMapServer. -
getCurrentUserInfo
Returns the current authenticated user info.- Returns:
- the current authenticated user info
-
getSessionId
public int getSessionId()Returns the session token for the current authenticated user.- Returns:
- the session token for the current authenticated user or -1 if user is anonymous
-
getServerId
Returns the current server id.- Returns:
- the current server id.
-
getUserInfo
Returns information about the users present in JMapServer. This information includes full name, e-mail address and description.- Returns:
- a vector containing UserInfo instances
-
getSessionInfo
Returns the current session info.- Returns:
- a session info
-
getLogos
- Returns:
- the map logo and the expiration logo that appears if JMap version is expired
-
getJMSUID
Get the UID from the currently connected JMapServer- Returns:
- the JMapServer Unique ID (Serial Number)
-
getServerTimeAdjustment
public long getServerTimeAdjustment() -
getServerVersion
-
getExternalAuthenticator
-
executeRequest
Sends the specified request and waits for the response from JMapServer. This method is blocking. If another request is already executing when this method is called, the specified request will be executed as soon as the other request terminates.- Specified by:
executeRequestin classJMapConnection- Parameters:
request- the request to execute- Returns:
- the response from JMapServer
- See Also:
-
executeRequest
Execute JMapServer request and return a generic response.- Returns:
- JMapResponse generic instance
- Since:
- 7.0 Funafuti
-
close
public void close()Closes all opened resources used by the connection. Also calls closeSession().- Specified by:
closein classJMapConnection
-
finalize
- Overrides:
finalizein classJMapBaseNetworkConnection- Throws:
Throwable
-
destroy
public void destroy()- Overrides:
destroyin classJMapBaseNetworkConnection
-
getLastMessage
Returns the message of the last request made to JMapServer.- Returns:
- the message of the last request made to JMapServer.
-
getLastStatus
public int getLastStatus()Returns the status of the last request made to JMapServer.- Returns:
- the status of the last request made to JMapServer.
- See Also:
-
executePendingRequests
public void executePendingRequests()Executes all pending requests of the current logged user. -
deleteAllPendingRequests
public void deleteAllPendingRequests()Deletes all pending requests of the current logged user. -
getPassword
Returns the password passed to the last openSession(String, String) method.- Returns:
- the current user password
-
isMaxSessionExceeded
public boolean isMaxSessionExceeded() -
isServerLicenseExpired
public boolean isServerLicenseExpired() -
addSrvConnectionListener
-
removeSrvConnectionListener
-
getLayerInfo
Gets the layer info for a specific layer that is part of a specific project.- Parameters:
projectName- the name of the projectlayerName- the name of the layer- Returns:
- the layer info for the specified layer if it exists; if it doesn't exist, null is returned
- See Also:
-
getLayersConfig
-
readFromByteArray
-
getOfflineRequestHandler
-
getLastUsername
-
goOffline
public boolean goOffline()Force the offline mode on all pool connections.- Specified by:
goOfflinein classJMapBaseNetworkConnection- Returns:
trueif successful,falseif the connection is already in offline mode
-
goOnline
public boolean goOnline()Force the online mode on all pool connections.- Specified by:
goOnlinein classJMapBaseNetworkConnection- Returns:
trueif successful
-
executeRequest
Non-blocking method that sends a pre-serialized request (byte array) to JMapServer and returns the serialized response object (byte array) obtained from JMapServer. Execute the request using a pool of network connections.- Specified by:
executeRequestin classJMapConnection- Parameters:
requestBytes- the request bytes to send to JMapServer- Returns:
- the response from JMapServer
- Throws:
IOException
-
pushRequest
Non-blocking method that push the request execution on a separate thread. Requests are not placed in a queue here. When the response is returned from JMapServer, the client is notified through its callback.- Specified by:
pushRequestin classJMapConnection- Parameters:
request- the request to send to JMapServer- See Also:
-
isConnected
public boolean isConnected()Monitor the connection status.- Specified by:
isConnectedin classJMapConnection- Returns:
trueif at least one connection is connected
-
getNbPendingRequests
public int getNbPendingRequests()Returns the number of pending requests.- Returns:
- number of pending requests
-
setReadTimeout
public void setReadTimeout(int readTimeout)
-