Ejemplo n.º 1
0
        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();
            }
        }
Ejemplo n.º 2
0
        /// <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());
        }
Ejemplo n.º 3
0
        /// <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);
        }