Example #1
0
        public void addPlugin(string name, Plugin plugin)
        {
            lock(this)
            {
                if(_communicator == null)
                {
                    throw new CommunicatorDestroyedException();
                }

                if(_plugins.Contains(name))
                {
                    AlreadyRegisteredException ex = new AlreadyRegisteredException();
                    ex.id = name;
                    ex.kindOfObject = _kindOfObject;
                    throw ex;
                }
                _plugins[name] = plugin;
            }
        }
Example #2
0
        public void addPlugin(string name, Plugin plugin)
        {
            lock (this)
            {
                if (_communicator == null)
                {
                    throw new CommunicatorDestroyedException();
                }

                if (findPlugin(name) != null)
                {
                    AlreadyRegisteredException ex = new AlreadyRegisteredException();
                    ex.id           = name;
                    ex.kindOfObject = _kindOfObject;
                    throw ex;
                }

                _plugins.Add(new PluginInfo(name, plugin));
            }
        }
Example #3
0
        public void addPlugin(string name, Plugin plugin)
        {
            lock(this)
            {
                if(_communicator == null)
                {
                    throw new CommunicatorDestroyedException();
                }

                if(findPlugin(name) != null)
                {
                    AlreadyRegisteredException ex = new AlreadyRegisteredException();
                    ex.id = name;
                    ex.kindOfObject = _kindOfObject;
                    throw ex;
                }

                PluginInfo info = new PluginInfo();
                info.name = name;
                info.plugin = plugin;
                _plugins.Add(info);
            }
        }
Example #4
0
        //
        // Only for use by ObjectAdapterFactory
        //
        public ObjectAdapterI(Instance instance, Communicator communicator,
                              ObjectAdapterFactory objectAdapterFactory, string name,
                              RouterPrx router, bool noConfig)
        {
            _instance             = instance;
            _communicator         = communicator;
            _objectAdapterFactory = objectAdapterFactory;
            _servantManager       = new ServantManager(instance, name);
            _name = name;
            _incomingConnectionFactories = new List <IncomingConnectionFactory>();
            _publishedEndpoints          = Array.Empty <EndpointI>();
            _routerInfo  = null;
            _directCount = 0;
            _noConfig    = noConfig;

            if (_noConfig)
            {
                _id             = "";
                _replicaGroupId = "";
                _reference      = _instance.referenceFactory().create("dummy -t", "");
                _acm            = _instance.serverACM();
                return;
            }

            Properties    properties   = _instance.initializationData().properties;
            List <string> unknownProps = new List <string>();
            bool          noProps      = filterProperties(unknownProps);

            //
            // Warn about unknown object adapter properties.
            //
            if (unknownProps.Count != 0 && properties.getPropertyAsIntWithDefault("Ice.Warn.UnknownProperties", 1) > 0)
            {
                StringBuilder message = new StringBuilder("found unknown properties for object adapter `");
                message.Append(_name);
                message.Append("':");
                foreach (string s in unknownProps)
                {
                    message.Append("\n    ");
                    message.Append(s);
                }
                _instance.initializationData().logger.warning(message.ToString());
            }

            //
            // Make sure named adapter has configuration.
            //
            if (router == null && noProps)
            {
                //
                // These need to be set to prevent warnings/asserts in the destructor.
                //
                _state    = StateDestroyed;
                _instance = null;
                _incomingConnectionFactories = null;

                InitializationException ex = new InitializationException();
                ex.reason = "object adapter `" + _name + "' requires configuration";
                throw ex;
            }

            _id             = properties.getProperty(_name + ".AdapterId");
            _replicaGroupId = properties.getProperty(_name + ".ReplicaGroupId");

            //
            // Setup a reference to be used to get the default proxy options
            // when creating new proxies. By default, create twoway proxies.
            //
            string proxyOptions = properties.getPropertyWithDefault(_name + ".ProxyOptions", "-t");

            try
            {
                _reference = _instance.referenceFactory().create("dummy " + proxyOptions, "");
            }
            catch (ProxyParseException)
            {
                InitializationException ex = new InitializationException();
                ex.reason = "invalid proxy options `" + proxyOptions + "' for object adapter `" + _name + "'";
                throw ex;
            }

            _acm = new ACMConfig(properties, communicator.getLogger(), _name + ".ACM", _instance.serverACM());

            {
                int defaultMessageSizeMax = instance.messageSizeMax() / 1024;
                int num = properties.getPropertyAsIntWithDefault(_name + ".MessageSizeMax", defaultMessageSizeMax);
                if (num < 1 || num > 0x7fffffff / 1024)
                {
                    _messageSizeMax = 0x7fffffff;
                }
                else
                {
                    _messageSizeMax = num * 1024; // Property is in kilobytes, _messageSizeMax in bytes
                }
            }

            try
            {
                int threadPoolSize    = properties.getPropertyAsInt(_name + ".ThreadPool.Size");
                int threadPoolSizeMax = properties.getPropertyAsInt(_name + ".ThreadPool.SizeMax");
                if (threadPoolSize > 0 || threadPoolSizeMax > 0)
                {
                    _threadPool = new ThreadPool(_instance, _name + ".ThreadPool", 0);
                }

                if (router == null)
                {
                    router = RouterPrxHelper.uncheckedCast(_instance.proxyFactory().propertyToProxy(_name + ".Router"));
                }
                if (router != null)
                {
                    _routerInfo = _instance.routerManager().get(router);
                    Debug.Assert(_routerInfo != null);

                    //
                    // Make sure this router is not already registered with another adapter.
                    //
                    if (_routerInfo.getAdapter() != null)
                    {
                        AlreadyRegisteredException ex = new AlreadyRegisteredException();
                        ex.kindOfObject = "object adapter with router";
                        ex.id           = Util.identityToString(router.ice_getIdentity(), _instance.toStringMode());
                        throw ex;
                    }

                    //
                    // Associate this object adapter with the router. This way,
                    // new outgoing connections to the router's client proxy will
                    // use this object adapter for callbacks.
                    //
                    _routerInfo.setAdapter(this);

                    //
                    // Also modify all existing outgoing connections to the
                    // router's client proxy to use this object adapter for
                    // callbacks.
                    //
                    _instance.outgoingConnectionFactory().setRouterInfo(_routerInfo);
                }
                else
                {
                    //
                    // Parse the endpoints, but don't store them in the adapter. The connection
                    // factory might change it, for example, to fill in the real port number.
                    //
                    List <EndpointI> endpoints = parseEndpoints(properties.getProperty(_name + ".Endpoints"), true);
                    foreach (EndpointI endp in endpoints)
                    {
                        EndpointI publishedEndpoint;
                        foreach (IceInternal.EndpointI expanded in endp.expandHost(out publishedEndpoint))
                        {
                            IncomingConnectionFactory factory = new IncomingConnectionFactory(instance,
                                                                                              expanded,
                                                                                              publishedEndpoint,
                                                                                              this);
                            _incomingConnectionFactories.Add(factory);
                        }
                    }
                    if (endpoints.Count == 0)
                    {
                        TraceLevels tl = _instance.traceLevels();
                        if (tl.network >= 2)
                        {
                            _instance.initializationData().logger.trace(tl.networkCat, "created adapter `" + _name +
                                                                        "' without endpoints");
                        }
                    }
                }

                //
                // Parse published endpoints.
                //
                _publishedEndpoints = computePublishedEndpoints();

                if (properties.getProperty(_name + ".Locator").Length > 0)
                {
                    setLocator(LocatorPrxHelper.uncheckedCast(
                                   _instance.proxyFactory().propertyToProxy(_name + ".Locator")));
                }
                else
                {
                    setLocator(_instance.referenceFactory().getDefaultLocator());
                }
            }
            catch (LocalException)
            {
                destroy();
                throw;
            }
        }