Beispiel #1
0
        // TODO: @cleanup: Move to ServicedComponentProxy
        private static void ReconnectForPooling(ServicedComponentProxy scp)
        {
            Type         serverType        = scp.GetProxiedType();
            bool         fIsJitActivated   = scp.IsJitActivated;
            bool         fIsTypePooled     = scp.IsObjectPooled;
            bool         fAreMethodsSecure = scp.AreMethodsSecure;
            ProxyTearoff tearoff           = null;

            DBG.Assert(fIsTypePooled == true, "CS.ReconnectForPooling called on a non-pooled proxy!");

            DBG.Info(DBG.SC, "CS.ReconnectForPooling (type is pooled) " + serverType);
            ServicedComponent server = scp.DisconnectForPooling(ref tearoff);

            // now setup a new SCP that we can add to the pool
            // with the current server object and the CCW
            ServicedComponentProxy newscp = new ServicedComponentProxy(serverType, fIsJitActivated, fIsTypePooled, fAreMethodsSecure, false);

            DBG.Info(DBG.SC, "CS.ReconnectForPooling (calling newscp.ConnectForPooling)");
            newscp.ConnectForPooling(scp, server, tearoff, false);
            // switch the CCW from oldtp to new tp

            DBG.Info(DBG.SC, "CS.ReconnectForPooling (SwitchingWrappers)");
            EnterpriseServicesHelper.SwitchWrappers(scp, newscp);

            // Strengthen the CCW:  The only reference now held is
            // the reference from the pool.
            if (tearoff != null)
            {
                Marshal.ChangeWrapperHandleStrength(tearoff, false);
            }
            Marshal.ChangeWrapperHandleStrength(newscp.GetTransparentProxy(), false);
        }
Beispiel #2
0
        private static void ReconnectForPooling(ServicedComponentProxy scp)
        {
            Type                   proxiedType      = scp.GetProxiedType();
            bool                   isJitActivated   = scp.IsJitActivated;
            bool                   isObjectPooled   = scp.IsObjectPooled;
            bool                   areMethodsSecure = scp.AreMethodsSecure;
            ProxyTearoff           proxyTearoff     = null;
            ServicedComponent      server           = scp.DisconnectForPooling(ref proxyTearoff);
            ServicedComponentProxy newcp            = new ServicedComponentProxy(proxiedType, isJitActivated, isObjectPooled, areMethodsSecure, false);

            newcp.ConnectForPooling(scp, server, proxyTearoff, false);
            EnterpriseServicesHelper.SwitchWrappers(scp, newcp);
            if (proxyTearoff != null)
            {
                Marshal.ChangeWrapperHandleStrength(proxyTearoff, false);
            }
            Marshal.ChangeWrapperHandleStrength(newcp.GetTransparentProxy(), false);
        }
        internal void ActivateObject()
        {
            IntPtr currentContextToken = Proxy.GetCurrentContextToken();

            if ((this.IsObjectPooled && this.IsJitActivated) && (this.HomeToken != currentContextToken))
            {
                object obj2 = IdentityTable.FindObject(currentContextToken);
                if (obj2 != null)
                {
                    ServicedComponentProxy realProxy    = (ServicedComponentProxy)RemotingServices.GetRealProxy(obj2);
                    ProxyTearoff           proxyTearoff = null;
                    ServicedComponent      server       = this.DisconnectForPooling(ref proxyTearoff);
                    proxyTearoff.SetCanBePooled(false);
                    realProxy.ConnectForPooling(this, server, proxyTearoff, true);
                    EnterpriseServicesHelper.SwitchWrappers(this, realProxy);
                    realProxy.ActivateProxy();
                    return;
                }
            }
            this.ActivateProxy();
        }
 private static void ReconnectForPooling(ServicedComponentProxy scp)
 {
     Type proxiedType = scp.GetProxiedType();
     bool isJitActivated = scp.IsJitActivated;
     bool isObjectPooled = scp.IsObjectPooled;
     bool areMethodsSecure = scp.AreMethodsSecure;
     ProxyTearoff proxyTearoff = null;
     ServicedComponent server = scp.DisconnectForPooling(ref proxyTearoff);
     ServicedComponentProxy newcp = new ServicedComponentProxy(proxiedType, isJitActivated, isObjectPooled, areMethodsSecure, false);
     newcp.ConnectForPooling(scp, server, proxyTearoff, false);
     EnterpriseServicesHelper.SwitchWrappers(scp, newcp);
     if (proxyTearoff != null)
     {
         Marshal.ChangeWrapperHandleStrength(proxyTearoff, false);
     }
     Marshal.ChangeWrapperHandleStrength(newcp.GetTransparentProxy(), false);
 }