Class Client
- java.lang.Object
-
- org.marketcetera.util.ws.stateless.Node
-
- org.marketcetera.util.ws.stateless.StatelessClient
-
- org.marketcetera.util.ws.stateful.Client
-
- All Implemented Interfaces:
UsesPort
public class Client extends StatelessClient
A client node for stateful communication. Its (optional) application ID is that of the application which hosts the client. A session starts withlogin(String,char[])and ends withlogout().- Since:
- 1.0.0
- Version:
- $Id: Client.java 17411 2017-04-28 14:50:38Z colin $
- Author:
- tlerios@marketcetera.com
-
-
Field Summary
Fields Modifier and Type Field Description private SessionIdmSessionIdprivate Stringusernameusername value-
Fields inherited from class org.marketcetera.util.ws.stateless.Node
DEFAULT_CLIENT_HOST, DEFAULT_PORT, DEFAULT_SERVER_HOST
-
-
Constructor Summary
Constructors Constructor Description Client()Creates a new client node with the default server host name and port, and no client application ID.Client(String host, int port, AppId appId)Creates a new client node with the given server host name, port, and client application ID.Client(String inHost, int inPort, AppId inAppId, ContextClassProvider inContextClassProvider)Create a new Client instance.Client(AppId appId)Creates a new client node with the default server host name and port, and the given client application ID.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidassertValidSession()Asserts that an active session is in progress.ClientContextgetContext()Returns a client context which the client must supply as an argument to every remote call made via proxies obtained from the receiver.SessionIdgetSessionId()Returns the receiver's session ID.StringgetUsername()Get the username value.voidlogin(String user, char[] password)Initiates a new session using the given credentials.voidlogout()Ends an ongoing session.private voidsetSessionId(SessionId sessionId)Sets the receiver's session ID to the given one.private voidsetUsername(String inUsername)Sets the username value.-
Methods inherited from class org.marketcetera.util.ws.stateless.StatelessClient
fillContext, getAppId, getService
-
Methods inherited from class org.marketcetera.util.ws.stateless.Node
getConnectionUrl, getHost, getId, getNodeDescription, getPort, getPortDescriptors, setHost, setNodeDescription, setPort
-
-
-
-
Constructor Detail
-
Client
public Client(String inHost, int inPort, AppId inAppId, ContextClassProvider inContextClassProvider)
Create a new Client instance.- Parameters:
inHost- aStringvalueinPort- anintvalueinAppId- anAppIdvalueinContextClassProvider- aContextClassProvidervalue
-
Client
public Client(String host, int port, AppId appId)
Creates a new client node with the given server host name, port, and client application ID.- Parameters:
host- The host name.port- The port.appId- The application ID, which may be null.
-
Client
public Client(AppId appId)
Creates a new client node with the default server host name and port, and the given client application ID.- Parameters:
appId- The application ID, which may be null.
-
Client
public Client()
Creates a new client node with the default server host name and port, and no client application ID.
-
-
Method Detail
-
getUsername
public String getUsername()
Get the username value.- Returns:
- a
Stringvalue
-
setUsername
private void setUsername(String inUsername)
Sets the username value.- Parameters:
inUsername- aStringvalue
-
setSessionId
private void setSessionId(SessionId sessionId)
Sets the receiver's session ID to the given one.- Parameters:
sessionId- The session ID, which may be null.
-
getSessionId
public SessionId getSessionId()
Returns the receiver's session ID.- Returns:
- The session ID, which may be null.
-
assertValidSession
public void assertValidSession() throws I18NExceptionAsserts that an active session is in progress.- Throws:
I18NException- Thrown if an active session is not in progress.
-
login
public void login(String user, char[] password) throws I18NException, RemoteException
Initiates a new session using the given credentials.- Parameters:
user- The user name.password- The password.- Throws:
I18NException- Thrown if a session is already in progress.RemoteException- Thrown if the server is unable to complete the login operation.
-
logout
public void logout() throws RemoteExceptionEnds an ongoing session.- Throws:
RemoteException- Thrown if the server is unable to complete the logout operation.
-
getContext
public ClientContext getContext()
Description copied from class:StatelessClientReturns a client context which the client must supply as an argument to every remote call made via proxies obtained from the receiver.- Overrides:
getContextin classStatelessClient- Returns:
- The context.
-
-