Package omero.cmd

Class SessionI

    • 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)  
    • 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
      • 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,
                                 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 interface Glacier2._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 other ServiceFactoryI instances in the same Session. Since destroy(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 a SessionException . See destroy(Current) for more information. When destroy(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 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 the interceptors which are in effect, and stores the instance away in the cache. Note: Since HardWiredInterceptor implements MethodInterceptor, all the Advice instances will be wrapped in Advisor instances and will be returned by Advised.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 the Current argument in the CallContext 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)
      • 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>"
      • clientId

        public static java.lang.String clientId​(Ice.Current current)
                                         throws ApiUsageException
        Helpers method to extract the CLIENTUUID out of the given Ice.Current. Throws an ApiUsageException 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 class java.lang.Object