public Ice.ObjectAdapter createObjectAdapter(string name, Ice.RouterPrx router) { lock (this) { if (instance_ == null) { throw new Ice.CommunicatorDestroyedException(); } Ice.ObjectAdapterI adapter = null; if (name.Length == 0) { string uuid = System.Guid.NewGuid().ToString(); adapter = new Ice.ObjectAdapterI(instance_, _communicator, this, uuid, null, true); } else { if (_adapterNamesInUse.Contains(name)) { Ice.AlreadyRegisteredException ex = new Ice.AlreadyRegisteredException(); ex.kindOfObject = "object adapter"; ex.id = name; throw ex; } adapter = new Ice.ObjectAdapterI(instance_, _communicator, this, name, router, false); _adapterNamesInUse.Add(name); } _adapters.Add(adapter); return(adapter); } }
public Ice.ObjectAdapter createObjectAdapter(string name, Ice.RouterPrx router) { lock(this) { if(instance_ == null) { throw new Ice.CommunicatorDestroyedException(); } Ice.ObjectAdapterI adapter = null; if(name.Length == 0) { string uuid = System.Guid.NewGuid().ToString(); adapter = new Ice.ObjectAdapterI(instance_, _communicator, this, uuid, null, true); } else { if(_adapterNamesInUse.Contains(name)) { Ice.AlreadyRegisteredException ex = new Ice.AlreadyRegisteredException(); ex.kindOfObject = "object adapter"; ex.id = name; throw ex; } adapter = new Ice.ObjectAdapterI(instance_, _communicator, this, name, router, false); _adapterNamesInUse.Add(name); } _adapters.Add(adapter); return adapter; } }
public void addServant(Ice.Object servant, Ice.Identity ident, string facet) { lock(this) { Debug.Assert(instance_ != null); // Must not be called after destruction. if(facet == null) { facet = ""; } Dictionary<string, Ice.Object> m; _servantMapMap.TryGetValue(ident, out m); if(m == null) { _servantMapMap[ident] = (m = new Dictionary<string, Ice.Object>()); } else { if(m.ContainsKey(facet)) { Ice.AlreadyRegisteredException ex = new Ice.AlreadyRegisteredException(); ex.id = instance_.identityToString(ident); ex.kindOfObject = "servant"; if(facet.Length > 0) { ex.id += " -f " + IceUtilInternal.StringUtil.escapeString(facet, ""); } throw ex; } } m[facet] = servant; } }
public void addServant(Ice.Object servant, Ice.Identity ident, string facet) { lock (this) { Debug.Assert(_instance != null); // Must not be called after destruction. if (facet == null) { facet = ""; } Dictionary <string, Ice.Object> m; _servantMapMap.TryGetValue(ident, out m); if (m == null) { _servantMapMap[ident] = (m = new Dictionary <string, Ice.Object>()); } else { if (m.ContainsKey(facet)) { Ice.AlreadyRegisteredException ex = new Ice.AlreadyRegisteredException(); ex.id = Ice.Util.identityToString(ident, _instance.toStringMode()); ex.kindOfObject = "servant"; if (facet.Length > 0) { ex.id += " -f " + IceUtilInternal.StringUtil.escapeString(facet, "", _instance.toStringMode()); } throw ex; } } m[facet] = servant; } }
public void add(Ice.ValueFactory factory, string id) { lock (this) { if (_factoryMap.ContainsKey(id)) { Ice.AlreadyRegisteredException ex = new Ice.AlreadyRegisteredException(); ex.id = id; ex.kindOfObject = "value factory"; throw ex; } _factoryMap[id] = factory; } }
public void add(Ice.ObjectFactory factory, string id) { lock(this) { if(_factoryMap.ContainsKey(id)) { Ice.AlreadyRegisteredException ex = new Ice.AlreadyRegisteredException(); ex.id = id; ex.kindOfObject = "object factory"; throw ex; } _factoryMap[id] = factory; } }
public void add(Ice.ObjectFactory factory, string id) { lock(this) { object o = _factoryMap[id]; if(o != null) { Ice.AlreadyRegisteredException ex = new Ice.AlreadyRegisteredException(); ex.id = id; ex.kindOfObject = "object factory"; throw ex; } _factoryMap[id] = factory; } }
public void add(Ice.ObjectFactory factory, string id) { lock (this) { if (_factoryMap.ContainsKey(id)) { Ice.AlreadyRegisteredException ex = new Ice.AlreadyRegisteredException(); ex.id = id; ex.kindOfObject = "value factory"; throw ex; } Ice.ValueFactory valueFactory = s => { return(factory.create(s)); }; _factoryMap[id] = valueFactory; _objectFactoryMap[id] = factory; } }
public void add(Ice.ObjectFactory factory, string id) { lock(this) { if(_factoryMap.ContainsKey(id)) { Ice.AlreadyRegisteredException ex = new Ice.AlreadyRegisteredException(); ex.id = id; ex.kindOfObject = "value factory"; throw ex; } Ice.ValueFactory valueFactory = s => { return factory.create(s); }; _factoryMap[id] = valueFactory; _objectFactoryMap[id] = factory; } }
public void addDefaultServant(Ice.Object servant, string category) { lock (this) { Debug.Assert(_instance != null); // Must not be called after destruction. Ice.Object obj = null; _defaultServantMap.TryGetValue(category, out obj); if (obj != null) { Ice.AlreadyRegisteredException ex = new Ice.AlreadyRegisteredException(); ex.kindOfObject = "default servant"; ex.id = category; throw ex; } _defaultServantMap[category] = servant; } }
public void addDefaultServant(Ice.Object servant, string category) { lock(this) { Debug.Assert(instance_ != null); // Must not be called after destruction. Ice.Object obj = null; _defaultServantMap.TryGetValue(category, out obj); if(obj != null) { Ice.AlreadyRegisteredException ex = new Ice.AlreadyRegisteredException(); ex.kindOfObject = "default servant"; ex.id = category; throw ex; } _defaultServantMap[category] = servant; } }
public void addServantLocator(Ice.ServantLocator locator, string category) { lock (this) { Debug.Assert(_instance != null); // Must not be called after destruction. Ice.ServantLocator l; _locatorMap.TryGetValue(category, out l); if (l != null) { Ice.AlreadyRegisteredException ex = new Ice.AlreadyRegisteredException(); ex.id = IceUtilInternal.StringUtil.escapeString(category, "", _instance.toStringMode()); ex.kindOfObject = "servant locator"; throw ex; } _locatorMap[category] = locator; } }
public Ice.ObjectAdapter createObjectAdapter(string name, Ice.RouterPrx router) { lock (this) { if (_instance == null) { throw new Ice.CommunicatorDestroyedException(); } if (name.Length > 0) { if (_adapterNamesInUse.Contains(name)) { Ice.AlreadyRegisteredException ex = new Ice.AlreadyRegisteredException(); ex.kindOfObject = "object adapter"; ex.id = name; throw ex; } _adapterNamesInUse.Add(name); } } // // Must be called outside the synchronization since initialize can make client invocations // on the router if it's set. // Ice.ObjectAdapterI adapter = null; try { if (name.Length == 0) { string uuid = System.Guid.NewGuid().ToString(); adapter = new Ice.ObjectAdapterI(_instance, _communicator, this, uuid, null, true); } else { adapter = new Ice.ObjectAdapterI(_instance, _communicator, this, name, router, false); } lock (this) { if (_instance == null) { throw new Ice.CommunicatorDestroyedException(); } _adapters.Add(adapter); } } catch (Ice.CommunicatorDestroyedException ex) { if (adapter != null) { adapter.destroy(); } throw ex; } catch (Ice.LocalException ex) { if (name.Length > 0) { lock (this) { _adapterNamesInUse.Remove(name); } } throw ex; } return(adapter); }
// // 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 = new List <EndpointI>(); _routerEndpoints = new List <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); if (_routerInfo != null) { // // Make sure this router is not already registered with another adapter. // if (_routerInfo.getAdapter() != null) { Ice.AlreadyRegisteredException ex = new Ice.AlreadyRegisteredException(); ex.kindOfObject = "object adapter with router"; ex.id = Ice.Util.identityToString(router.ice_getIdentity()); throw ex; } // // Add the router's server proxy endpoints to this object // adapter. // EndpointI[] endpoints = _routerInfo.getServerEndpoints(); for (int i = 0; i < endpoints.Length; ++i) { _routerEndpoints.Add(endpoints[i]); } _routerEndpoints.Sort(); // Must be sorted. // // Remove duplicate endpoints, so we have a list of unique endpoints. // for (int i = 0; i < _routerEndpoints.Count - 1;) { EndpointI e1 = _routerEndpoints[i]; EndpointI e2 = _routerEndpoints[i + 1]; if (e1.Equals(e2)) { _routerEndpoints.RemoveAt(i); } else { ++i; } } // // 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) { IncomingConnectionFactory factory = new IncomingConnectionFactory(instance, endp, 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 = parsePublishedEndpoints(); } if (properties.getProperty(_name + ".Locator").Length > 0) { setLocator(LocatorPrxHelper.uncheckedCast( instance_.proxyFactory().propertyToProxy(_name + ".Locator"))); } else { setLocator(instance_.referenceFactory().getDefaultLocator()); } } catch (LocalException) { destroy(); throw; } }
// // 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 = new List<EndpointI>(); _routerEndpoints = new List<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); if(_routerInfo != null) { // // Make sure this router is not already registered with another adapter. // if(_routerInfo.getAdapter() != null) { Ice.AlreadyRegisteredException ex = new Ice.AlreadyRegisteredException(); ex.kindOfObject = "object adapter with router"; ex.id = instance_.identityToString(router.ice_getIdentity()); throw ex; } // // Add the router's server proxy endpoints to this object // adapter. // EndpointI[] endpoints = _routerInfo.getServerEndpoints(); for(int i = 0; i < endpoints.Length; ++i) { _routerEndpoints.Add(endpoints[i]); } _routerEndpoints.Sort(); // Must be sorted. // // Remove duplicate endpoints, so we have a list of unique endpoints. // for(int i = 0; i < _routerEndpoints.Count-1;) { EndpointI e1 = _routerEndpoints[i]; EndpointI e2 = _routerEndpoints[i + 1]; if(e1.Equals(e2)) { _routerEndpoints.RemoveAt(i); } else { ++i; } } // // 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) { IncomingConnectionFactory factory = new IncomingConnectionFactory(instance, endp, 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 = parsePublishedEndpoints(); } if(properties.getProperty(_name + ".Locator").Length > 0) { setLocator(LocatorPrxHelper.uncheckedCast( instance_.proxyFactory().propertyToProxy(_name + ".Locator"))); } else { setLocator(instance_.referenceFactory().getDefaultLocator()); } } catch(LocalException) { destroy(); throw; } }
public void addServantLocator(Ice.ServantLocator locator, string category) { lock(this) { Debug.Assert(instance_ != null); // Must not be called after destruction. Ice.ServantLocator l; _locatorMap.TryGetValue(category, out l); if(l != null) { Ice.AlreadyRegisteredException ex = new Ice.AlreadyRegisteredException(); ex.id = IceUtilInternal.StringUtil.escapeString(category, ""); ex.kindOfObject = "servant locator"; throw ex; } _locatorMap[category] = locator; } }