public class client
extends java.lang.Object
client instances, which
are destroyed on program termination.
Typical usage:
omero.client client = new omero.client(); // Uses ICE_CONFIG
omero.client client = new omero.client(host); // Defines "omero.host"
omero.client client = new omero.client(host, port); // Defines "omero.host" and "omero.port"
For more information, see
https://trac.openmicroscopy.org.uk/ome/wiki/ClientDesign | Constructor and Description |
|---|
client()
Calls
client(Ice.InitializationData) with a new
InitializationData |
client(java.io.File... files)
Creates an
Communicator from multiple files. |
client(Ice.InitializationData id)
Creates an
Communicator from a InitializationData
instance. |
client(java.util.Map p)
Creates an
Communicator from a Map instance. |
client(java.lang.String host)
Creates an
Communicator pointing at the given server using
the Server.DEFAULT_PORT. |
client(java.lang.String[] args)
Calls
client(String[], Ice.InitializationData) with a new
InitializationData |
client(java.lang.String[] args,
Ice.InitializationData id)
Creates an
Communicator from command-line arguments. |
client(java.lang.String host,
int port)
Creates an
Communicator pointing at the given server with the
non-standard port. |
| Modifier and Type | Method and Description |
|---|---|
void |
__del__()
Calls closeSession() and ignores any exceptions.
|
void |
closeSession()
Closes the session and nulls out the communicator.
|
client |
createClient(boolean secure)
Creates a possibly insecure
client instance and calls
joinSession(String) using the current session id. |
ServiceFactoryPrx |
createSession()
Calls
createSession(String, String) with null values |
ServiceFactoryPrx |
createSession(java.lang.String username,
java.lang.String password)
Performs the actual logic of logging in, which is done via the
getRouter(Ice.Communicator). |
void |
download(long fileId,
java.io.File file) |
void |
download(long fileId,
java.io.File file,
int blockSize) |
void |
enableKeepAlive(int seconds)
Resets the "omero.keep_alive" property on the current
Communicator which is used on initialization to determine the
time-period between checks. |
protected ISessionPrx |
env()
Helper method to access session environment
|
protected static java.lang.String |
filesToString(java.io.File... files) |
Ice.ObjectAdapter |
getAdapter() |
java.lang.String |
getCategory()
Returns the category which should be used for all callbacks
passed to the server.
|
Ice.Communicator |
getCommunicator()
Returns the
Communicator for this instance or throws an
exception if null. |
int |
getDefaultBlockSize()
Returns the user-configured setting for "omero.block_size"
or
DEFAULTBLOCKSIZE if none is set. |
Ice.ImplicitContext |
getImplicitContext()
Returns the
ImplicitContext which defines what properties
will be sent on every method invocation. |
RType |
getInput(java.lang.String key)
Retrieves an item from the "input" shared (session) memory.
|
java.util.List<java.lang.String> |
getInputKeys()
Returns a list of keys for all items in the "input" shared (session)
memory
|
RType |
getOutput(java.lang.String key)
Retrieves an item from the "output" shared (session) memory.
|
java.util.List<java.lang.String> |
getOutputKeys()
Returns a list of keys for all items in the "output" shared (session)
memory
|
Ice.Properties |
getProperties()
Returns the
active properties for this instance. |
java.lang.String |
getProperty(java.lang.String key)
Returns the property value for this key or the empty string if none.
|
java.util.Map<java.lang.String,java.lang.String> |
getPropertyMap()
Returns all properties which are prefixed with "omero." or "Ice."
using the Properties from
getProperties(). |
java.util.Map<java.lang.String,java.lang.String> |
getPropertyMap(Ice.Properties properties)
Returns all properties which are prefixed with "omero." or "Ice."
|
static Glacier2.RouterPrx |
getRouter(Ice.Communicator comm)
Acquires the
default router,
and throws an exception if it is not of type {Glacier2.RouterPrx}. |
ServiceFactoryPrx |
getSession()
Returns the current active session or throws an exception if none has
been
created since the last
closeSession() |
java.lang.String |
getSessionId()
Returns the UUID for the current session without making a remote call.
|
java.util.List<StatefulServiceInterfacePrx> |
getStatefulServices()
Returns all active
StatefulServiceInterface proxies. |
boolean |
isSecure()
Specifies whether or not this client was created via a call to
createClient(boolean) with a boolean of false. |
ServiceFactoryPrx |
joinSession(java.lang.String session)
Uses the given session uuid as name and password to rejoin a running
session.
|
int |
killSession()
Calls ISession.closeSession(omero.model.Session) until
the returned reference count is greater than zero.
|
void |
onHeartbeat(java.lang.Runnable runnable) |
void |
onSessionClosed(java.lang.Runnable runnable) |
void |
onShutdown(java.lang.Runnable runnable) |
protected java.lang.String |
parseAndSetInt(Ice.InitializationData data,
java.lang.String key,
int newValue) |
void |
setAgent(java.lang.String agent)
Sets the
user agent string for
this client. |
boolean |
setFastShutdown(boolean fastShutdown)
Sets the
fastShutdown flag. |
void |
setInput(java.lang.String key,
RType value)
Sets an item in the "input" shared (session) memory under the given name.
|
void |
setIP(java.lang.String ip)
Sets the
user ip string for
this client. |
void |
setOutput(java.lang.String key,
RType value)
Sets an item in the "output" shared (session) memory under the given
name.
|
java.lang.String |
sha1(java.io.File file)
Calculates the local sha1 for a file.
|
OriginalFile |
upload(java.io.File file) |
OriginalFile |
upload(java.io.File file,
OriginalFile fileObject) |
OriginalFile |
upload(java.io.File file,
OriginalFile fileObject,
java.lang.Integer blockSize)
Utility method to upload a file to the server
|
public client()
client(Ice.InitializationData) with a new
InitializationDatapublic client(Ice.InitializationData id)
Communicator from a InitializationData
instance. Cannot be null.id - the Ice initialization datapublic client(java.lang.String host)
Communicator pointing at the given server using
the Server.DEFAULT_PORT.host - the server host namepublic client(java.lang.String host,
int port)
Communicator pointing at the given server with the
non-standard port.host - the server host nameport - the server port numberpublic client(java.lang.String[] args)
client(String[], Ice.InitializationData) with a new
InitializationDataargs - command-line argumentspublic client(java.lang.String[] args,
Ice.InitializationData id)
Communicator from command-line arguments. These
are parsed via Ice.Properties.parseIceCommandLineOptions(args) and
Ice.Properties.parseCommandLineOptions("omero", args)args - command-line argumentsid - the Ice initialization datapublic client(java.io.File... files)
Communicator from multiple files.files - files from which to load propertiespublic client(java.util.Map p)
Communicator from a Map instance. The
String representation of each member is added to the
Properties under the String representation of the
key.p - propertiespublic boolean setFastShutdown(boolean fastShutdown)
fastShutdown flag. By setting this
to true, you will prevent proper clean up. This should
only be used in the case of network loss (or similar).fastShutdown - if shutdown should be fastpublic void setAgent(java.lang.String agent)
user agent string for
this client. Every session creation will be passed this argument. Finding
open sessions with the same agent can be done via
ISessionPrx.getMyOpenAgentSessions(String).agent - the user agent for sessionspublic void setIP(java.lang.String ip)
user ip string for
this client. Every session creation will be passed this argument. Finding
open sessions with the same agent can be done via
ISessionPrx.getMyOpenAgentSessions(String).ip - the user IP addresspublic boolean isSecure()
createClient(boolean) with a boolean of false. If insecure, then
all remote calls will use the insecure connection defined by the server.public client createClient(boolean secure) throws ServerError, Glacier2.CannotCreateSessionException, Glacier2.PermissionDeniedException
client instance and calls
joinSession(String) using the current session id. If secure is false, then first the "omero.router.insecure"
configuration property is retrieved from the server and used as the value
of "Ice.Default.Router" for the new client. Any exception thrown during
creation is passed on to the caller.
Note: detachOnDestroy has NOT been called on the session in the returned client.
Clients are responsible for doing this immediately if such desired.ServerErrorGlacier2.CannotCreateSessionExceptionGlacier2.PermissionDeniedExceptionpublic void __del__()
public Ice.Communicator getCommunicator()
Communicator for this instance or throws an
exception if null.Communicatorpublic Ice.ObjectAdapter getAdapter()
public ServiceFactoryPrx getSession()
created since the last
closeSession()public java.lang.String getSessionId()
getSession() internally and will throw an exception if
no session is active.public java.lang.String getCategory()
public Ice.ImplicitContext getImplicitContext()
ImplicitContext which defines what properties
will be sent on every method invocation.ImplicitContextpublic Ice.Properties getProperties()
active properties for this instance.public java.lang.String getProperty(java.lang.String key)
key - a property keypublic java.util.Map<java.lang.String,java.lang.String> getPropertyMap()
getProperties().public java.util.Map<java.lang.String,java.lang.String> getPropertyMap(Ice.Properties properties)
properties - some Ice propertiespublic int getDefaultBlockSize()
DEFAULTBLOCKSIZE if none is set.public ServiceFactoryPrx joinSession(java.lang.String session) throws Glacier2.CannotCreateSessionException, Glacier2.PermissionDeniedException, ServerError
Glacier2.CannotCreateSessionExceptionGlacier2.PermissionDeniedExceptionServerErrorpublic ServiceFactoryPrx createSession() throws Glacier2.CannotCreateSessionException, Glacier2.PermissionDeniedException, ServerError
createSession(String, String) with null valuesGlacier2.CannotCreateSessionExceptionGlacier2.PermissionDeniedExceptionServerErrorpublic ServiceFactoryPrx createSession(java.lang.String username, java.lang.String password) throws Glacier2.CannotCreateSessionException, Glacier2.PermissionDeniedException, ServerError
getRouter(Ice.Communicator). Disallows an extant ServiceFactoryPrx
and tries to re-create a null Communicator. A null or empty
username will throw an exception, but an empty password is allowed.Glacier2.CannotCreateSessionExceptionGlacier2.PermissionDeniedExceptionServerErrorpublic static Glacier2.RouterPrx getRouter(Ice.Communicator comm)
default router,
and throws an exception if it is not of type {Glacier2.RouterPrx}. Also
sets the ImplicitContext on the router proxy.comm - the Ice communicatorpublic void enableKeepAlive(int seconds)
Communicator which is used on initialization to determine the
time-period between checks.public java.util.List<StatefulServiceInterfacePrx> getStatefulServices() throws ServerError
StatefulServiceInterface proxies. This can
be used to call close before calling setSecurityContext.ServerErrorpublic void closeSession()
public int killSession()
public java.lang.String sha1(java.io.File file)
file - a local filepublic OriginalFile upload(java.io.File file) throws ServerError, java.io.IOException
ServerErrorjava.io.IOExceptionpublic OriginalFile upload(java.io.File file, OriginalFile fileObject) throws ServerError, java.io.IOException
ServerErrorjava.io.IOExceptionpublic OriginalFile upload(java.io.File file, OriginalFile fileObject, java.lang.Integer blockSize) throws ServerError, java.io.IOException
file - Cannot be null.fileObject - Can be null.blockSize - Can be null.ServerErrorjava.io.IOExceptionpublic void download(long fileId,
java.io.File file)
throws ServerError,
java.io.IOException
ServerErrorjava.io.IOExceptionpublic void download(long fileId,
java.io.File file,
int blockSize)
throws ServerError,
java.io.IOException
ServerErrorjava.io.IOExceptionpublic RType getInput(java.lang.String key) throws ServerError
ServerErrorpublic RType getOutput(java.lang.String key) throws ServerError
ServerErrorpublic void setInput(java.lang.String key,
RType value)
throws ServerError
ServerErrorpublic void setOutput(java.lang.String key,
RType value)
throws ServerError
ServerErrorpublic java.util.List<java.lang.String> getInputKeys()
throws ServerError
ServerErrorpublic java.util.List<java.lang.String> getOutputKeys()
throws ServerError
ServerErrorprotected java.lang.String parseAndSetInt(Ice.InitializationData data,
java.lang.String key,
int newValue)
protected static java.lang.String filesToString(java.io.File... files)
protected ISessionPrx env() throws ServerError
ServerErrorpublic void onHeartbeat(java.lang.Runnable runnable)
public void onSessionClosed(java.lang.Runnable runnable)
public void onShutdown(java.lang.Runnable runnable)