Exemple #1
0
        ///<summary>
        /// IProxyInvocationHandler method that gets called from within the proxy
        /// instance.
        ///</summary>
        ///<param name="proxy">Instance of proxy</param>
        ///<param name="method">Method instance
        public Object Invoke(Object proxy, System.Reflection.MethodInfo method, Object[] parameters)
        {
            Object retVal   = null;
            string userRole = "role";

            // if the user has permission to invoke the method, the method
            // is invoked, otherwise an exception is thrown indicating they
            // do not have permission
            if (DynamicProxy.SecurityManager.IsMethodInRole(userRole, method.Name))
            {
                // The actual method is invoked
                //retVal = method.Invoke(_mServiceImpl, parameters);

                var producerExecutor = this;
                int sessionId        = _fetchSessionId();
                // enqueue TRequest to queue
                MethodContext mContext = new MethodContext(_objServiceImpl, method, parameters);
                producerExecutor.enqueueRequest(sessionId, mContext);
                mContext._mConsumerResetEvent.WaitOne();
                // waiting for release by producer
                // get result from MethodContext
                retVal = mContext.getResult();
                var map = (IDictionary <int, MethodContext>)_mSessionId2MethodContext;
                map.Remove(sessionId);
            }
            else
            {
                throw new Exception("Invalid permission to invoke " + method.Name);
            }

            return(retVal);
        }
Exemple #2
0
        Object getResponse(int sessionId)
        {
            MethodContext methodContext = _mSessionId2MethodContext[sessionId];

            return(methodContext.getResult());
        }