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.ObjectAdapteradapterprotected ClientCallbackPrxcallbackjava.lang.StringclientIdome.system.OmeroContextcontextGlacier2.SessionControlPrxcontrolprotected booleandoCloseome.services.util.ExecutorexecutorExecutorto be used by servant implementations which do not delegate to the server package where all instances are wrapped with AOP for dealing with Hibernate.ServantHolderholderome.system.Principalprincipalprotected java.util.concurrent.atomic.AtomicBooleanreusedSessionome.services.sessions.SessionManagersessionManagerjava.lang.StringtokenToken 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 voidallow(Ice.ObjectPrx prx)protected Ice.ObjectcallContextWrapper(Ice.Object servant, Ice.Current current)voidcleanServants(boolean all)UsecleanServants(boolean, String, ServantHolder, Ice.ObjectAdapter)to clean up.static voidcleanServants(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.voidcleanupSelf()Called if this isn't a kill-everything event.static java.lang.StringclientId(Ice.Current current)Helpers method to extract theCLIENTUUIDout of the given Ice.Current.voidconfigureServant(Ice.Object servant)Apply proper AOP and call setters for any known injection properties.protected Ice.ObjectcreateServantDelegate(java.lang.String name)Creates a proxy according to the servant definition for the given name.voiddestroy(Ice.Current current)Destruction simply decrements the reference count for a session to allow reconnecting to it.voiddoDestroy()Performs the actual cleanup operation on all the resources shared between this and otherServiceFactoryIinstances in the sameSession.Ice.ObjectAdaptergetAdapter()ome.services.util.ExecutorgetExecutor()Ice.IdentitygetIdentity(java.lang.String name)ome.system.PrincipalgetPrincipal()voidhandleCallbackException(java.lang.Exception e)Reusable method for logging an exception that occurs on one-way communication with clients during callback notification.protected voidinternalServantConfig(java.lang.Object obj)Ice.CurrentnewCurrent(Ice.Identity id, java.lang.String method)static Ice.CurrentnewCurrent(Ice.Identity id, java.lang.String method, Ice.ObjectAdapter adapter, java.lang.String clientId)Ice.ObjectPrxregisterServant(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.ObjectPrxregisterServant(Ice.Identity id, Ice.Object servant, Ice.Current current)Additionally stores information from theCurrentargument in theCallContextso 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.IdentitysessionId()Returns theIdentityfor this instance as defined bysessionId(String, String)static Ice.IdentitysessionId(java.lang.String clientId, java.lang.String uuid)Definition of session ids:"session-<CLIENTID>/<UUID>"voidsubmit_async(AMD_Session_submit __cb, Request req, Ice.Current current)voidsubmit_async(AMD_Session_submit __cb, Request req, Ice.Current current, ome.services.util.Executor.Priority priority)java.lang.StringtoString()voidunregisterServant(Ice.Identity id)static voidunregisterServant(Ice.Identity id, Ice.ObjectAdapter adapter, ServantHolder holder)Reverts all the additions made byregisterServant(Ice.Identity, Ice.Object)Now called bySessionManagerIin 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
Executorto 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_asyncin 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:
destroyin 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 otherServiceFactoryIinstances 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-ServantHolderto 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 ServerErrorCreates 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 theinterceptorswhich are in effect, and stores the instance away in the cache. Note: SinceHardWiredInterceptorimplementsMethodInterceptor, all theAdviceinstances will be wrapped inAdvisorinstances and will be returned byAdvised.getAdvisors().- Throws:
ServerError
-
configureServant
public void configureServant(Ice.Object servant) throws ServerErrorApply 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 ServerErrorRegisters 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 ServerErrorAdditionally stores information from theCurrentargument in theCallContextso 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 bySessionManagerIin 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 theIdentityfor this instance as defined bysessionId(String, String)
-
clientId
public static java.lang.String clientId(Ice.Current current) throws ApiUsageExceptionHelpers method to extract theCLIENTUUIDout of the given Ice.Current. Throws anApiUsageExceptionif 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:
toStringin classjava.lang.Object
-
-