Exemple #1
0
        private static Ice.Communicator createSendLogCommunicator(Ice.Communicator communicator, Ice.Logger logger)
        {
            Ice.InitializationData initData = new Ice.InitializationData();
            initData.logger     = logger;
            initData.properties = Ice.Util.createProperties();

            Ice.Properties mainProps = communicator.Properties;

            copyProperties("Ice.Default.Locator", mainProps, initData.properties);
            copyProperties("Ice.Plugin.IceSSL", mainProps, initData.properties);
            copyProperties("IceSSL.", mainProps, initData.properties);

            string[] extraProps = mainProps.getPropertyAsList("Ice.Admin.Logger.Properties");

            if (extraProps.Length > 0)
            {
                for (int i = 0; i < extraProps.Length; ++i)
                {
                    string p = extraProps[i];
                    if (!p.StartsWith("--"))
                    {
                        extraProps[i] = "--" + p;
                    }
                }
                initData.properties.parseCommandLineOptions("", extraProps);
            }
            return(Ice.Util.initialize(initData));
        }
Exemple #2
0
        public void loadPlugins(ref string[] cmdArgs)
        {
            Debug.Assert(_communicator != null);
            string     prefix     = "Ice.Plugin.";
            Properties properties = _communicator.getProperties();
            Dictionary <string, string> plugins = properties.getPropertiesForPrefix(prefix);

            //
            // First, load static plugin factories which were setup to load on
            // communicator initialization. If a matching plugin property is
            // set, we load the plugin with the plugin specification. The
            // entryPoint will be ignored but the rest of the plugin
            // specification might be used.
            //
            foreach (var name in _loadOnInitialization)
            {
                string key = "Ice.Plugin." + name + ".clr";
                string r   = null;
                plugins.TryGetValue(key, out r);
                if (r != null)
                {
                    plugins.Remove("Ice.Plugin." + name);
                }
                else
                {
                    key = "Ice.Plugin." + name;
                    plugins.TryGetValue(key, out r);
                }

                if (r != null)
                {
                    loadPlugin(name, r, ref cmdArgs);
                    plugins.Remove(key);
                }
                else
                {
                    loadPlugin(name, "", ref cmdArgs);
                }
            }

            //
            // Load and initialize the plug-ins defined in the property set
            // with the prefix "Ice.Plugin.". These properties should
            // have the following format:
            //
            // Ice.Plugin.name[.<language>]=entry_point [args]
            //
            // The code below is different from the Java/C++ algorithm
            // because C# must support full assembly names such as:
            //
            // Ice.Plugin.Logger=logger, Version=0.0.0.0, Culture=neutral:LoginPluginFactory
            //
            // If the Ice.PluginLoadOrder property is defined, load the
            // specified plug-ins in the specified order, then load any
            // remaining plug-ins.
            //

            string[] loadOrder = properties.getPropertyAsList("Ice.PluginLoadOrder");
            for (int i = 0; i < loadOrder.Length; ++i)
            {
                if (loadOrder[i].Length == 0)
                {
                    continue;
                }

                if (findPlugin(loadOrder[i]) != null)
                {
                    PluginInitializationException e = new PluginInitializationException();
                    e.reason = "plug-in `" + loadOrder[i] + "' already loaded";
                    throw e;
                }

                string key   = "Ice.Plugin." + loadOrder[i] + ".clr";
                string value = null;
                plugins.TryGetValue(key, out value);
                if (value != null)
                {
                    plugins.Remove("Ice.Plugin." + loadOrder[i]);
                }
                else
                {
                    key = "Ice.Plugin." + loadOrder[i];
                    plugins.TryGetValue(key, out value);
                }

                if (value != null)
                {
                    loadPlugin(loadOrder[i], value, ref cmdArgs);
                    plugins.Remove(key);
                }
                else
                {
                    PluginInitializationException e = new PluginInitializationException();
                    e.reason = "plug-in `" + loadOrder[i] + "' not defined";
                    throw e;
                }
            }

            //
            // Load any remaining plug-ins that weren't specified in PluginLoadOrder.
            //
            while (plugins.Count > 0)
            {
                IEnumerator <KeyValuePair <string, string> > p = plugins.GetEnumerator();
                p.MoveNext();
                string key  = p.Current.Key;
                string val  = p.Current.Value;
                string name = key.Substring(prefix.Length);

                int dotPos = name.LastIndexOf('.');
                if (dotPos != -1)
                {
                    string suffix = name.Substring(dotPos + 1);
                    if (suffix.Equals("cpp") || suffix.Equals("java"))
                    {
                        //
                        // Ignored
                        //
                        plugins.Remove(key);
                    }
                    else if (suffix.Equals("clr"))
                    {
                        name = name.Substring(0, dotPos);
                        loadPlugin(name, val, ref cmdArgs);
                        plugins.Remove(key);
                        plugins.Remove("Ice.Plugin." + name);
                    }
                    else
                    {
                        //
                        // Name is just a regular name that happens to contain a dot
                        //
                        dotPos = -1;
                    }
                }

                if (dotPos == -1)
                {
                    plugins.Remove(key);

                    //
                    // Is there a .clr entry?
                    //
                    string clrKey = "Ice.Plugin." + name + ".clr";
                    if (plugins.ContainsKey(clrKey))
                    {
                        val = plugins[clrKey];
                        plugins.Remove(clrKey);
                    }
                    loadPlugin(name, val, ref cmdArgs);
                }
            }
        }