internal void Init(AdapterSettings adapterSettings) { if (adapterSettings != null) { string typeName = adapterSettings.Class; Type type = ObjectFactory.Locate(typeName); if (type != null) { _adapter = ObjectFactory.CreateInstance(type) as ServiceAdapter; _adapter.SetDestination(this); _adapter.SetAdapterSettings(adapterSettings); _adapter.SetDestinationSettings(_settings); _adapter.Init(); } } MessageBroker messageBroker = this.Service.GetMessageBroker(); messageBroker.RegisterDestination(this, _service); //If the source has application scope create an instance here, so the service can listen for SessionCreated events for the first request if (this.Scope == "application") { FactoryInstance factoryInstance = GetFactoryInstance(); object inst = factoryInstance.Lookup(); } }
/// <summary> /// Return an instance as appropriate for this instance of the given factory. /// </summary> /// <param name="factoryInstance"></param> /// <returns></returns> public object Lookup(FactoryInstance factoryInstance) { DotNetFactoryInstance dotNetFactoryInstance = factoryInstance as DotNetFactoryInstance; if (dotNetFactoryInstance.Scope == "application") { return(dotNetFactoryInstance.ApplicationInstance); } return(dotNetFactoryInstance.CreateInstance()); }
/// <summary> /// Returns the FactoryInstance used by the Destination to create object instances. /// </summary> /// <returns></returns> public FactoryInstance GetFactoryInstance() { if (_factoryInstance != null) { return(_factoryInstance); } MessageBroker messageBroker = this.Service.GetMessageBroker(); IFlexFactory factory = messageBroker.GetFactory(this.FactoryId); Hashtable properties = _settings.Properties; _factoryInstance = factory.CreateFactoryInstance(this.Id, properties); return(_factoryInstance); }