예제 #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);
        }
 internal ServicedComponent DisconnectForPooling(ref ProxyTearoff proxyTearoff)
 {
     if (this._fIsServerActivated)
     {
         this.DispatchDeactivate();
     }
     proxyTearoff       = this._proxyTearoff;
     this._proxyTearoff = null;
     if (base.GetUnwrappedServer() != null)
     {
         return((ServicedComponent)base.DetachServer());
     }
     return(null);
 }
 internal ProxyTearoff GetProxyTearoff()
 {
     if (this._proxyTearoff == null)
     {
         if (Util.ExtendedLifetime)
         {
             this._proxyTearoff = new WeakProxyTearoff();
         }
         else
         {
             this._proxyTearoff = new ClassicProxyTearoff();
         }
         this._proxyTearoff.Init(this);
     }
     return(this._proxyTearoff);
 }
예제 #4
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 ConnectForPooling(ServicedComponentProxy oldscp, ServicedComponent server, ProxyTearoff proxyTearoff, bool fForJit)
 {
     if (oldscp != null)
     {
         this._fReturnedByFinalizer = oldscp._fFinalized;
         if (fForJit)
         {
             this._pPoolUnk   = oldscp._pPoolUnk;
             oldscp._pPoolUnk = IntPtr.Zero;
         }
     }
     if (server != null)
     {
         base.AttachServer(server);
     }
     this._proxyTearoff = proxyTearoff;
     this._proxyTearoff.Init(this);
 }
        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();
        }