Package omero.cmd
Class SessionI
- java.lang.Object
-
- omero.cmd.SessionI
-
- All Implemented Interfaces:
Glacier2._SessionOperations
,_SessionOperations
- Direct Known Subclasses:
ServiceFactoryI
public class SessionI extends java.lang.Object implements _SessionOperations
- Since:
- 4.3.2
-
-
Field Summary
Fields Modifier and Type Field Description Ice.ObjectAdapter
adapter
protected ClientCallbackPrx
callback
java.lang.String
clientId
ome.system.OmeroContext
context
Glacier2.SessionControlPrx
control
protected boolean
doClose
ome.services.util.Executor
executor
Executor
to be used by servant implementations which do not delegate to the server package where all instances are wrapped with AOP for dealing with Hibernate.ServantHolder
holder
ome.system.Principal
principal
protected java.util.concurrent.atomic.AtomicBoolean
reusedSession
ome.services.sessions.SessionManager
sessionManager
java.lang.String
token
Token in the form of a UUID for securing method invocations.
-
Constructor Summary
Constructors Constructor Description SessionI(boolean reusedSession, Ice.Current current, ServantHolder holder, Glacier2.SessionControlPrx control, ome.system.OmeroContext context, ome.services.sessions.SessionManager sessionManager, ome.services.util.Executor executor, ome.system.Principal principal, java.lang.String token)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
allow(Ice.ObjectPrx prx)
protected Ice.Object
callContextWrapper(Ice.Object servant, Ice.Current current)
void
cleanServants(boolean all)
UsecleanServants(boolean, String, ServantHolder, Ice.ObjectAdapter)
to clean up.static void
cleanServants(boolean all, java.lang.String clientId, ServantHolder holder, Ice.ObjectAdapter adapter)
Clean all servants that are in the current holder and remove them from the adapter.void
cleanupSelf()
Called if this isn't a kill-everything event.static java.lang.String
clientId(Ice.Current current)
Helpers method to extract theCLIENTUUID
out of the given Ice.Current.void
configureServant(Ice.Object servant)
Apply proper AOP and call setters for any known injection properties.protected Ice.Object
createServantDelegate(java.lang.String name)
Creates a proxy according to the servant definition for the given name.void
destroy(Ice.Current current)
Destruction simply decrements the reference count for a session to allow reconnecting to it.void
doDestroy()
Performs the actual cleanup operation on all the resources shared between this and otherServiceFactoryI
instances in the sameSession
.Ice.ObjectAdapter
getAdapter()
ome.services.util.Executor
getExecutor()
Ice.Identity
getIdentity(java.lang.String name)
ome.system.Principal
getPrincipal()
void
handleCallbackException(java.lang.Exception e)
Reusable method for logging an exception that occurs on one-way communication with clients during callback notification.protected void
internalServantConfig(java.lang.Object obj)
Ice.Current
newCurrent(Ice.Identity id, java.lang.String method)
static Ice.Current
newCurrent(Ice.Identity id, java.lang.String method, Ice.ObjectAdapter adapter, java.lang.String clientId)
Ice.ObjectPrx
registerServant(Ice.Identity id, Ice.Object servant)
Registers the servant with the adapter (or throws an exception if one is already registered) as well as configures the servant in any post-Spring way necessary, based on the type of the servant.Ice.ObjectPrx
registerServant(Ice.Identity id, Ice.Object servant, Ice.Current current)
Additionally stores information from theCurrent
argument in theCallContext
so that information from the creation of a servant can be recorded server-side without the need for clients to re-send the information or even for values which clients should not know.Ice.Identity
sessionId()
Returns theIdentity
for this instance as defined bysessionId(String, String)
static Ice.Identity
sessionId(java.lang.String clientId, java.lang.String uuid)
Definition of session ids:"session-<CLIENTID>/<UUID>"
void
submit_async(AMD_Session_submit __cb, Request req, Ice.Current current)
void
submit_async(AMD_Session_submit __cb, Request req, Ice.Current current, ome.services.util.Executor.Priority priority)
java.lang.String
toString()
void
unregisterServant(Ice.Identity id)
static void
unregisterServant(Ice.Identity id, Ice.ObjectAdapter adapter, ServantHolder holder)
Reverts all the additions made byregisterServant(Ice.Identity, Ice.Object)
Now called bySessionManagerI
in response to anUnregisterServantMessage
.
-
-
-
Field Detail
-
clientId
public final java.lang.String clientId
-
control
public final Glacier2.SessionControlPrx control
-
reusedSession
protected final java.util.concurrent.atomic.AtomicBoolean reusedSession
-
doClose
protected boolean doClose
-
callback
protected ClientCallbackPrx callback
-
holder
public final ServantHolder holder
-
sessionManager
public final ome.services.sessions.SessionManager sessionManager
-
executor
public final ome.services.util.Executor executor
Executor
to be used by servant implementations which do not delegate to the server package where all instances are wrapped with AOP for dealing with Hibernate.
-
principal
public final ome.system.Principal principal
-
context
public final ome.system.OmeroContext context
-
adapter
public final Ice.ObjectAdapter adapter
-
token
public final java.lang.String token
Token in the form of a UUID for securing method invocations.
-
-
Constructor Detail
-
SessionI
public SessionI(boolean reusedSession, Ice.Current current, ServantHolder holder, Glacier2.SessionControlPrx control, ome.system.OmeroContext context, ome.services.sessions.SessionManager sessionManager, ome.services.util.Executor executor, ome.system.Principal principal, java.lang.String token) throws ApiUsageException
- Throws:
ApiUsageException
-
-
Method Detail
-
getAdapter
public Ice.ObjectAdapter getAdapter()
-
getPrincipal
public ome.system.Principal getPrincipal()
-
getExecutor
public ome.services.util.Executor getExecutor()
-
submit_async
public void submit_async(AMD_Session_submit __cb, Request req, Ice.Current current)
- Specified by:
submit_async
in interface_SessionOperations
-
submit_async
public void submit_async(AMD_Session_submit __cb, Request req, Ice.Current current, ome.services.util.Executor.Priority priority)
-
destroy
public void destroy(Ice.Current current)
Destruction simply decrements the reference count for a session to allow reconnecting to it. This means that the Glacier timeout property is fairly unimportant. If a Glacier connection times out or is otherwise destroyed, a client can attempt to reconnect. However, in the case of only one reference to the session, if the Glacier2 timeout is greater than the session timeout, exceptions can be thrown when this method tries to clean up the session. Therefore all session access must be guarded by a try/finally block.- Specified by:
destroy
in interfaceGlacier2._SessionOperations
-
handleCallbackException
public void handleCallbackException(java.lang.Exception e)
Reusable method for logging an exception that occurs on one-way communication with clients during callback notification.
-
cleanupSelf
public void cleanupSelf()
Called if this isn't a kill-everything event.- See Also:
- Trac ticket #9330
-
doDestroy
public void doDestroy()
Performs the actual cleanup operation on all the resources shared between this and otherServiceFactoryI
instances in the sameSession
. Sincedestroy(Current)
is called regardless by the router, even when a client has just died, we have this internal method for handling the actual closing of resources. This method must take precautions to not throw aSessionException
. Seedestroy(Current)
for more information. Whendestroy(Current)
is called but it isn't time to close down the entire instance, then we should still close down the stateless services for this instance as well as remove ourselves from the adapter.- See Also:
- Trac ticket #9330
-
cleanServants
public void cleanServants(boolean all)
UsecleanServants(boolean, String, ServantHolder, Ice.ObjectAdapter)
to clean up.- Parameters:
all
- if stateful sessions should be shut down such that other clients cannot reattach (the servant is cleaned up)
-
cleanServants
public static void cleanServants(boolean all, java.lang.String clientId, ServantHolder holder, Ice.ObjectAdapter adapter)
Clean all servants that are in the current holder and remove them from the adapter. If all is true, then all servants that are non-null will be processed. Otherwise, only servants that a) belong to this clientId and b) are not stateful (since stateful services may be used by other clients).- Parameters:
all
- if stateful sessions should be shut down such that other clients cannot reattach (the servant is cleaned up)clientId
- Only used if all is false.holder
-ServantHolder
to be cleaned.adapter
- from which the servants should be removed.
-
internalServantConfig
protected void internalServantConfig(java.lang.Object obj) throws ServerError
- Throws:
ServerError
-
newCurrent
public static Ice.Current newCurrent(Ice.Identity id, java.lang.String method, Ice.ObjectAdapter adapter, java.lang.String clientId)
-
newCurrent
public Ice.Current newCurrent(Ice.Identity id, java.lang.String method)
-
allow
public void allow(Ice.ObjectPrx prx)
-
createServantDelegate
protected Ice.Object createServantDelegate(java.lang.String name) throws ServerError
Creates a proxy according to the servant definition for the given name. Injects the instance for this session so that all services are linked to a single session. Creates an ome.api.* service (mostly managed by Spring), wraps it with theinterceptors
which are in effect, and stores the instance away in the cache. Note: SinceHardWiredInterceptor
implementsMethodInterceptor
, all theAdvice
instances will be wrapped inAdvisor
instances and will be returned byAdvised.getAdvisors()
.- Throws:
ServerError
-
configureServant
public void configureServant(Ice.Object servant) throws ServerError
Apply proper AOP and call setters for any known injection properties.- Parameters:
servant
- the servant- Throws:
ServerError
- if the configuration or tying failed
-
registerServant
public Ice.ObjectPrx registerServant(Ice.Identity id, Ice.Object servant) throws ServerError
Registers the servant with the adapter (or throws an exception if one is already registered) as well as configures the servant in any post-Spring way necessary, based on the type of the servant.- Throws:
ServerError
-
registerServant
public Ice.ObjectPrx registerServant(Ice.Identity id, Ice.Object servant, Ice.Current current) throws ServerError
Additionally stores information from theCurrent
argument in theCallContext
so that information from the creation of a servant can be recorded server-side without the need for clients to re-send the information or even for values which clients should not know.- Throws:
ServerError
-
callContextWrapper
protected Ice.Object callContextWrapper(Ice.Object servant, Ice.Current current)
-
unregisterServant
public void unregisterServant(Ice.Identity id)
-
unregisterServant
public static void unregisterServant(Ice.Identity id, Ice.ObjectAdapter adapter, ServantHolder holder)
Reverts all the additions made byregisterServant(Ice.Identity, Ice.Object)
Now called bySessionManagerI
in response to anUnregisterServantMessage
.
-
getIdentity
public Ice.Identity getIdentity(java.lang.String name)
-
sessionId
public static Ice.Identity sessionId(java.lang.String clientId, java.lang.String uuid)
Definition of session ids:"session-<CLIENTID>/<UUID>"
-
sessionId
public Ice.Identity sessionId()
Returns theIdentity
for this instance as defined bysessionId(String, String)
-
clientId
public static java.lang.String clientId(Ice.Current current) throws ApiUsageException
Helpers method to extract theCLIENTUUID
out of the given Ice.Current. Throws anApiUsageException
if none is present, since it is each client's responsibility to set this value. (Typically done in our SDKs)- Throws:
ApiUsageException
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-