Ejemplo n.º 1
0
            public Test.RemoteCommunicatorPrx createCommunicator(Dictionary <string, string> props, Ice.Current current)
            {
                //
                // Prepare the property set using the given properties.
                //
                Ice.InitializationData init = new Ice.InitializationData();
                init.properties = Ice.Util.createProperties();
                foreach (KeyValuePair <string, string> e in props)
                {
                    init.properties.setProperty(e.Key, e.Value);
                }

                if (init.properties.getPropertyAsInt("NullLogger") > 0)
                {
                    init.logger = new NullLogger();
                }

                //
                // Initialize a new communicator.
                //
                Ice.Communicator communicator = Ice.Util.initialize(init);

                //
                // Install a custom admin facet.
                //
                try
                {
                    communicator.addAdminFacet <TestFacet, TestFacetTraits>(new TestFacetI(), "TestFacet");
                }
                catch (System.ArgumentException ex)
                {
                }

                //
                // The RemoteCommunicator servant also implements PropertiesAdminUpdateCallback.
                // Set the callback on the admin facet.
                //
                RemoteCommunicatorI servant = new RemoteCommunicatorI(communicator);
                var propFacet = communicator.findAdminFacet("Properties").servant;

                if (propFacet != null)
                {
                    Ice.NativePropertiesAdmin admin = (Ice.NativePropertiesAdmin)propFacet;
                    Debug.Assert(admin != null);
                    admin.addUpdateCallback(servant.updated);
                }

                return(current.adapter.Add(servant));
            }
Ejemplo n.º 2
0
Archivo: TestI.cs Proyecto: ycbxklk/ice
            override public Test.RemoteCommunicatorPrx createCommunicator(Dictionary <string, string> props, Ice.Current current)
            {
                //
                // Prepare the property set using the given properties.
                //
                Ice.InitializationData init = new Ice.InitializationData();
                init.properties = Ice.Util.createProperties();
                foreach (KeyValuePair <string, string> e in props)
                {
                    init.properties.setProperty(e.Key, e.Value);
                }

                if (init.properties.getPropertyAsInt("NullLogger") > 0)
                {
                    init.logger = new NullLogger();
                }

                //
                // Initialize a new communicator.
                //
                Ice.Communicator communicator = Ice.Util.initialize(init);

                //
                // Install a custom admin facet.
                //
                communicator.addAdminFacet(new TestFacetI(), "TestFacet");

                //
                // The RemoteCommunicator servant also implements PropertiesAdminUpdateCallback.
                // Set the callback on the admin facet.
                //
                RemoteCommunicatorI servant = new RemoteCommunicatorI(communicator);

                Ice.Object propFacet = communicator.findAdminFacet("Properties");

                if (propFacet != null)
                {
                    Ice.NativePropertiesAdmin admin = (Ice.NativePropertiesAdmin)propFacet;
                    Debug.Assert(admin != null);
                    admin.addUpdateCallback(servant.updated);
                }

                Ice.ObjectPrx proxy = current.adapter.addWithUUID(servant);
                return(Test.RemoteCommunicatorPrxHelper.uncheckedCast(proxy));
            }
Ejemplo n.º 3
0
            testFacets(Ice.Communicator com, bool builtInFacets)
            {
                if (builtInFacets)
                {
                    test(com.findAdminFacet("Properties") != null);
                    test(com.findAdminFacet("Process") != null);
                    test(com.findAdminFacet("Logger") != null);
                    test(com.findAdminFacet("Metrics") != null);
                }

                Test.TestFacet f1 = new TestFacetI();
                Test.TestFacet f2 = new TestFacetI();
                Test.TestFacet f3 = new TestFacetI();

                com.addAdminFacet(f1, "Facet1");
                com.addAdminFacet(f2, "Facet2");
                com.addAdminFacet(f3, "Facet3");

                test(com.findAdminFacet("Facet1") == f1);
                test(com.findAdminFacet("Facet2") == f2);
                test(com.findAdminFacet("Facet3") == f3);
                test(com.findAdminFacet("Bogus") == null);

                Dictionary <string, Ice.Object> facetMap = com.findAllAdminFacets();

                if (builtInFacets)
                {
                    test(facetMap.Count == 7);
                    test(facetMap.ContainsKey("Properties"));
                    test(facetMap.ContainsKey("Process"));
                    test(facetMap.ContainsKey("Logger"));
                    test(facetMap.ContainsKey("Metrics"));
                }
                else
                {
                    test(facetMap.Count >= 3);
                }
                test(facetMap.ContainsKey("Facet1"));
                test(facetMap.ContainsKey("Facet2"));
                test(facetMap.ContainsKey("Facet3"));

                try
                {
                    com.addAdminFacet(f1, "Facet1");
                    test(false);
                }
                catch (Ice.AlreadyRegisteredException)
                {
                    // Expected
                }

                try
                {
                    com.removeAdminFacet("Bogus");
                    test(false);
                }
                catch (Ice.NotRegisteredException)
                {
                    // Expected
                }

                com.removeAdminFacet("Facet1");
                com.removeAdminFacet("Facet2");
                com.removeAdminFacet("Facet3");

                try
                {
                    com.removeAdminFacet("Facet1");
                    test(false);
                }
                catch (Ice.NotRegisteredException)
                {
                    // Expected
                }
            }