public void Init(IKernel kernel, IConfiguration config)
        {
            _kernel = kernel;

            _mserver = MServerFactory.CreateServer("castle.domain", false);

            _serverConn =
                MConnectorServerFactory.CreateServer(
                    "provider:http:binary:test.rem", null, _mserver);

            _kernel.ComponentModelBuilder.AddContributor(
                new ManagementExtensionModelServerInspector());

            _kernel.ComponentCreated   += new ComponentInstanceDelegate(OnComponentCreated);
            _kernel.ComponentDestroyed += new ComponentInstanceDelegate(OnComponentDestroyed);
        }
Пример #2
0
        public void TestTcpServerCreation()
        {
            System.Collections.Specialized.NameValueCollection props =
                new System.Collections.Specialized.NameValueCollection();
            props.Add("port", "3131");

            MConnectorServer serverConn =
                MConnectorServerFactory.CreateServer("provider:tcp:binary:test.rem", props, null);

            AssertNotNull(serverConn);

            ManagedObjectName name = new ManagedObjectName("connector.tcp:formatter=binary");

            server.RegisterManagedObject(serverConn, name);

            AssertEquals(name, serverConn.ManagedObjectName);

            AppDomain child = null;

            try
            {
                child = AppDomain.CreateDomain(
                    "Child",
                    new System.Security.Policy.Evidence(AppDomain.CurrentDomain.Evidence),
                    AppDomain.CurrentDomain.SetupInformation);

                RemoteClient client = (RemoteClient)
                                      child.CreateInstanceAndUnwrap(typeof(RemoteClient).Assembly.FullName, typeof(RemoteClient).FullName);

                AssertNotNull(client.TestTcpClientCreation());
            }
            finally
            {
                server.UnregisterManagedObject(name);

                if (child != null)
                {
                    AppDomain.Unload(child);
                }
            }
        }
        public override MConnectorServer CreateServer(String url, NameValueCollection properties, MServer server)
        {
            String[] parts     = StripUrl(url);
            String   formatter = parts[2];
            String   objectUri = parts[3];

            TcpChannel channel = CreateChannel(formatter, properties, true);

            MConnectorServer connServer = null;

            if (server != null)
            {
                connServer = new MConnectorServer(server, objectUri);
            }
            else
            {
                connServer = new MConnectorServer(objectUri);
            }

            return(connServer);
        }