Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@@ -0,0 +1,78 @@
2009-05-06 Lluis Sanchez Gual <lluis@novell.com>
* Lease.cs: Don't use ArrayList.Remove() to remove sponsors because
it will end calling Equals, which may crash if the sponsor is not
available anymore. Just compare references.
2008-04-02 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
* ClientSponsor.cs: Fix parameter names
2006-01-31 Lluis Sanchez Gual <lluis@novell.com>
* Lease.cs: Fixed double check lock.
2004-06-07 Lluis Sanchez Gual <lluis@ximian.com>
* LeaseManager.cs: In StopManager, nullify the timer variable before
disposing, since Dispose may abort the current thread.
2003-12-10 Lluis Sanchez Gual <lluis@ximian.com>
* LifetimeServices.cs: Removed TODO.
2003-10-08 Lluis Sanchez Gual <lluis@ximian.com>
* ClientSponsor.cs: Improved implementation. Use Hashtable instead of
ArrayList for internal storage.
2003-08-14 Lluis Sanchez Gual <lluis@ximian.com>
* ClientSponsor.cs: Implemented.
2003-03-03 Lluis Sanchez Gual <lluis@ideary.com>
* LeaseManager.cs: Added method for removing an object from the lease manager.
* LifetimeServices.cs: Added method for removing an object from the lease manager.
2003-02-16 Lluis Sanchez Gual <lluis@ideary.com>
* LeaseSink.cs: small correction.
2003-02-04 Lluis Sanchez Gual <lluis@ideary.com>
* LifetimeServices.cs: Implemented all methods.
* LeaseSink.cs: implemented renewal of lease.
* Lease.cs: Added. It is an implementation of ILease.
* LeaseManager.cs: Added. Tracks lifetime of remote objects.
2003-01-29 Lluis Sanchez Gual <lluis@ideary.com>
* LifetimeServices.cs: Implemented some basic properties.
2002-12-20 Lluis Sanchez Gual <lsg@ctv.es>
* LeaseSink.cs: Added
2002-08-24 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* LifetimeServices.cs: the class is sealed.
2002-07-30 Duncan Mak <duncan@ximian.com>
* LeaseState.cs: Fixed namespace.
2002-07-29 Duncan Mak <duncan@ximian.com>
* ILease.cs: Add the method part of the interface and renamed the
CurrentState property to it proper name.
2002-07-24 Duncan Mak <duncan@ximian.com>
* LeaseState.cs: Moved here from System.Runtime.Remoting.
* ClientSponsor.cs:
* LifetimeServices.cs: Stubbed out
* ILease.cs:
* ISponsor.cs: Added to CVS.

View File

@@ -0,0 +1,108 @@
//
// System.Runtime.Remoting.Lifetime.ClientSponsor.cs
//
// Author: Duncan Mak (duncan@ximian.com)
// Lluis Sanchez Gual (lluis@ximian.com)
//
// 2002 (C) Copyright. Ximian, Inc.
//
//
// 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;
using System.Collections;
using System.Runtime.Remoting.Lifetime;
namespace System.Runtime.Remoting.Lifetime {
[System.Runtime.InteropServices.ComVisible (true)]
public class ClientSponsor : MarshalByRefObject, ISponsor
{
TimeSpan renewal_time;
Hashtable registered_objects = new Hashtable ();
public ClientSponsor ()
{
renewal_time = new TimeSpan (0, 2, 0); // default is 2 mins
}
public ClientSponsor (TimeSpan renewalTime)
{
renewal_time = renewalTime;
}
public TimeSpan RenewalTime {
get {
return renewal_time;
}
set {
renewal_time = value;
}
}
public void Close ()
{
foreach (MarshalByRefObject obj in registered_objects.Values)
{
ILease lease = obj.GetLifetimeService () as ILease;
lease.Unregister (this);
}
registered_objects.Clear ();
}
~ClientSponsor ()
{
Close ();
}
public override object InitializeLifetimeService ()
{
return base.InitializeLifetimeService ();
}
public bool Register (MarshalByRefObject obj)
{
if (registered_objects.ContainsKey (obj)) return false;
ILease lease = obj.GetLifetimeService () as ILease;
if (lease == null) return false;
lease.Register (this);
registered_objects.Add (obj,obj);
return true;
}
public TimeSpan Renewal (ILease lease)
{
return renewal_time;
}
public void Unregister (MarshalByRefObject obj)
{
if (!registered_objects.ContainsKey (obj)) return;
ILease lease = obj.GetLifetimeService () as ILease;
lease.Unregister (this);
registered_objects.Remove (obj);
}
}
}

View File

@@ -0,0 +1,51 @@
//
// System.Runtime.Remoting.Lifetime.ILease.cs
//
// Author: Duncan Mak (duncan@ximian.com)
//
// 2002 (C) Copyright. Ximian, Inc.
//
//
// 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;
using System.Runtime.Remoting.Lifetime;
namespace System.Runtime.Remoting.Lifetime {
[System.Runtime.InteropServices.ComVisible (true)]
public interface ILease
{
TimeSpan CurrentLeaseTime { get; }
LeaseState CurrentState { get; }
TimeSpan InitialLeaseTime { get; set; }
TimeSpan RenewOnCallTime { get; set; }
TimeSpan SponsorshipTimeout {get; set; }
void Register (ISponsor obj);
void Register (ISponsor obj, TimeSpan renewalTime);
TimeSpan Renew (TimeSpan renewalTime);
void Unregister (ISponsor obj);
}
}

View File

@@ -0,0 +1,42 @@
//
// System.Runtime.Remoting.Lifetime.ISponsor.cs
//
// Author: Duncan Mak (duncan@ximian.com)
//
// 2002 (C) Copyright. Ximian, Inc.
//
//
// 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;
using System.Runtime.Remoting.Lifetime;
namespace System.Runtime.Remoting.Lifetime {
[System.Runtime.InteropServices.ComVisible (true)]
public interface ISponsor
{
TimeSpan Renewal (ILease lease);
}
}

View File

@@ -0,0 +1,215 @@
//
// System.Runtime.Remoting.Identity.cs
//
// Author: Lluis Sanchez Gual (lluis@ideary.com)
//
// (C) 2003, 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;
using System.Threading;
using System.Collections;
namespace System.Runtime.Remoting.Lifetime
{
internal class Lease : MarshalByRefObject, ILease
{
DateTime _leaseExpireTime;
LeaseState _currentState;
TimeSpan _initialLeaseTime;
TimeSpan _renewOnCallTime;
TimeSpan _sponsorshipTimeout;
ArrayList _sponsors;
Queue _renewingSponsors;
RenewalDelegate _renewalDelegate;
delegate TimeSpan RenewalDelegate(ILease lease);
public Lease()
{
_currentState = LeaseState.Initial;
_initialLeaseTime = LifetimeServices.LeaseTime;
_renewOnCallTime = LifetimeServices.RenewOnCallTime;
_sponsorshipTimeout = LifetimeServices.SponsorshipTimeout;
_leaseExpireTime = DateTime.Now + _initialLeaseTime;
}
public TimeSpan CurrentLeaseTime
{
get { return _leaseExpireTime - DateTime.Now; }
}
public LeaseState CurrentState
{
get { return _currentState; }
}
public void Activate()
{
// Called when then Lease is registered in the LeaseManager
_currentState = LeaseState.Active;
}
public TimeSpan InitialLeaseTime
{
get { return _initialLeaseTime; }
set
{
if (_currentState != LeaseState.Initial)
throw new RemotingException ("InitialLeaseTime property can only be set when the lease is in initial state; state is " + _currentState + ".");
_initialLeaseTime = value;
_leaseExpireTime = DateTime.Now + _initialLeaseTime;
if (value == TimeSpan.Zero) _currentState = LeaseState.Null;
}
}
public TimeSpan RenewOnCallTime
{
get { return _renewOnCallTime; }
set
{
if (_currentState != LeaseState.Initial)
throw new RemotingException ("RenewOnCallTime property can only be set when the lease is in initial state; state is " + _currentState + ".");
_renewOnCallTime = value;
}
}
public TimeSpan SponsorshipTimeout
{
get { return _sponsorshipTimeout; }
set
{
if (_currentState != LeaseState.Initial)
throw new RemotingException ("SponsorshipTimeout property can only be set when the lease is in initial state; state is " + _currentState + ".");
_sponsorshipTimeout = value;
}
}
public void Register (ISponsor obj)
{
Register (obj, TimeSpan.Zero);
}
public void Register (ISponsor obj, TimeSpan renewalTime)
{
lock (this) {
if (_sponsors == null)
_sponsors = new ArrayList();
_sponsors.Add (obj);
}
if (renewalTime != TimeSpan.Zero)
Renew (renewalTime);
}
public TimeSpan Renew (TimeSpan renewalTime)
{
DateTime newTime = DateTime.Now + renewalTime;
if (newTime > _leaseExpireTime) _leaseExpireTime = newTime;
return CurrentLeaseTime;
}
public void Unregister (ISponsor obj)
{
lock (this) {
if (_sponsors == null) return;
// Don't use ArrayList.Remove() here because it will end calling Equals, which may
// crash if the sponsor is not available anymore
for (int n=0; n < _sponsors.Count; n++) {
if (object.ReferenceEquals (_sponsors [n], obj)) {
_sponsors.RemoveAt (n);
break;
}
}
}
}
internal void UpdateState ()
{
// Called by the lease manager to update the state of this lease,
// basically for knowing if it has expired
if (_currentState != LeaseState.Active) return;
if (CurrentLeaseTime > TimeSpan.Zero) return;
// Expired. Try to renew using sponsors.
if (_sponsors != null)
{
_currentState = LeaseState.Renewing;
lock (this) {
_renewingSponsors = new Queue (_sponsors);
}
CheckNextSponsor ();
}
else
_currentState = LeaseState.Expired;
}
void CheckNextSponsor ()
{
if (_renewingSponsors.Count == 0) {
_currentState = LeaseState.Expired;
_renewingSponsors = null;
return;
}
ISponsor nextSponsor = (ISponsor) _renewingSponsors.Peek();
_renewalDelegate = new RenewalDelegate (nextSponsor.Renewal);
IAsyncResult ar = _renewalDelegate.BeginInvoke (this, null, null);
ThreadPool.RegisterWaitForSingleObject (ar.AsyncWaitHandle, new WaitOrTimerCallback (ProcessSponsorResponse), ar, _sponsorshipTimeout, true);
}
void ProcessSponsorResponse (object state, bool timedOut)
{
if (!timedOut)
{
try
{
IAsyncResult ar = (IAsyncResult)state;
TimeSpan newSpan = _renewalDelegate.EndInvoke (ar);
if (newSpan != TimeSpan.Zero)
{
Renew (newSpan);
_currentState = LeaseState.Active;
_renewingSponsors = null;
return;
}
}
catch { }
}
// Sponsor failed, timed out, or returned TimeSpan.Zero
Unregister ((ISponsor) _renewingSponsors.Dequeue()); // Drop the sponsor
CheckNextSponsor ();
}
}
}

View File

@@ -0,0 +1,107 @@
//
// System.Runtime.Remoting.Identity.cs
//
// Author: Lluis Sanchez Gual (lluis@ideary.com)
//
// (C) 2003, 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;
using System.Threading;
using System.Collections;
using System.Runtime.Remoting;
namespace System.Runtime.Remoting.Lifetime
{
internal class LeaseManager
{
ArrayList _objects = new ArrayList();
Timer _timer = null;
public void SetPollTime (TimeSpan timeSpan)
{
lock (_objects.SyncRoot)
{
if (_timer != null)
_timer.Change (timeSpan,timeSpan);
}
}
public void TrackLifetime (ServerIdentity identity)
{
lock (_objects.SyncRoot)
{
identity.Lease.Activate();
_objects.Add (identity);
if (_timer == null) StartManager();
}
}
public void StopTrackingLifetime (ServerIdentity identity)
{
lock (_objects.SyncRoot)
{
_objects.Remove (identity);
}
}
public void StartManager()
{
_timer = new Timer (new TimerCallback (ManageLeases), null, LifetimeServices.LeaseManagerPollTime,LifetimeServices.LeaseManagerPollTime);
}
public void StopManager()
{
Timer t = _timer;
_timer = null;
t.Dispose();
}
public void ManageLeases(object state)
{
lock (_objects.SyncRoot)
{
int n=0;
while (n < _objects.Count)
{
ServerIdentity ident = (ServerIdentity)_objects[n];
ident.Lease.UpdateState();
if (ident.Lease.CurrentState == LeaseState.Expired)
{
_objects.RemoveAt (n);
ident.OnLifetimeExpired ();
}
else
n++;
}
if (_objects.Count == 0)
StopManager();
}
}
}
}

View File

@@ -0,0 +1,75 @@
//
// System.Runtime.Remoting.LeaseSink.cs
//
// Author: Lluis Sanchez Gual (lluis@ideary.com)
//
// (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;
using System.Runtime.Remoting.Messaging;
namespace System.Runtime.Remoting.Lifetime
{
// This sink updates lifetime information
// about an object
internal class LeaseSink: IMessageSink
{
IMessageSink _nextSink;
public LeaseSink (IMessageSink nextSink)
{
_nextSink = nextSink;
}
public IMessage SyncProcessMessage (IMessage msg)
{
RenewLease (msg);
return _nextSink.SyncProcessMessage (msg);
}
public IMessageCtrl AsyncProcessMessage (IMessage msg, IMessageSink replySink)
{
RenewLease (msg);
return _nextSink.AsyncProcessMessage (msg, replySink);
}
void RenewLease (IMessage msg)
{
ServerIdentity identity = (ServerIdentity) RemotingServices.GetMessageTargetIdentity (msg);
ILease lease = identity.Lease;
if (lease != null && lease.CurrentLeaseTime < lease.RenewOnCallTime)
lease.Renew (lease.RenewOnCallTime);
}
public IMessageSink NextSink
{
get { return _nextSink; }
}
}
}

View File

@@ -0,0 +1,66 @@
// LeaseState.cs
//
// This code was automatically generated from
// ECMA CLI XML Library Specification.
// Generator: libgen.xsl [1.0; (C) Sergey Chaban (serge@wildwestsoftware.com)]
// Created: Wed, 5 Sep 2001 06:40:41 UTC
// Source file: all.xml
// URL: http://devresource.hp.com/devresource/Docs/TechPapers/CSharp/all.xml
//
// (C) 2001 Ximian, Inc. http://www.ximian.com
//
// 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.
//
namespace System.Runtime.Remoting.Lifetime {
/// <summary>
/// </summary>
[System.Runtime.InteropServices.ComVisible (true)]
[Serializable]
public enum LeaseState {
/// <summary>
/// </summary>
Null = 0,
/// <summary>
/// </summary>
Initial = 1,
/// <summary>
/// </summary>
Active = 2,
/// <summary>
/// </summary>
Renewing = 3,
/// <summary>
/// </summary>
Expired = 4,
} // LeaseState
} // System.Runtime.Remoting.Lifetime

View File

@@ -0,0 +1,101 @@
//
// System.Runtime.Remoting.Lifetime.LifetimeServices.cs
//
// Author: Duncan Mak (duncan@ximian.com)
// Lluis Sanchez Gual (lluis@ideary.com)
//
// 2002 (C) Copyright. Ximian, Inc.
//
//
// 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;
namespace System.Runtime.Remoting.Lifetime {
//LAMESPEC: MS docs don't say that this class is sealed.
[System.Runtime.InteropServices.ComVisible (true)]
public sealed class LifetimeServices
{
private static TimeSpan _leaseManagerPollTime;
private static TimeSpan _leaseTime;
private static TimeSpan _renewOnCallTime;
private static TimeSpan _sponsorshipTimeout;
private static LeaseManager _leaseManager = new LeaseManager();
static LifetimeServices ()
{
_leaseManagerPollTime = TimeSpan.FromSeconds (10);
_leaseTime = TimeSpan.FromMinutes (5);
_renewOnCallTime = TimeSpan.FromMinutes (2);
_sponsorshipTimeout = TimeSpan.FromMinutes (2);
}
#if NET_4_0
[Obsolete("Call the static methods directly on this type instead", true)]
#endif
public LifetimeServices ()
{
}
public static TimeSpan LeaseManagerPollTime
{
get { return _leaseManagerPollTime; }
set {
_leaseManagerPollTime = value;
_leaseManager.SetPollTime (value);
}
}
public static TimeSpan LeaseTime
{
get { return _leaseTime; }
set { _leaseTime = value; }
}
public static TimeSpan RenewOnCallTime
{
get { return _renewOnCallTime; }
set { _renewOnCallTime = value; }
}
public static TimeSpan SponsorshipTimeout
{
get { return _sponsorshipTimeout; }
set { _sponsorshipTimeout = value; }
}
internal static void TrackLifetime (ServerIdentity identity)
{
_leaseManager.TrackLifetime (identity);
}
internal static void StopTrackingLifetime (ServerIdentity identity)
{
_leaseManager.StopTrackingLifetime (identity);
}
}
}