/**
* Create a new Vorba Session
* @param applicationHandle is the application's VAMSAS handle string
+ * @throws NoDefaultSessionException if more than one session exists that the client may connect to
*/
- IClient getIClient(ClientHandle applicationHandle);
+ IClient getIClient(ClientHandle applicationHandle) throws NoDefaultSessionException;
/**
* returns new Vorba for a given session.
* @param applicationHandle
* @param applicationHandle
* @param userId
* @return
+ * @throws NoDefaultSessionException if more than one session exists that the client may connect to
*/
- IClient getIClient(ClientHandle applicationHandle, UserHandle userId);
+ IClient getIClient(ClientHandle applicationHandle, UserHandle userId) throws NoDefaultSessionException;
+ /**
+ * enumerate the active sessions this IClientFactory instance knows about.
+ * Can be used by caller to pick a session on catching a NoDefaultSessionException.
+ * LATER: Define interface for discovering more information about a session (so it can be presented to a user in a meaningful way)
+ * @return possibly empty array of sessionUrn strings
+ */
+ public String[] getCurrentSessions();
}
--- /dev/null
+/**
+ *
+ */
+package org.vamsas.client;
+
+/**
+ * @author jimp
+ * Raised if an IClient instance is requested without
+ * specifying a particular vamsas session handle
+ * when more than one candidate session exists.
+ */
+public class NoDefaultSessionException extends Exception {
+
+ /**
+ *
+ */
+ public NoDefaultSessionException() {
+ super("No Default Session Defined");
+ }
+
+ /**
+ * @param message
+ */
+ public NoDefaultSessionException(String message) {
+ super(message);
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param cause
+ */
+ public NoDefaultSessionException(Throwable cause) {
+ super(cause);
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public NoDefaultSessionException(String message, Throwable cause) {
+ super(message, cause);
+ // TODO Auto-generated constructor stub
+ }
+
+}
import org.vamsas.client.ClientHandle;
import org.vamsas.client.IClient;
import org.vamsas.client.IClientFactory;
+import org.vamsas.client.NoDefaultSessionException;
import org.vamsas.client.UserHandle;
/**
throw(new IOException("Cannot read and write to a directory called "+path));
}
}
+
+ /* (non-Javadoc)
+ * @see org.vamsas.client.IClientFactory#getCurrentSessions()
+ */
+ public String[] getCurrentSessions() {
+ // TODO look in the arena and enumerate session handles for return.
+ return new String[] {};
+ }
/* (non-Javadoc)
* @see org.vamsas.client.IClientFactory#getIClient(org.vamsas.client.ClientHandle)
*/
- public IClient getIClient(ClientHandle applicationHandle) {
+ public IClient getIClient(ClientHandle applicationHandle) throws NoDefaultSessionException {
// create a new session
// register new ClientHandle in session
// create SimpleClient instance
/* (non-Javadoc)
* @see org.vamsas.client.IClientFactory#getIClient(org.vamsas.client.ClientHandle, org.vamsas.client.UserHandle)
*/
- public IClient getIClient(ClientHandle applicationHandle, UserHandle userId) {
+ public IClient getIClient(ClientHandle applicationHandle, UserHandle userId) throws NoDefaultSessionException {
// create new session
// register SimpleClient and UserHandles in session
// create client instance