@ThreadSafe public abstract class SessionProxy extends Object implements Session
A session proxy wraps the communication with a remote session object. This includes the creation of that object thru the appropriate session factory.
Modifier and Type | Class and Description |
---|---|
static class |
SessionProxy.Builder
Builder.
|
static interface |
SessionProxy.Listener
Listener.
|
static class |
SessionProxy.SessionConnectVetoException
Connect veto exception.
|
Session.ConnectionMode
Modifier | Constructor and Description |
---|---|
protected |
SessionProxy(String clientName,
Optional<LoginInfo> loginInfo,
SessionClientContext context,
Optional<SessionProxy.Listener> listener,
boolean autoconnect)
Constructs an instance.
|
Modifier and Type | Method and Description |
---|---|
void |
connect()
Connects to a session.
|
protected abstract Session |
createSession()
Creates a session.
|
void |
disconnect()
Disconnects from the session.
|
protected String |
getClientName()
Gets the clientName.
|
Session.ConnectionMode |
getConnectionMode()
Gets the connection mode.
|
SessionClientContext |
getContext()
Gets the context.
|
UUID |
getContextUUID()
Gets the context UUID.
|
protected Remote |
getFactory()
Gets the session factory.
|
String |
getServerName()
Gets the server name.
|
URI |
getServerURI()
Gets the server URI.
|
protected Session |
getSession()
Gets the session.
|
protected Logger |
getThisLogger()
Gets the logger for this instance.
|
boolean |
hasLoginInfo()
Asks if login info is available.
|
boolean |
isConnected()
Asks if the session is connected.
|
boolean |
isPrivate()
Asks if this is a private session.
|
boolean |
isRemote()
Asks if this is a remote session.
|
protected void |
lockConnect()
Locks connect.
|
protected void |
lockConnectInterruptibly()
Locks connect interruptibly.
|
void |
login(String identifier,
char[] password)
Identifies and authenticates the identity associated with the Session.
|
void |
logout()
Logs out.
|
protected SessionException |
sessionException(Exception exception)
Throws a session exception.
|
protected String |
sessionMode()
Returns some session mode identifying text.
|
void |
tearDown()
Tears down what has been set up.
|
protected void |
unlockConnect()
Unlocks connect.
|
protected SessionProxy(@Nonnull String clientName, @Nonnull Optional<LoginInfo> loginInfo, @Nonnull SessionClientContext context, @Nonnull Optional<SessionProxy.Listener> listener, boolean autoconnect)
clientName
- The client name.loginInfo
- The optional login informations.context
- The session client context.listener
- The optional listener.autoconnect
- The autoconnect indicator.public void connect() throws SessionConnectFailedException
This method may be called redundantly.
SessionConnectFailedException
- When connect fails.public void disconnect()
This method may be called redundantly.
public Session.ConnectionMode getConnectionMode()
This method may be called before or after Session.login(java.lang.String, char[])
.
getConnectionMode
in interface Session
@Nonnull @CheckReturnValue public SessionClientContext getContext()
@Nonnull @CheckReturnValue public UUID getContextUUID()
@Nonnull @CheckReturnValue public String getServerName()
@Nonnull @CheckReturnValue public URI getServerURI()
@CheckReturnValue public final boolean hasLoginInfo()
@CheckReturnValue public boolean isConnected()
@CheckReturnValue public boolean isPrivate()
@CheckReturnValue public boolean isRemote()
public void login(String identifier, char[] password)
public void tearDown()
@Nonnull @CheckReturnValue protected abstract Session createSession() throws RemoteException, SessionException
RemoteException
- From RMI.SessionException
- When session creation fails.@Nonnull @CheckReturnValue protected String getClientName()
@Nonnull @CheckReturnValue protected final Remote getFactory() throws SessionConnectFailedException
SessionConnectFailedException
- When connect fails.@Nonnull @CheckReturnValue protected final Session getSession() throws SessionException
SessionException
- When the session can't be obtained.@Nonnull @CheckReturnValue protected final Logger getThisLogger()
protected void lockConnect()
protected void lockConnectInterruptibly() throws CatchedSessionException
CatchedSessionException
- When an exception is catched.@Nonnull @CheckReturnValue protected SessionException sessionException(@Nonnull Exception exception)
exception
- A catched exception.@Nonnull @CheckReturnValue protected String sessionMode()
protected void unlockConnect()
Copyright © 2003-2019 Serge Brisson. All Rights Reserved.