X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2Fcorlib%2FSystem.Runtime.Remoting%2FIdentity.cs;h=608798ccbabdbf1546c4cec75cad585a171985ae;hb=c9afd924fdbe70a69ab9960c379f280ecbb3a778;hp=18ecf79f9a5495a1e17b438966111fdd29b60271;hpb=0bd2c8daeae3a1ced9c9fbdbe2de25da37d70a62;p=mono.git diff --git a/mcs/class/corlib/System.Runtime.Remoting/Identity.cs b/mcs/class/corlib/System.Runtime.Remoting/Identity.cs index 18ecf79f9a5..608798ccbab 100644 --- a/mcs/class/corlib/System.Runtime.Remoting/Identity.cs +++ b/mcs/class/corlib/System.Runtime.Remoting/Identity.cs @@ -6,6 +6,29 @@ // (C) 2002, Lluis Sanchez Gual // +// +// Copyright (C) 2004 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + using System.Runtime.Remoting.Messaging; using System.Runtime.Remoting.Proxies; using System.Runtime.Remoting.Contexts; @@ -21,8 +44,6 @@ namespace System.Runtime.Remoting // and also to store server side information (information // about how to dispatch messages to the object in the server). - protected Type _objectType; - // URI of the object protected string _objectUri; @@ -36,11 +57,15 @@ namespace System.Runtime.Remoting // The ObjRef protected ObjRef _objRef; + + // This flag is set when the identity is removed from the uri table. + // It is needed because in some scenarios the runtime may try to + // dispose the identity twice. + bool _disposed = false; - public Identity(string objectUri, Type objectType) + public Identity(string objectUri) { _objectUri = objectUri; - _objectType = objectType; } public abstract ObjRef CreateObjRef (Type requestedType); @@ -64,11 +89,6 @@ namespace System.Runtime.Remoting get { return _envoySink; } } - public Type ObjectType - { - get { return _objectType; } - } - public string ObjectUri { get { return _objectUri; } @@ -79,6 +99,12 @@ namespace System.Runtime.Remoting { get { return _objectUri != null; } } + + public bool Disposed + { + get { return _disposed; } + set { _disposed = value; } + } public DynamicPropertyCollection ClientDynamicProperties { @@ -121,9 +147,9 @@ namespace System.Runtime.Remoting internal class ClientIdentity : Identity { - MarshalByRefObject _proxyObject; + WeakReference _proxyReference; - public ClientIdentity (string objectUri, ObjRef objRef): base (objectUri, Type.GetType (objRef.TypeInfo.TypeName,true)) + public ClientIdentity (string objectUri, ObjRef objRef): base (objectUri) { _objRef = objRef; _envoySink = (_objRef.EnvoyInfo != null) ? _objRef.EnvoyInfo.EnvoySinks : null; @@ -131,9 +157,9 @@ namespace System.Runtime.Remoting public MarshalByRefObject ClientProxy { - get { return _proxyObject; } - set { _proxyObject = value; } - } + get { return (MarshalByRefObject) _proxyReference.Target; } + set { _proxyReference = new WeakReference (value); } + } public override ObjRef CreateObjRef (Type requestedType) {