Beispiel #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));
            }