omero
Class client

java.lang.Object
  extended by omero.client

public class client
extends Object

Central client-side blitz entry point. This class uses solely Ice functionality to provide access to blitz (as opposed to also using Spring) and should be in sync with the OmeroPy omero.client class as well as the OmeroCpp omero::client class. In order to more closely map the destructors in Python and C++, this class keeps a collection of 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" More more information, see https://trac.openmicroscopy.org.uk/omero/wiki/ClientDesign

Since:
3.0-Beta3
Author:
Josh Moore, josh at glencoesoftware.com

Constructor Summary
client()
          Calls client(Ice.InitializationData) with a new InitializationData
client(File... files)
          Creates an Communicator from multiple files.
client(Ice.InitializationData id)
          Creates an Communicator from a InitializationData instance.
client(Map p)
          Creates an Communicator from a Map instance.
client(String host)
          Creates an Communicator pointing at the given server using the #DEFAULT_PORT.
client(String[] args)
          Calls client(String[], Ice.InitializationData) with a new InitializationData
client(String[] args, Ice.InitializationData id)
          Creates an Communicator from command-line arguments.
client(String host, int port)
          Creates an Communicator pointing at the given server with the non-standard port.
 
Method Summary
protected  void __del__()
          Calls closeSession() and ignores any exceptions.
 void closeSession()
          Closes the session and nulls out the communicator.
 omero.api.ServiceFactoryPrx createSession()
          Calls createSession(String, String) with null values
 omero.api.ServiceFactoryPrx createSession(String username, String password)
          Performs the actual logic of logging in, which is done via the #getRouter().
 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  omero.api.ISessionPrx env()
          Helper method to access session environment
protected static String filesToString(File... files)
           
 Ice.Communicator getCommunicator()
          Returns the Communicator for this instance or throws an exception if null.
 Ice.ImplicitContext getImplicitContext()
          Returns the ImplicitContext which defines what properties will be sent on every method invocation.
 omero.RType getInput(String key)
          Retrieves an item from the "input" shared (session) memory.
 List<String> getInputKeys()
          Returns a list of keys for all items in the "input" shared (session) memory
 omero.RType getOutput(String key)
          Retrieves an item from the "output" shared (session) memory.
 List<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.
 String getProperty(String key)
          Returns the property value for this key or the empty string if none.
static Glacier2.RouterPrx getRouter(Ice.Communicator comm)
          Acquires the default router, and throws an exception if it is not of type {Glacier2.RouterPrx}.
 omero.api.ServiceFactoryPrx getServiceFactory()
          Deprecated.  
 omero.api.ServiceFactoryPrx getSession()
          Returns the current active session or throws an exception if none has been created since the last closeSession()
 omero.api.ServiceFactoryPrx joinSession(String session)
          Uses the given session uuid as name and password to rejoin a running session.
 void onHearbeat(Runnable runnable)
           
 void onSessionClosed(Runnable runnable)
           
 void onShutdown(Runnable runnable)
           
protected  String parseAndSetInt(Ice.InitializationData data, String key, int newValue)
           
protected  String sess()
          Helper method to access session id
 void setInput(String key, omero.RType value)
          Sets an item in the "input" shared (session) memory under the given name.
 void setOutput(String key, omero.RType value)
          Sets an item in the "output" shared (session) memory under the given name.
 String sha1(File file)
          Calculates the local sha1 for a file.
 void upload(File file, omero.model.OriginalFile fileObject, Integer blockSize)
          Utility method to upload a file to the server
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

client

public client()
Calls client(Ice.InitializationData) with a new InitializationData


client

public client(Ice.InitializationData id)
Creates an Communicator from a InitializationData instance. Cannot be null.


client

public client(String host)
Creates an Communicator pointing at the given server using the #DEFAULT_PORT.


client

public client(String host,
              int port)
Creates an Communicator pointing at the given server with the non-standard port.


client

public client(String[] args)
Calls client(String[], Ice.InitializationData) with a new InitializationData


client

public client(String[] args,
              Ice.InitializationData id)
Creates an Communicator from command-line arguments. These are parsed via Ice.Properties.parseIceCommandLineOptions(args) and Ice.Properties.parseCommandLineOptions("omero", args)


client

public client(File... files)
Creates an Communicator from multiple files.


client

public client(Map p)
Creates an Communicator from a Map instance. The String representation of each member is added to the Properties under the String representation of the key.

Method Detail

__del__

protected void __del__()
Calls closeSession() and ignores any exceptions. Equivalent to OmeroPy's __del__ or OmeroCpp's omero::client::~client()


getCommunicator

public Ice.Communicator getCommunicator()
Returns the Communicator for this instance or throws an exception if null.


getSession

public omero.api.ServiceFactoryPrx getSession()
Returns the current active session or throws an exception if none has been created since the last closeSession()


getServiceFactory

@Deprecated
public omero.api.ServiceFactoryPrx getServiceFactory()
Deprecated. 

See Also:
getSession()

getImplicitContext

public Ice.ImplicitContext getImplicitContext()
Returns the ImplicitContext which defines what properties will be sent on every method invocation.


getProperties

public Ice.Properties getProperties()
Returns the active properties for this instance.


getProperty

public String getProperty(String key)
Returns the property value for this key or the empty string if none.


joinSession

public omero.api.ServiceFactoryPrx joinSession(String session)
                                        throws Glacier2.CannotCreateSessionException,
                                               Glacier2.PermissionDeniedException,
                                               omero.ServerError
Uses the given session uuid as name and password to rejoin a running session.

Throws:
Glacier2.PermissionDeniedException
Glacier2.CannotCreateSessionException
omero.ServerError

createSession

public omero.api.ServiceFactoryPrx createSession()
                                          throws Glacier2.CannotCreateSessionException,
                                                 Glacier2.PermissionDeniedException,
                                                 omero.ServerError
Calls createSession(String, String) with null values

Throws:
Glacier2.CannotCreateSessionException
Glacier2.PermissionDeniedException
omero.ServerError

createSession

public omero.api.ServiceFactoryPrx createSession(String username,
                                                 String password)
                                          throws Glacier2.CannotCreateSessionException,
                                                 Glacier2.PermissionDeniedException,
                                                 omero.ServerError
Performs the actual logic of logging in, which is done via the #getRouter(). 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.

Parameters:
username -
password -
Returns:
Throws:
Glacier2.CannotCreateSessionException
Glacier2.PermissionDeniedException
omero.ServerError

getRouter

public static Glacier2.RouterPrx getRouter(Ice.Communicator comm)
Acquires the default router, and throws an exception if it is not of type {Glacier2.RouterPrx}. Also sets the ImplicitContext on the router proxy.


enableKeepAlive

public 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. If no __resources is available currently, one is also created.


closeSession

public void closeSession()
Closes the session and nulls out the communicator. This is required by an Ice bug.

See Also:
2370 Ice Ping Error

sha1

public String sha1(File file)
Calculates the local sha1 for a file.


upload

public void upload(File file,
                   omero.model.OriginalFile fileObject,
                   Integer blockSize)
Utility method to upload a file to the server

Parameters:
file - Cannot be null.
fileObject - Can be null.
blockSize - Can be null.

getInput

public omero.RType getInput(String key)
                     throws omero.ServerError
Retrieves an item from the "input" shared (session) memory.

Throws:
omero.ServerError

getOutput

public omero.RType getOutput(String key)
                      throws omero.ServerError
Retrieves an item from the "output" shared (session) memory.

Throws:
omero.ServerError

setInput

public void setInput(String key,
                     omero.RType value)
              throws omero.ServerError
Sets an item in the "input" shared (session) memory under the given name.

Throws:
omero.ServerError

setOutput

public void setOutput(String key,
                      omero.RType value)
               throws omero.ServerError
Sets an item in the "output" shared (session) memory under the given name.

Throws:
omero.ServerError

getInputKeys

public List<String> getInputKeys()
                          throws omero.ServerError
Returns a list of keys for all items in the "input" shared (session) memory

Throws:
omero.ServerError

getOutputKeys

public List<String> getOutputKeys()
                           throws omero.ServerError
Returns a list of keys for all items in the "output" shared (session) memory

Throws:
omero.ServerError

parseAndSetInt

protected String parseAndSetInt(Ice.InitializationData data,
                                String key,
                                int newValue)

filesToString

protected static String filesToString(File... files)

env

protected omero.api.ISessionPrx env()
                             throws omero.ServerError
Helper method to access session environment

Throws:
omero.ServerError

sess

protected String sess()
               throws omero.ServerError
Helper method to access session id

Throws:
omero.ServerError

onHearbeat

public void onHearbeat(Runnable runnable)

onSessionClosed

public void onSessionClosed(Runnable runnable)

onShutdown

public void onShutdown(Runnable runnable)


OmeroJava Api

Version: Beta-4.1.1-r5927-b91

Copyright © 2009 The University of Dundee. All Rights Reserved.