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,231 @@
//
// System.Runtime.Remoting.ActivationServices.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.Threading;
using System.Runtime.Remoting.Messaging;
using System.Runtime.Remoting.Activation;
using System.Runtime.Remoting.Contexts;
using System.Runtime.Remoting.Proxies;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Collections;
using System.Runtime.Remoting.Channels;
namespace System.Runtime.Remoting.Activation
{
internal class ActivationServices
{
static IActivator _constructionActivator;
static IActivator ConstructionActivator {
get {
if (_constructionActivator == null)
_constructionActivator = new ConstructionLevelActivator ();
return _constructionActivator;
}
}
public static IMessage Activate (RemotingProxy proxy, ConstructionCall ctorCall)
{
IMessage response;
ctorCall.SourceProxy = proxy;
if (Thread.CurrentContext.HasExitSinks && !ctorCall.IsContextOk)
response = Thread.CurrentContext.GetClientContextSinkChain ().SyncProcessMessage (ctorCall);
else
response = RemoteActivate (ctorCall);
if (response is IConstructionReturnMessage && ((IConstructionReturnMessage)response).Exception == null && proxy.ObjectIdentity == null)
{
Identity identity = RemotingServices.GetMessageTargetIdentity (ctorCall);
proxy.AttachIdentity (identity);
}
return response;
}
public static IMessage RemoteActivate (IConstructionCallMessage ctorCall)
{
try
{
return ctorCall.Activator.Activate (ctorCall);
}
catch (Exception ex)
{
return new ReturnMessage (ex, ctorCall);
}
}
public static object CreateProxyFromAttributes (Type type, object[] activationAttributes)
{
string activationUrl = null;
foreach (object attr in activationAttributes)
{
if (!(attr is IContextAttribute)) throw new RemotingException ("Activation attribute does not implement the IContextAttribute interface");
if (attr is UrlAttribute) activationUrl = ((UrlAttribute)attr).UrlValue;
}
if (activationUrl != null)
return RemotingServices.CreateClientProxy (type, activationUrl, activationAttributes);
ActivatedClientTypeEntry activatedEntry = RemotingConfiguration.IsRemotelyActivatedClientType (type);
if (activatedEntry != null)
return RemotingServices.CreateClientProxy (activatedEntry, activationAttributes);
if (type.IsContextful)
return RemotingServices.CreateClientProxyForContextBound (type, activationAttributes);
return null;
}
public static ConstructionCall CreateConstructionCall (Type type, string activationUrl, object[] activationAttributes)
{
ConstructionCall ctorCall = new ConstructionCall (type);
if (!type.IsContextful)
{
// Must be a remote activated object
ctorCall.Activator = new AppDomainLevelActivator (activationUrl, ConstructionActivator);
ctorCall.IsContextOk = false; // It'll be activated in a remote context
return ctorCall;
}
// It is a CBO. Need collect context properties and
// check if a new context is needed.
IActivator activatorChain = ConstructionActivator;
activatorChain = new ContextLevelActivator (activatorChain);
ArrayList attributes = new ArrayList ();
if (activationAttributes != null) attributes.AddRange (activationAttributes);
bool isContextOk = (activationUrl == ChannelServices.CrossContextUrl); // Remote CBOs are always created in a new context
Context currentContext = Threading.Thread.CurrentContext;
if (isContextOk)
{
foreach (IContextAttribute attr in attributes)
{
if (!attr.IsContextOK (currentContext, ctorCall))
{
isContextOk = false;
break;
}
}
}
object[] typeAttributes = type.GetCustomAttributes (true);
foreach (object attr in typeAttributes)
{
if (attr is IContextAttribute)
{
isContextOk = isContextOk && ((IContextAttribute)attr).IsContextOK (currentContext, ctorCall);
attributes.Add (attr);
}
}
if (!isContextOk)
{
// A new context is needed. Collect the context properties and chain
// the context level activator.
ctorCall.SetActivationAttributes (attributes.ToArray());
foreach (IContextAttribute attr in attributes)
attr.GetPropertiesForNewContext (ctorCall);
}
if (activationUrl != ChannelServices.CrossContextUrl)
activatorChain = new AppDomainLevelActivator (activationUrl, activatorChain);
ctorCall.Activator = activatorChain;
ctorCall.IsContextOk = isContextOk;
return ctorCall;
}
public static IMessage CreateInstanceFromMessage (IConstructionCallMessage ctorCall)
{
object obj = AllocateUninitializedClassInstance (ctorCall.ActivationType);
ServerIdentity identity = (ServerIdentity) RemotingServices.GetMessageTargetIdentity (ctorCall);
identity.AttachServerObject ((MarshalByRefObject) obj, Threading.Thread.CurrentContext);
ConstructionCall call = ctorCall as ConstructionCall;
if (ctorCall.ActivationType.IsContextful && call != null && call.SourceProxy != null)
{
call.SourceProxy.AttachIdentity (identity);
MarshalByRefObject target = (MarshalByRefObject) call.SourceProxy.GetTransparentProxy ();
RemotingServices.InternalExecuteMessage (target, ctorCall);
}
else
ctorCall.MethodBase.Invoke (obj, ctorCall.Args);
return new ConstructionResponse (obj, null, ctorCall);
}
public static object CreateProxyForType (Type type)
{
// Called by the runtime when creating an instance of a type
// that has been registered as remotely activated.
// First of all check for remote activation. If the object is not remote, then
// it may be contextbound.
ActivatedClientTypeEntry activatedEntry = RemotingConfiguration.IsRemotelyActivatedClientType (type);
if (activatedEntry != null)
return RemotingServices.CreateClientProxy (activatedEntry, null);
WellKnownClientTypeEntry wellknownEntry = RemotingConfiguration.IsWellKnownClientType (type);
if (wellknownEntry != null)
return RemotingServices.CreateClientProxy (wellknownEntry);
if (type.IsContextful)
return RemotingServices.CreateClientProxyForContextBound (type, null);
#if !NET_2_1
if (type.IsCOMObject) {
return RemotingServices.CreateClientProxyForComInterop (type);
}
#endif
return null;
}
// Allocates an uninitialized instance. It never creates proxies.
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public static extern object AllocateUninitializedClassInstance (Type type);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern static void EnableProxyActivation (Type type, bool enable);
}
}

View File

@@ -0,0 +1,44 @@
//
// System.Runtime.Remoting.Contexts.ActivatorLevel..cs
//
// Author:
// Miguel de Icaza (miguel@ximian.com)
//
// (C) 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.Activation {
[System.Runtime.InteropServices.ComVisible (true)]
[System.Serializable]
public enum ActivatorLevel {
Construction = 4,
Context = 8,
AppDomain = 12,
Process = 16,
Machine = 20,
}
}

View File

@@ -0,0 +1,92 @@
//
// System.Runtime.Remoting.Activation.AppDomainLevelActivator.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.Runtime.Remoting.Messaging;
namespace System.Runtime.Remoting.Activation
{
internal class AppDomainLevelActivator: IActivator
{
string _activationUrl;
IActivator _next;
public AppDomainLevelActivator(string activationUrl, IActivator next)
{
_activationUrl = activationUrl;
_next = next;
}
public ActivatorLevel Level
{
get { return ActivatorLevel.AppDomain; }
}
public IActivator NextActivator
{
get { return _next; }
set { _next = value; }
}
public IConstructionReturnMessage Activate (IConstructionCallMessage ctorCall)
{
IConstructionReturnMessage response;
// Create the object by calling the remote activation service
IActivator remoteActivator = (IActivator) RemotingServices.Connect (typeof (IActivator), _activationUrl);
ctorCall.Activator = ctorCall.Activator.NextActivator;
try
{
response = remoteActivator.Activate (ctorCall);
}
catch (Exception ex)
{
return new ConstructionResponse (ex, ctorCall);
}
// Create the client identity for the remote object
ObjRef objRef = (ObjRef) response.ReturnValue;
if (RemotingServices.GetIdentityForUri (objRef.URI) != null)
throw new RemotingException("Inconsistent state during activation; there may be two proxies for the same object");
object proxy;
// We pass null for proxyType because we don't really to attach the identity
// to a proxy, we already have one.
Identity identity = RemotingServices.GetOrCreateClientIdentity (objRef, null, out proxy);
RemotingServices.SetMessageTargetIdentity (ctorCall, identity);
return response;
}
}
}

View File

@@ -0,0 +1,93 @@
2009-10-29 Jb Evain <jbevain@novell.com>
* ActivationServices.cs: avoid a static constructor.
2009-09-18 Sebastien Pouliot <sebastien@ximian.com>
* ActivationServices.cs: Avoid depending on COM stuff for NET_2_1
2007-08-15 Atsushi Enomoto <atsushi@ximian.com>
* ActivatorLevel.cs UrlAttribute.cs : [ComVisible], [Serializable].
2006-08-09 Jonathan Chambers <joncham@gmail.com>
* ActivationServices.cs: Check type.IsCOMObject rather than type.IsImport.
2006-07-15 Jonathan Chambers <joncham@gmail.com>
* ActivationServices.cs: Begin implementing COM Interop.
2004-09-22 Lluis Sanchez Gual <lluis@novell.com>
* ActivationServices.cs: In Activate, assign the proxy to the ctor
message. In CreateInstanceFromMessage if the object being created
is a CBO, use the provided proxy as "this" when calling the ctor.
2003-12-23 Lluis Sanchez Gual <lluis@ximian.com>
* ActivationServices.cs: If remote activation returns an exception, do not
try to attach the object identity to the return message.
* AppDomainLevelActivator.cs: Catch exceptions when execution remote
activation.
* ConstructionLevelActivator.cs: Do not store next activator. This is
always the last one.
* ContextLevelActivator.cs: Renamed _next member to match MS.NET
implementation.
2003-10-18 Lluis Sanchez Gual <lluis@ximian.com>
* ActivationServices.cs: make AllocateUninitializedClassInstance public,
so it can be reused.
2003-10-08 Lluis Sanchez Gual <lluis@ximian.com>
* AppDomainLevelActivator.cs: little fix.
2003-08-14 Lluis Sanchez Gual <lluis@ximian.com>
* AppDomainLevelActivator.cs, ConstructionLevelActivator.cs,
ContextLevelActivator.cs, RemoteActivationAttribute.cs,
RemoteActivator.cs: Changed class from public to internal.
2003-03-21 Lluis Sanchez Gual <lluis@ideary.com>
* ActivationServices.cs: Added the method Activate that performs the forwards the
creation message to the right message sink. Added support for AppDomainLevelActivator.
* ConstructionLevelActivator.cs: Activate does not use the object identity because
it may not be set yet.
* ContextLevelActivator.cs: this activator is now always called for CBOs. A new context
has to be created only if the construction message says so.
* AppDomainLevelActivator.cs: Added. Implements an IActivator that makes a remote creation.
2003-02-25 Lluis Sanchez Gual <lluis@ideary.com>
* ActivationServices.cs: Added method for creating a proxy from a list
of activation attributes. This is used by System.Activator.
Added method for creating a ConstructionCall from a list of activation attributes.
This is used from RemotingProxy.
* ConstructionLevelActivator.cs: Added. Implements an IActivator that constructs an object.
* ContextLevelActivator.cs: Added. Implements an IActivator that constructs a context.
* RemoteActivationAttribute.cs: Added.
* RemoteActivator.cs: Used RemoteActivationAttribute in the creation of the server object.
* UrlAttribute.cs: Removed some "throw new NotImplementedException ()".
2003-02-18 Lluis Sanchez Gual <lluis@ideary.com>
* RemoteActivator.cs: Instance creation implemented.
* ActivationServices.cs: Added.
2003-01-29 Lluis Sanchez Gual <lluis@ideary.com>
* RemoteActivator.cs: Added.
2002-12-06 Duncan Mak <duncan@ximian.com>
* UrlAttribute.cs (GetHashCode): Implemented.
2002-07-24 Duncan Mak <duncan@ximian.com>
* System.Runtime.Remoting.Activation/UrlAttribute.cs: Add to CVS.
* System.Runtime.Remoting.Activation/IConstructionCallMessage.cs:
This implements IMessage, IMethodCallMessage and IMethodMessage.

View File

@@ -0,0 +1,57 @@
//
// System.Runtime.Remoting.Activation.ConstructionLevelActivator.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.Runtime.Remoting.Messaging;
namespace System.Runtime.Remoting.Activation
{
[Serializable]
internal class ConstructionLevelActivator: IActivator
{
public ActivatorLevel Level
{
get { return ActivatorLevel.Construction; }
}
public IActivator NextActivator
{
get { return null; }
set { ; }
}
public IConstructionReturnMessage Activate (IConstructionCallMessage msg)
{
// The StackBuilderSink at the end of the server context sink chain will do the job
return (IConstructionReturnMessage) Threading.Thread.CurrentContext.GetServerContextSinkChain().SyncProcessMessage (msg);
}
}
}

View File

@@ -0,0 +1,83 @@
//
// System.Runtime.Remoting.Activation.ContextLevelActivator.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.Runtime.Remoting.Messaging;
using System.Runtime.Remoting.Contexts;
namespace System.Runtime.Remoting.Activation
{
[Serializable]
internal class ContextLevelActivator: IActivator
{
IActivator m_NextActivator;
public ContextLevelActivator (IActivator next)
{
m_NextActivator = next;
}
public ActivatorLevel Level
{
get { return ActivatorLevel.Context; }
}
public IActivator NextActivator
{
get { return m_NextActivator; }
set { m_NextActivator = value; }
}
public IConstructionReturnMessage Activate (IConstructionCallMessage ctorCall)
{
ServerIdentity identity = RemotingServices.CreateContextBoundObjectIdentity (ctorCall.ActivationType);
RemotingServices.SetMessageTargetIdentity (ctorCall, identity);
ConstructionCall call = ctorCall as ConstructionCall;
if (call == null || !call.IsContextOk)
{
identity.Context = Context.CreateNewContext (ctorCall);
Context oldContext = Context.SwitchToContext (identity.Context);
try
{
return m_NextActivator.Activate (ctorCall);
}
finally
{
Context.SwitchToContext (oldContext);
}
}
else
return m_NextActivator.Activate (ctorCall);
}
}
}

View File

@@ -0,0 +1,48 @@
//
// System.Runtime.Remoting.Contexts.IActivator..cs
//
// Author:
// Miguel de Icaza (miguel@ximian.com)
//
// (C) 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.Activation {
[System.Runtime.InteropServices.ComVisible (true)]
public interface IActivator {
ActivatorLevel Level {
get;
}
IActivator NextActivator {
get; set;
}
IConstructionReturnMessage Activate (IConstructionCallMessage msg);
}
}

View File

@@ -0,0 +1,61 @@
//
// System.Runtime.Remoting.Activation.IConstructionCallMessage.cs
//
// Author:
// Miguel de Icaza (miguel@ximian.com)
//
// (C) 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.
//
using System.Collections;
using System.Runtime.Remoting.Messaging;
namespace System.Runtime.Remoting.Activation {
[System.Runtime.InteropServices.ComVisible (true)]
public interface IConstructionCallMessage : IMessage, IMethodCallMessage, IMethodMessage {
Type ActivationType {
get;
}
string ActivationTypeName {
get;
}
IActivator Activator {
get;
set;
}
object [] CallSiteActivationAttributes {
get;
}
IList ContextProperties {
get;
}
}
}

View File

@@ -0,0 +1,41 @@
//
// System.Runtime.Remoting.Contexts.IConstructionReturnMessage..cs
//
// Author:
// Miguel de Icaza (miguel@ximian.com)
//
// (C) 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.
//
using System.Runtime.Remoting.Messaging;
namespace System.Runtime.Remoting.Activation {
[System.Runtime.InteropServices.ComVisible (true)]
public interface IConstructionReturnMessage :IMethodReturnMessage, IMethodMessage, IMessage {
}
}

View File

@@ -0,0 +1,72 @@
//
// System.Runtime.Remoting.Activation.RemoteActivationAttribute.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.Runtime.Remoting.Activation;
using System.Runtime.Remoting.Contexts;
using System.Collections;
namespace System.Runtime.Remoting.Activation
{
internal class RemoteActivationAttribute: Attribute, IContextAttribute
{
// This activation attribute is used when creating a client activated
// CBO in the server. This attribute will enforce the creation of
// a new context, and will provide the context properties collected in
// the client.
IList _contextProperties;
public RemoteActivationAttribute ()
{
}
public RemoteActivationAttribute(IList contextProperties)
{
_contextProperties = contextProperties;
}
public bool IsContextOK(Context ctx, IConstructionCallMessage ctor)
{
// CBOs remotely activated allways need a new context
return false;
}
public void GetPropertiesForNewContext(IConstructionCallMessage ctor)
{
if (_contextProperties != null)
{
foreach (object prop in _contextProperties)
ctor.ContextProperties.Add (prop);
}
}
}
}

View File

@@ -0,0 +1,78 @@
//
// System.Runtime.Remoting.RemoteActivator.cs
//
// Author: Lluis Sanchez Gual (lsg@ctv.es)
//
// (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.Lifetime;
using System.Runtime.Remoting.Messaging;
namespace System.Runtime.Remoting.Activation
{
internal class RemoteActivator: MarshalByRefObject, IActivator
{
public IConstructionReturnMessage Activate (IConstructionCallMessage msg)
{
if (!RemotingConfiguration.IsActivationAllowed (msg.ActivationType))
throw new RemotingException ("The type " + msg.ActivationTypeName + " is not allowed to be client activated");
object[] activationAttributes = new object[] { new RemoteActivationAttribute (msg.ContextProperties) };
MarshalByRefObject newObject = (MarshalByRefObject) Activator.CreateInstance (msg.ActivationType, msg.Args, activationAttributes);
// The activator must return a ConstructionResponse with an ObjRef as return value.
// It avoids the automatic creation of a proxy in the client.
ObjRef objref = RemotingServices.Marshal (newObject);
return new ConstructionResponse (objref, null, msg);
}
public override Object InitializeLifetimeService()
{
ILease lease = (ILease)base.InitializeLifetimeService();
if (lease.CurrentState == LeaseState.Initial)
{
lease.InitialLeaseTime = TimeSpan.FromMinutes(30);
lease.SponsorshipTimeout = TimeSpan.FromMinutes(1);
lease.RenewOnCallTime = TimeSpan.FromMinutes(10);
}
return lease;
}
public ActivatorLevel Level
{
get { throw new NotSupportedException (); }
}
public IActivator NextActivator
{
get { throw new NotSupportedException (); }
set { throw new NotSupportedException (); }
}
}
}

View File

@@ -0,0 +1,77 @@
//
// System.Runtime.Remoting.Activation.UrlAttribute.cs
//
// Author: Duncan Mak (duncan@ximian.com)
//
// (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.Runtime.Remoting.Contexts;
namespace System.Runtime.Remoting.Activation {
[Serializable]
[System.Runtime.InteropServices.ComVisible (true)]
public sealed class UrlAttribute : ContextAttribute
{
string url;
public UrlAttribute (string callsiteURL)
: base (callsiteURL)
{
url = callsiteURL;
}
public string UrlValue {
get { return url; }
}
public override bool Equals (object o)
{
if (!(o is UrlAttribute))
return false;
return (((UrlAttribute) o).UrlValue == url);
}
public override int GetHashCode ()
{
return url.GetHashCode ();
}
[System.Runtime.InteropServices.ComVisible (true)]
public override void GetPropertiesForNewContext (IConstructionCallMessage ctorMsg)
{
// No new properties
}
[System.Runtime.InteropServices.ComVisible (true)]
public override bool IsContextOK (Context ctx, IConstructionCallMessage msg)
{
return true;
}
}
}