Пример #1
0
        /// <summary>
        /// Parameterises and remotes a TPollClientTasks Object that will be used by the
        /// Client to poll for ClientTasks.
        ///
        /// @comment WARNING: If you need to rename this function or change its parameters,
        /// you also need to change the String with its name and the parameters in the
        /// .NET Reflection call in TClientAppDomainConnection!
        ///
        /// @comment The Client needs to make calls to the TPollClientTasks Object
        /// in regular intervals. If the calls don't come anymore, the Client's
        /// AppDomain will be unloaded by a thread of TClientStillAliveCheck!
        ///
        /// </summary>
        /// <returns>The URL at which the remoted TPollClientTasks Object can be reached.
        /// </returns>
        public String GetPollClientTasksURL()
        {
            // Set Parameters for TPollClientTasks Class
            new TPollClientTasksParameters(FClientTasksManager);

            FRemotedPollClientTaskObject = new TPollClientTasks();

            // Start ClientStillAliveCheck Thread
            new ClientStillAliveCheck.TClientStillAliveCheck(FClientServerConnectionType, new TDelegateTearDownAppDomain(
                                                                 TearDownAppDomain), FRandomAppDomainTearDownToken);

            if (TLogging.DL >= 5)
            {
                Console.WriteLine("TClientDomainManager.GetPollClientTasksURL: created TClientStillAliveCheck.");
            }

            string ReturnValue = TConfigurableMBRObject.BuildRandomURI("PollClientTasks");

            if (TLogging.DL >= 9)
            {
                Console.WriteLine("TClientDomainManager.GetPollClientTasksURL: remote at: " + ReturnValue);
            }

            return(ReturnValue);
        }
        /// <summary>
        /// add a new service, for the specified client
        /// </summary>
        public static void AddService(string AClientID, string AServiceID, ICrossDomainService AService)
        {
            FAvailableServicesPerClient.Add(AClientID + AServiceID, AService);

            if (TLogging.DebugLevel > 1)
            {
                TLogging.Log("CrossDomainMarshaller.AddService " + AClientID + " " + AServiceID + " " + FAvailableServicesPerClient.Count.ToString());
            }
        }
Пример #3
0
        /// <summary>
        /// add a new service, for the specified client
        /// </summary>
        public static void AddService(string AClientID, string AServiceID, ICrossDomainService AService)
        {
            FAvailableServicesPerClient.Add(AClientID + AServiceID, AService);

            if (TLogging.DebugLevel > 1)
            {
                TLogging.Log("CrossDomainMarshaller.AddService " + AClientID + " " + AServiceID + " " + FAvailableServicesPerClient.Count.ToString());
            }
        }
Пример #4
0
        /// <summary>
        /// Creates and dynamically exposes an instance of the remoteable TMyService
        /// class to make it callable remotely from the Client.
        ///
        /// @comment This function gets called from TRemoteLoader.LoadPetraModuleAssembly.
        /// This call is done late-bound through .NET Reflection!
        ///
        /// WARNING: If the name of this function or its parameters should change, this
        /// needs to be reflected in the call to this function in
        /// TRemoteLoader.LoadPetraModuleAssembly!!!
        ///
        /// </summary>
        /// <returns>The URL at which the remoted object can be reached.</returns>
        public String GetRemotingURL()
        {
            if (TLogging.DL >= 9)
            {
                Console.WriteLine("TMyServiceNamespaceLoader.GetRemotingURL in AppDomain: " + Thread.GetDomain().FriendlyName);
            }

            FRemotedObject = new TMyService();
            FRemotingURL   = BuildRandomURI("TMyService");

            return(FRemotingURL);
        }
Пример #5
0
        /// <summary>
        /// Loads the ClientDomain DLL into the Client's AppDomain, instantiates the
        /// main Class (TClientDomainManager) and initialises the AppDomain by calling
        /// several functions of that Class.
        ///
        /// </summary>
        /// <param name="AClientID">ClientID as assigned by the ClientManager</param>
        /// <param name="AClientServerConnectionType">Tells in which way the Client connected
        /// to the PetraServer</param>
        /// <param name="AClientManagerRef">A reference to the ClientManager object
        /// (Note: .NET Remoting will be working behind the scenes since calls to
        /// this Object will cross AppDomains!)</param>
        /// <param name="ASystemDefaultsCacheRef">A reference to the SystemDefaultsCache object
        /// (Note: .NET Remoting will be working behind the scenes since calls to
        /// this Object will cross AppDomains!)</param>
        /// <param name="ACacheableTablesManagerRef"></param>
        /// <param name="AUserInfo">An instantiated PetraPrincipal Object, containing User
        /// information</param>
        /// <param name="AServerSettings">A copy of the ServerSettings</param>
        /// <param name="ARemotingURLPollClientTasks">The .NET Remoting URL of the
        /// TPollClientTasks Class which the Client needs to calls to retrieve
        /// ClientTasks.</param>
        /// <param name="ARemotedPollClientTasksObject"></param>
        public void LoadDomainManagerAssembly(Int32 AClientID,
                                              TClientServerConnectionType AClientServerConnectionType,
                                              TClientManagerCallForwarder AClientManagerRef,
                                              object ASystemDefaultsCacheRef,
                                              object ACacheableTablesManagerRef,
                                              IPrincipal AUserInfo,
                                              TSrvSetting AServerSettings,
                                              out String ARemotingURLPollClientTasks,
                                              out ICrossDomainService ARemotedPollClientTasksObject)
        {
            // Console.WriteLine('TRemoteLoader.LoadDomainManagerAssembly in AppDomain: ' + AppDomain.CurrentDomain.ToString);
            Assembly LoadedAssembly = Assembly.Load(CLIENTDOMAIN_DLLNAME);

            FRemoteClientDomainManagerClass = LoadedAssembly.GetType(CLIENTDOMAIN_CLASSNAME);

            FRemoteClientDomainManagerObject = Activator.CreateInstance(FRemoteClientDomainManagerClass,
                                                                        (BindingFlags.Public | BindingFlags.Instance | BindingFlags.CreateInstance), null,
                                                                        new Object[] { AClientID.ToString(),
                                                                                       AClientServerConnectionType,
                                                                                       AClientManagerRef,
                                                                                       ASystemDefaultsCacheRef,
                                                                                       ACacheableTablesManagerRef, AUserInfo },
                                                                        null);

            FRemoteClientDomainManagerClass.InvokeMember("InitAppDomain",
                                                         (BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod),
                                                         null,
                                                         FRemoteClientDomainManagerObject,
                                                         new Object[] { AServerSettings });

            // Create and remote the TPollClientTasks Class
            ARemotingURLPollClientTasks =
                Convert.ToString(FRemoteClientDomainManagerClass.InvokeMember("GetPollClientTasksURL",
                                                                              (BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod), null, FRemoteClientDomainManagerObject, null, null));

            ARemotedPollClientTasksObject =
                (ICrossDomainService)FRemoteClientDomainManagerClass.InvokeMember("GetRemotedPollClientTasksObject",
                                                                                  (BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod), null, FRemoteClientDomainManagerObject, null, null);

            // Establish (separate) DataBase connection for the AppDomain
            Convert.ToString(FRemoteClientDomainManagerClass.InvokeMember("EstablishDBConnection",
                                                                          (BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod), null, FRemoteClientDomainManagerObject, null, null));

            // Perform any other initialisation required by the AppDomain
            FRemoteClientDomainManagerClass.InvokeMember("PostAppDomainSetupInitialisation",
                                                         (BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod), null, FRemoteClientDomainManagerObject, null, null);
            //  LoadClientDomainManager.ClientTaskAdd('USERMESSAGE','This is just for testing purposes!', 'blabla_1', 'blabla_2', 'blabla_3', 'blabla_4', 1);
        }
Пример #6
0
        /// <summary>
        /// create a object that can be remoted to a client
        /// </summary>
        public static object CreateRemotableObject(Type ARemotableObject, ICrossDomainService ObjectToRemote)
        {
            // need to calculate the URI for this object and pass it to the new namespace object
            string ObjectURI = TConfigurableMBRObject.BuildRandomURI(ObjectToRemote.GetType().ToString());

            // we need to add the service in the main domain
            DomainManagerBase.UClientManagerCallForwarderRef.AddCrossDomainService(
                DomainManagerBase.GClientID.ToString(), ObjectURI, ObjectToRemote);

            try
            {
                // create the object
                return Activator.CreateInstance(ARemotableObject, new object[] { ObjectURI });
            }
            catch (Exception ex)
            {
                TLogging.Log(ex.ToString());
                throw;
            }
        }
Пример #7
0
        /// <summary>
        /// create a object that can be remoted to a client
        /// </summary>
        public static object CreateRemotableObject(Type ARemotableObject, ICrossDomainService ObjectToRemote)
        {
            // need to calculate the URI for this object and pass it to the new namespace object
            string ObjectURI = TConfigurableMBRObject.BuildRandomURI(ObjectToRemote.GetType().ToString());

            // we need to add the service in the main domain
            DomainManagerBase.UClientManagerCallForwarderRef.AddCrossDomainService(
                DomainManagerBase.GClientID.ToString(), ObjectURI, ObjectToRemote);

            try
            {
                // create the object
                return(Activator.CreateInstance(ARemotableObject, new object[] { ObjectURI }));
            }
            catch (Exception ex)
            {
                TLogging.Log(ex.ToString());
                throw;
            }
        }
Пример #8
0
        /// <summary>
        /// Loads a specified Petra Module Instantiator DLL into a Client's AppDomain,
        /// initialises the main Class (an Instantiator) and remotes the resulting
        /// Instantiator Object.
        ///
        /// </summary>
        /// <param name="AAssemblyDLLName">name of the dll that contains ARemoteType</param>
        /// <param name="ARemoteType">name of the class that should be loaded</param>
        /// <param name="APetraModuleInstantiatorRemotingURL">The .NET Remoting URL which the
        /// Client needs to make calls to the Instantiator Object.
        /// </param>
        /// <param name="ARemoteObject">the remote object</param>
        /// <returns>void</returns>
        public void LoadPetraModuleAssembly(
            string AAssemblyDLLName,
            String ARemoteType,
            out String APetraModuleInstantiatorRemotingURL,
            out ICrossDomainService ARemoteObject)
        {
            // Console.WriteLine('TRemoteLoader.LoadPetraModuleAssembly in AppDomain: ' + AppDomain.CurrentDomain.ToString);
            #region Load Petra Module DLL into AppDomain of Client, create instance of Instantiator Object

            Assembly LoadedAssembly = Assembly.Load(AAssemblyDLLName);

            Type RemoteClass = LoadedAssembly.GetType(ARemoteType);

            if (RemoteClass == null)
            {
                string msg = "cannot find type " + ARemoteType + " in " + AAssemblyDLLName;
                TLogging.Log(msg);
                throw new Exception(msg);
            }

            object Instantiator = Activator.CreateInstance(RemoteClass,
                                                           (BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod),
                                                           null,
                                                           null,
                                                           null);

            #endregion

            // Remote the Petra Module Instantiator from the AppDomain
            APetraModuleInstantiatorRemotingURL =
                Convert.ToString(RemoteClass.InvokeMember("GetRemotingURL", (BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod),
                                                          null, Instantiator, null, null));

            ARemoteObject = (ICrossDomainService)
                            RemoteClass.InvokeMember("GetRemotedObject", (BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod),
                                                     null, Instantiator, null, null);
        }
Пример #9
0
 /// <summary>
 /// add a service that is offered by the appdomain, for single port remoting
 /// </summary>
 public void AddCrossDomainService(string ClientID, string ObjectURI, ICrossDomainService ObjectToRemote)
 {
     TCrossDomainMarshaller.AddService(ClientID, ObjectURI, ObjectToRemote);
 }
        /// <summary>
        /// Loads a specified Petra Module Instantiator DLL into a Client's AppDomain,
        /// initialises the main Class (an Instantiator) and remotes the resulting
        /// Instantiator Object.
        ///
        /// </summary>
        /// <param name="AAssemblyDLLName">name of the dll that contains ARemoteType</param>
        /// <param name="ARemoteType">name of the class that should be loaded</param>
        /// <param name="APetraModuleInstantiatorRemotingURL">The .NET Remoting URL which the
        /// Client needs to make calls to the Instantiator Object.
        /// </param>
        /// <param name="ARemoteObject">the remote object</param>
        /// <returns>void</returns>
        public void LoadPetraModuleAssembly(
            string AAssemblyDLLName,
            String ARemoteType,
            out String APetraModuleInstantiatorRemotingURL,
            out ICrossDomainService ARemoteObject)
        {
            // Console.WriteLine('TRemoteLoader.LoadPetraModuleAssembly in AppDomain: ' + AppDomain.CurrentDomain.ToString);
            #region Load Petra Module DLL into AppDomain of Client, create instance of Instantiator Object

            Assembly LoadedAssembly = Assembly.Load(AAssemblyDLLName);

            Type RemoteClass = LoadedAssembly.GetType(ARemoteType);

            if (RemoteClass == null)
            {
                string msg = "cannot find type " + ARemoteType + " in " + AAssemblyDLLName;
                TLogging.Log(msg);
                throw new Exception(msg);
            }

            object Instantiator = Activator.CreateInstance(RemoteClass,
                (BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod),
                null,
                null,
                null);

            #endregion

            // Remote the Petra Module Instantiator from the AppDomain
            APetraModuleInstantiatorRemotingURL =
                Convert.ToString(RemoteClass.InvokeMember("GetRemotingURL", (BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod),
                        null, Instantiator, null, null));

            ARemoteObject = (ICrossDomainService)
                            RemoteClass.InvokeMember("GetRemotedObject", (BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod),
                null, Instantiator, null, null);
        }
        /// <summary>
        /// Loads the ClientDomain DLL into the Client's AppDomain, instantiates the
        /// main Class (TClientDomainManager) and initialises the AppDomain by calling
        /// several functions of that Class.
        ///
        /// </summary>
        /// <param name="AClientID">ClientID as assigned by the ClientManager</param>
        /// <param name="AClientServerConnectionType">Tells in which way the Client connected
        /// to the PetraServer</param>
        /// <param name="AClientManagerRef">A reference to the ClientManager object
        /// (Note: .NET Remoting will be working behind the scenes since calls to
        /// this Object will cross AppDomains!)</param>
        /// <param name="ASystemDefaultsCacheRef">A reference to the SystemDefaultsCache object
        /// (Note: .NET Remoting will be working behind the scenes since calls to
        /// this Object will cross AppDomains!)</param>
        /// <param name="ACacheableTablesManagerRef"></param>
        /// <param name="AUserInfo">An instantiated PetraPrincipal Object, containing User
        /// information</param>
        /// <param name="AServerSettings">A copy of the ServerSettings</param>
        /// <param name="ARemotingURLPollClientTasks">The .NET Remoting URL of the
        /// TPollClientTasks Class which the Client needs to calls to retrieve
        /// ClientTasks.</param>
        /// <param name="ARemotedPollClientTasksObject"></param>
        public void LoadDomainManagerAssembly(Int32 AClientID,
            TClientServerConnectionType AClientServerConnectionType,
            TClientManagerCallForwarder AClientManagerRef,
            object ASystemDefaultsCacheRef,
            object ACacheableTablesManagerRef,
            IPrincipal AUserInfo,
            TSrvSetting AServerSettings,
            out String ARemotingURLPollClientTasks,
            out ICrossDomainService ARemotedPollClientTasksObject)
        {
            // Console.WriteLine('TRemoteLoader.LoadDomainManagerAssembly in AppDomain: ' + AppDomain.CurrentDomain.ToString);
            Assembly LoadedAssembly = Assembly.Load(CLIENTDOMAIN_DLLNAME);

            FRemoteClientDomainManagerClass = LoadedAssembly.GetType(CLIENTDOMAIN_CLASSNAME);

            FRemoteClientDomainManagerObject = Activator.CreateInstance(FRemoteClientDomainManagerClass,
                (BindingFlags.Public | BindingFlags.Instance | BindingFlags.CreateInstance), null,
                new Object[] { AClientID.ToString(),
                               AClientServerConnectionType,
                               AClientManagerRef,
                               ASystemDefaultsCacheRef,
                               ACacheableTablesManagerRef, AUserInfo },
                null);

            FRemoteClientDomainManagerClass.InvokeMember("InitAppDomain",
                (BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod),
                null,
                FRemoteClientDomainManagerObject,
                new Object[] { AServerSettings });

            // Create and remote the TPollClientTasks Class
            ARemotingURLPollClientTasks =
                Convert.ToString(FRemoteClientDomainManagerClass.InvokeMember("GetPollClientTasksURL",
                        (BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod), null, FRemoteClientDomainManagerObject, null, null));

            ARemotedPollClientTasksObject =
                (ICrossDomainService)FRemoteClientDomainManagerClass.InvokeMember("GetRemotedPollClientTasksObject",
                    (BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod), null, FRemoteClientDomainManagerObject, null, null);

            // Establish (separate) DataBase connection for the AppDomain
            Convert.ToString(FRemoteClientDomainManagerClass.InvokeMember("EstablishDBConnection",
                    (BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod), null, FRemoteClientDomainManagerObject, null, null));

            // Perform any other initialisation required by the AppDomain
            FRemoteClientDomainManagerClass.InvokeMember("PostAppDomainSetupInitialisation",
                (BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod), null, FRemoteClientDomainManagerObject, null, null);
            //  LoadClientDomainManager.ClientTaskAdd('USERMESSAGE','This is just for testing purposes!', 'blabla_1', 'blabla_2', 'blabla_3', 'blabla_4', 1);
        }
Пример #12
0
        /// <summary>
        /// Parameterises and remotes a TPollClientTasks Object that will be used by the
        /// Client to poll for ClientTasks.
        ///
        /// @comment WARNING: If you need to rename this function or change its parameters,
        /// you also need to change the String with its name and the parameters in the
        /// .NET Reflection call in TClientAppDomainConnection!
        ///
        /// @comment The Client needs to make calls to the TPollClientTasks Object
        /// in regular intervals. If the calls don't come anymore, the Client's
        /// AppDomain will be unloaded by a thread of TClientStillAliveCheck!
        ///
        /// </summary>
        /// <returns>The URL at which the remoted TPollClientTasks Object can be reached.
        /// </returns>
        public String GetPollClientTasksURL()
        {
            // Set Parameters for TPollClientTasks Class
            new TPollClientTasksParameters(FClientTasksManager);

            FRemotedPollClientTaskObject = new TPollClientTasks();

            // Start ClientStillAliveCheck Thread
            new ClientStillAliveCheck.TClientStillAliveCheck(FClientServerConnectionType, new TDelegateTearDownAppDomain(
                    TearDownAppDomain), FRandomAppDomainTearDownToken);

            if (TLogging.DL >= 5)
            {
                Console.WriteLine("TClientDomainManager.GetPollClientTasksURL: created TClientStillAliveCheck.");
            }

            string ReturnValue = TConfigurableMBRObject.BuildRandomURI("PollClientTasks");

            if (TLogging.DL >= 9)
            {
                Console.WriteLine("TClientDomainManager.GetPollClientTasksURL: remote at: " + ReturnValue);
            }

            return ReturnValue;
        }
Пример #13
0
        /// <summary>
        /// Creates and dynamically exposes an instance of the remoteable TMyService
        /// class to make it callable remotely from the Client.
        ///
        /// @comment This function gets called from TRemoteLoader.LoadPetraModuleAssembly.
        /// This call is done late-bound through .NET Reflection!
        ///
        /// WARNING: If the name of this function or its parameters should change, this
        /// needs to be reflected in the call to this function in
        /// TRemoteLoader.LoadPetraModuleAssembly!!!
        ///
        /// </summary>
        /// <returns>The URL at which the remoted object can be reached.</returns>
        public String GetRemotingURL()
        {
            if (TLogging.DL >= 9)
            {
                Console.WriteLine("TMyServiceNamespaceLoader.GetRemotingURL in AppDomain: " + Thread.GetDomain().FriendlyName);
            }

            FRemotedObject = new TMyService();
            FRemotingURL = BuildRandomURI("TMyService");

            return FRemotingURL;
        }
 /// <summary>
 /// add a service that is offered by the appdomain, for single port remoting
 /// </summary>
 public void AddCrossDomainService(string ClientID, string ObjectURI, ICrossDomainService ObjectToRemote)
 {
     FClientManagerRef.AddCrossDomainService(ClientID, ObjectURI, ObjectToRemote);
 }
 /// <summary>
 /// add a service that is offered by the appdomain, for single port remoting
 /// </summary>
 public void AddCrossDomainService(string ClientID, string ObjectURI, ICrossDomainService ObjectToRemote)
 {
     FClientManagerRef.AddCrossDomainService(ClientID, ObjectURI, ObjectToRemote);
 }