private IConstructionReturnMessage InternalActivate(IConstructionCallMessage ctorMsg) { this.CtorThread = Thread.CurrentThread.GetHashCode(); IConstructionReturnMessage constructionReturnMessage = ActivationServices.Activate(this, ctorMsg); this.Initialized = true; return(constructionReturnMessage); }
internal IMessage ActivateRemoteObject(IMethodMessage request) { if (_ctorCall == null) // It must be a WKO { return(new ConstructionResponse(this, null, (IMethodCallMessage)request)); // Ignore constructor call for WKOs } _ctorCall.CopyFrom(request); return(ActivationServices.Activate(this, _ctorCall)); }
internal IMessage ActivateRemoteObject(IMethodMessage request) { if (this._ctorCall == null) { return(new ConstructionResponse(this, null, (IMethodCallMessage)request)); } this._ctorCall.CopyFrom(request); return(ActivationServices.Activate(this, this._ctorCall)); }
public static void RegisterActivatedServiceType(ActivatedServiceTypeEntry entry) { RemotingConfigHandler.RegisterActivatedServiceType(entry); if (!RemotingConfiguration.s_ListeningForActivationRequests) { RemotingConfiguration.s_ListeningForActivationRequests = true; ActivationServices.StartListeningForRemoteRequests(); } }
public IMessage SyncProcessMessage(IMessage msg) { if (msg is IConstructionCallMessage) { return(ActivationServices.CreateInstanceFromMessage((IConstructionCallMessage)msg)); } ServerIdentity serverIdentity = (ServerIdentity)RemotingServices.GetMessageTargetIdentity(msg); return(serverIdentity.SyncObjectProcessMessage(msg)); }
public static void RegisterActivatedServiceType(ActivatedServiceTypeEntry entry) { RemotingConfigHandler.RegisterActivatedServiceType(entry); // make sure we're listening for activation requests // (all registrations for activated service types will come through here) if (!s_ListeningForActivationRequests) { s_ListeningForActivationRequests = true; ActivationServices.StartListeningForRemoteRequests(); } } // RegisterActivatedServiceType
/// <summary>Creates a new instance of the specified object type.</summary> /// <returns>A zeroed object of the specified type.</returns> /// <param name="type">The type of object to create. </param> /// <exception cref="T:System.ArgumentNullException">The <paramref name="type" /> parameter is null. </exception> /// <exception cref="T:System.Security.SecurityException">The caller does not have the required permission. </exception> /// <PermissionSet> /// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="SerializationFormatter" /> /// </PermissionSet> public static object GetUninitializedObject(Type type) { if (type == null) { throw new ArgumentNullException("type"); } if (type == typeof(string)) { throw new ArgumentException("Uninitialized Strings cannot be created."); } return(ActivationServices.AllocateUninitializedClassInstance(type)); }
public static void RegisterWellKnownClientType(WellKnownClientTypeEntry entry) { lock (channelTemplates) { if (wellKnownClientEntries.ContainsKey(entry.ObjectType) || activatedClientEntries.ContainsKey(entry.ObjectType)) { throw new RemotingException("Attempt to redirect activation of type '" + entry.ObjectType.FullName + "' which is already redirected."); } wellKnownClientEntries[entry.ObjectType] = entry; ActivationServices.EnableProxyActivation(entry.ObjectType, true); } }
/// <summary>Registers an object <see cref="T:System.Type" /> recorded in the provided <see cref="T:System.Runtime.Remoting.ActivatedClientTypeEntry" /> on the client end as a type that can be activated on the server.</summary> /// <param name="entry">Configuration settings for the client-activated type. </param> /// <exception cref="T:System.Security.SecurityException">At least one of the callers higher in the callstack does not have permission to configure remoting types and channels. </exception> /// <PermissionSet> /// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="RemotingConfiguration" /> /// </PermissionSet> public static void RegisterActivatedClientType(ActivatedClientTypeEntry entry) { Hashtable obj = RemotingConfiguration.channelTemplates; lock (obj) { if (RemotingConfiguration.wellKnownClientEntries.ContainsKey(entry.ObjectType) || RemotingConfiguration.activatedClientEntries.ContainsKey(entry.ObjectType)) { throw new RemotingException("Attempt to redirect activation of type '" + entry.ObjectType.FullName + "' which is already redirected."); } RemotingConfiguration.activatedClientEntries[entry.ObjectType] = entry; ActivationServices.EnableProxyActivation(entry.ObjectType, true); } }
/// <include file='doc\remotingproxy.uex' path='docs/doc[@for="RemotingProxy.InternalActivate"]/*' /> // New method for activators. // This gets called during remoting intercepted activation when // JIT tries to run a constructor on a TP (which remoting gave it // in place of an actual uninitialized instance of the expected type) private IConstructionReturnMessage InternalActivate(IConstructionCallMessage ctorMsg) { // Remember the hashcode of the constructor thread. CtorThread = Thread.CurrentThread.GetHashCode(); IConstructionReturnMessage ctorRetMsg = ActivationServices.Activate(this, ctorMsg); // Set the flag to indicate that the object is initialized // Note: this assert is not valid for WKOs //BCLDebug.Assert(!Initialized, "Proxy marked as initialized before activation call completed"); Initialized = true; return(ctorRetMsg); }
private static void ConfigureRemoting(RemotingXmlConfigFileData configData, bool ensureSecurity) { try { string applicationName = configData.ApplicationName; if (applicationName != null) { ApplicationName = applicationName; } if (configData.CustomErrors != null) { _errorMode = configData.CustomErrors.Mode; } ConfigureChannels(configData, ensureSecurity); if (configData.Lifetime != null) { if (configData.Lifetime.IsLeaseTimeSet) { LifetimeServices.LeaseTime = configData.Lifetime.LeaseTime; } if (configData.Lifetime.IsRenewOnCallTimeSet) { LifetimeServices.RenewOnCallTime = configData.Lifetime.RenewOnCallTime; } if (configData.Lifetime.IsSponsorshipTimeoutSet) { LifetimeServices.SponsorshipTimeout = configData.Lifetime.SponsorshipTimeout; } if (configData.Lifetime.IsLeaseManagerPollTimeSet) { LifetimeServices.LeaseManagerPollTime = configData.Lifetime.LeaseManagerPollTime; } } _bUrlObjRefMode = configData.UrlObjRefMode; Info.StoreRemoteAppEntries(configData); Info.StoreActivatedExports(configData); Info.StoreInteropEntries(configData); Info.StoreWellKnownExports(configData); if (configData.ServerActivatedEntries.Count > 0) { ActivationServices.StartListeningForRemoteRequests(); } } catch (Exception exception) { throw new RemotingException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Remoting_Config_ConfigurationFailure"), new object[] { exception })); } }
public IMessage SyncProcessMessage(IMessage msg) { if (msg is IConstructionCallMessage) { return(ActivationServices.CreateInstanceFromMessage((IConstructionCallMessage)msg)); } else { #if !DISABLE_REMOTING ServerIdentity identity = (ServerIdentity)RemotingServices.GetMessageTargetIdentity(msg); return(identity.SyncObjectProcessMessage(msg)); #else return(null); #endif } }
public IMessage SyncProcessMessage(IMessage msg) { Context.NotifyGlobalDynamicSinks(true, msg, true, false); this._context.NotifyDynamicSinks(true, msg, true, false); IMessage result; if (msg is IConstructionCallMessage) { result = ActivationServices.RemoteActivate((IConstructionCallMessage)msg); } else { Identity messageTargetIdentity = RemotingServices.GetMessageTargetIdentity(msg); result = messageTargetIdentity.ChannelSink.SyncProcessMessage(msg); } Context.NotifyGlobalDynamicSinks(false, msg, true, false); this._context.NotifyDynamicSinks(false, msg, true, false); return result; }
public IMessage SyncProcessMessage(IMessage msg) { IMessage res = null; Context.NotifyGlobalDynamicSinks(true, msg, true, false); _context.NotifyDynamicSinks(true, msg, true, false); if (msg is IConstructionCallMessage) { res = ActivationServices.RemoteActivate((IConstructionCallMessage)msg); } #if !DISABLE_REMOTING else { Identity identity = RemotingServices.GetMessageTargetIdentity(msg); res = identity.ChannelSink.SyncProcessMessage(msg); } #endif Context.NotifyGlobalDynamicSinks(false, msg, true, false); _context.NotifyDynamicSinks(false, msg, true, false); return(res); }
internal RemotingProxy(Type type, string activationUrl, object[] activationAttributes) : base(type) { _hasEnvoySink = false; _ctorCall = ActivationServices.CreateConstructionCall(type, activationUrl, activationAttributes); }
public static object CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, object [] args, CultureInfo culture, object [] activationAttributes) { CheckType(type); #if NET_2_0 if (type.ContainsGenericParameters) { throw new ArgumentException(type + " is an open generic type", "type"); } #endif // It seems to apply the same rules documented for InvokeMember: "If the type of lookup // is omitted, BindingFlags.Public | BindingFlags.Instance will apply". if ((bindingAttr & _accessFlags) == 0) { bindingAttr |= BindingFlags.Public | BindingFlags.Instance; } int length = 0; if (args != null) { length = args.Length; } Type[] atypes = length == 0 ? Type.EmptyTypes : new Type [length]; for (int i = 0; i < length; ++i) { if (args [i] != null) { atypes [i] = args [i].GetType(); } } if (binder == null) { binder = Binder.DefaultBinder; } ConstructorInfo ctor = (ConstructorInfo)binder.SelectMethod(bindingAttr, type.GetConstructors(bindingAttr), atypes, null); if (ctor == null) { // Not sure about this if (type.IsValueType && atypes.Length == 0) { return(CreateInstanceInternal(type)); } StringBuilder sb = new StringBuilder(); foreach (Type t in atypes) { sb.Append(t != null ? t.ToString() : "(unknown)"); sb.Append(", "); } if (sb.Length > 2) { sb.Length -= 2; } throw new MissingMethodException(String.Format(Locale.GetText("No constructor found for {0}::.ctor({1})"), type.FullName, sb)); } CheckAbstractType(type); #if !NET_2_1 || MONOTOUCH if (activationAttributes != null && activationAttributes.Length > 0) { if (!type.IsMarshalByRef) { string msg = Locale.GetText("Type '{0}' doesn't derive from MarshalByRefObject.", type.FullName); throw new NotSupportedException(msg); } object newOb = ActivationServices.CreateProxyFromAttributes(type, activationAttributes); if (newOb != null) { // This returns null ctor.Invoke(newOb, bindingAttr, binder, args, culture); return(newOb); } } #endif return(ctor.Invoke(bindingAttr, binder, args, culture)); }
private async Task RemoveQueues(List <QueueId> queuesToRemove) { if (queuesToRemove.Count == 0) { return; } // Stop the agents that for queues that are not in my range anymore. var agents = new List <PersistentStreamPullingAgent>(queuesToRemove.Count); Log(ErrorCode.PersistentStreamPullingManager_10, "About to remove {0} agents from my responsibility: {1}", queuesToRemove.Count, Utils.EnumerableToString(queuesToRemove, q => q.ToString())); var removeTasks = new List <Task>(); foreach (var queueId in queuesToRemove) { PersistentStreamPullingAgent agent; if (!queuesToAgentsMap.TryGetValue(queueId, out agent)) { continue; } agents.Add(agent); queuesToAgentsMap.Remove(queueId); var agentGrainRef = agent.AsReference <IPersistentStreamPullingAgent>(); var task = OrleansTaskExtentions.SafeExecute(agentGrainRef.Shutdown); task = task.LogException(logger, ErrorCode.PersistentStreamPullingManager_11, String.Format("PersistentStreamPullingAgent {0} failed to Shutdown.", agent.QueueId)); removeTasks.Add(task); } try { await Task.WhenAll(removeTasks); } catch { // Just ignore this exception and proceed as if Initialize has succeeded. // We already logged individual exceptions for individual calls to Shutdown. No need to log again. } var catalog = ActivationServices.GetRequiredService <Catalog>(); foreach (var agent in agents) { try { catalog.UnregisterSystemTarget(agent); } catch (Exception exc) { Log(ErrorCode.PersistentStreamPullingManager_12, "Exception while UnRegisterSystemTarget of PersistentStreamPullingAgent {0}. Ignoring. Exc.Message = {1}.", ((ISystemTargetBase)agent).GrainId, exc.Message); } } if (agents.Count > 0) { Log(ErrorCode.PersistentStreamPullingManager_10, "Removed {0} queues: {1}. Now own total of {2} queues: {3}", agents.Count, Utils.EnumerableToString(agents, agent => agent.QueueId.ToString()), NumberRunningAgents, PrintQueues(queuesToAgentsMap.Keys)); } }
internal MarshalByRefObject CreateInstanceInternal(Type serverType) { return(ActivationServices.CreateInstance(serverType)); }
public static object CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, object [] args, CultureInfo culture, object [] activationAttributes) { CheckType(type); if (type.ContainsGenericParameters) { throw new ArgumentException(type + " is an open generic type", "type"); } // It seems to apply the same rules documented for InvokeMember: "If the type of lookup // is omitted, BindingFlags.Public | BindingFlags.Instance will apply". if ((bindingAttr & _accessFlags) == 0) { bindingAttr |= BindingFlags.Public | BindingFlags.Instance; } if (binder == null) { binder = Binder.DefaultBinder; } object state; ConstructorInfo ctor = (ConstructorInfo)binder.BindToMethod(bindingAttr, type.GetConstructors(bindingAttr), ref args, null, null, null, out state); if (ctor == null) { // Not sure about this if (type.IsValueType && (args == null || args.Length == 0)) { return(CreateInstanceInternal(type)); } var sb = new StringBuilder(); if (args != null) { for (int i = 0; i < args.Length; i++) { if (i > 0) { sb.Append(", "); } var argument = args [i]; var arg_type = argument != null?argument.GetType() : null; sb.Append(arg_type != null ? arg_type.ToString() : "(unknown)"); } } throw new MissingMethodException(String.Format(Locale.GetText("No constructor found for {0}::.ctor({1})"), type.FullName, sb)); } CheckAbstractType(type); if (activationAttributes != null && activationAttributes.Length > 0) { #if DISABLE_REMOTING throw new NotSupportedException("Activation attributes are not supported"); #else if (!type.IsMarshalByRef) { string msg = Locale.GetText("Type '{0}' doesn't derive from MarshalByRefObject.", type.FullName); throw new NotSupportedException(msg); } object newOb = ActivationServices.CreateProxyFromAttributes(type, activationAttributes); if (newOb != null) { // This returns null ctor.Invoke(newOb, bindingAttr, binder, args, culture); return(newOb); } #endif } return(ctor.Invoke(bindingAttr, binder, args, culture)); }