예제 #1
0
        private void InstallServiceBrowserDestinations(ServiceDefinition service, AdapterDefinition adapter)
        {
            //ServiceBrowser destinations
            DestinationDefinition destination = new DestinationDefinition(service);

            destination.Id = DestinationDefinition.FluorineServiceBrowserDestination;
            destination.Properties.Source = DestinationDefinition.FluorineServiceBrowserDestination;
            destination.AdapterRef        = new AdapterRef(adapter);
            service.AddDestination(destination);

            destination    = new DestinationDefinition(service);
            destination.Id = DestinationDefinition.FluorineManagementDestination;
            destination.Properties.Source = DestinationDefinition.FluorineManagementDestination;
            destination.AdapterRef        = new AdapterRef(adapter);
            service.AddDestination(destination);

            destination    = new DestinationDefinition(service);
            destination.Id = DestinationDefinition.FluorineCodeGeneratorDestination;
            destination.Properties.Source = DestinationDefinition.FluorineCodeGeneratorDestination;
            destination.AdapterRef        = new AdapterRef(adapter);
            service.AddDestination(destination);

            destination    = new DestinationDefinition(service);
            destination.Id = DestinationDefinition.FluorineSqlServiceDestination;
            destination.Properties.Source = DestinationDefinition.FluorineSqlServiceDestination;
            destination.AdapterRef        = new AdapterRef(adapter);
            service.AddDestination(destination);
        }
 /// <summary>
 /// Initializes the current Destination.
 /// </summary>
 /// <param name="adapterDefinition">Adapter definition.</param>
 public override void Init(AdapterDefinition adapterDefinition)
 {
     //For remoting destinations it is ok to use the default 'dotnet' adapter if no adapter was specified for the service
     if (adapterDefinition == null && this.DestinationDefinition != null && this.DestinationDefinition.Service != null)
     {
         adapterDefinition = this.DestinationDefinition.Service.GetDefaultAdapter();
     }
     base.Init(adapterDefinition);
 }
예제 #3
0
        public void UpdateAdapter(AdapterDefinition adapterDefinition)
        {
            try
            {
                configurator.UpdateAdapter(adapterDefinition);

                scheduledJobManager.QueueScheduledJobs(clearExistingScheduledJobInstancesFromWaitingQueue: true);
            }
            catch (Exception ex)
            {
                SyncEngineLogger.WriteExceptionToLog(ex, WEB_SERVICE_EXCEPTION_MESSAGE);

                throw;
            }
        }
예제 #4
0
        /// <summary>
        /// Initializes the current Destination.
        /// </summary>
        /// <param name="adapterDefinition">Adapter definition.</param>
        public virtual void Init(AdapterDefinition adapterDefinition)
        {
            if (_initialized)
            {
                throw new NotSupportedException(__Res.GetString(__Res.Destination_Reinit, this.Id, this.GetType().Name));
            }
            _initialized = true;
            if (adapterDefinition != null)
            {
                string typeName = adapterDefinition.Class;
                Type   type     = ObjectFactory.Locate(typeName);
                if (type != null)
                {
                    _adapter = ObjectFactory.CreateInstance(type) as ServiceAdapter;
                    _adapter.SetDestination(this);
                    _adapter.SetAdapterSettings(adapterDefinition);
                    _adapter.SetDestinationSettings(_destinationDefinition);
                    _adapter.Init();
                }
                else
                {
                    log.Error(__Res.GetString(__Res.Type_InitError, adapterDefinition.Class));
                }
            }
            else
            {
                log.Error(__Res.GetString(__Res.MessageServer_MissingAdapter, this.Id, this.GetType().Name));
            }
            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();
            }
        }
예제 #5
0
        internal ServiceBase(MessageBroker messageBroker, ServiceDefinition serviceDefinition)
        {
            _messageBroker     = messageBroker;
            _serviceDefinition = serviceDefinition;

            _destinations = new Hashtable();
            if (this.ServiceDefinition.Destinations != null)
            {
                foreach (DestinationDefinition destinationDefinition in this.ServiceDefinition.Destinations)
                {
                    AdapterDefinition adapterDefinition = null;
                    AdapterRef        adapterRef        = destinationDefinition.AdapterRef;
                    if (adapterRef != null)
                    {
                        adapterDefinition = serviceDefinition.GetAdapterByRef(adapterRef.Ref);
                    }
                    else
                    {
                        adapterDefinition = serviceDefinition.GetDefaultAdapter();
                    }
                    CreateDestination(destinationDefinition, adapterDefinition);
                }
            }
        }
예제 #6
0
        /// <summary>
        /// This method supports the Fluorine infrastructure and is not intended to be used directly from your code.
        /// </summary>
        /// <param name="configFolderPaths">Possible configuration file locations.</param>
        /// <param name="serviceBrowserAvailable">Indicates whether the service browser is avaliable.</param>
        public void Init(string[] configFolderPaths, bool serviceBrowserAvailable)
        {
            _messageBroker = new MessageBroker(this);

            string servicesConfigFile = null;

            for (int i = 0; i < configFolderPaths.Length; i++)
            {
                servicesConfigFile = Path.Combine(configFolderPaths[i], "services-config.xml");
                if (log.IsDebugEnabled)
                {
                    log.Debug(__Res.GetString(__Res.MessageServer_TryingServiceConfig, servicesConfigFile));
                }
                if (File.Exists(servicesConfigFile))
                {
                    break;
                }
            }
            if (servicesConfigFile != null && File.Exists(servicesConfigFile))
            {
                if (log.IsDebugEnabled)
                {
                    log.Debug(__Res.GetString(__Res.MessageServer_LoadingServiceConfig, servicesConfigFile));
                }
                _servicesConfiguration = ServicesConfiguration.Load(servicesConfigFile);
            }
            else
            {
                if (log.IsDebugEnabled)
                {
                    log.Debug(__Res.GetString(__Res.MessageServer_LoadingConfigDefault));
                }
                _servicesConfiguration = ServicesConfiguration.CreateDefault();
            }

            foreach (ChannelDefinition channelDefinition in _servicesConfiguration.Channels)
            {
                Type type = ObjectFactory.Locate(FluorineConfiguration.Instance.ClassMappings.GetType(channelDefinition.Endpoint.Class));
                if (type != null)
                {
                    IEndpoint endpoint = ObjectFactory.CreateInstance(type, new object[] { _messageBroker, channelDefinition }) as IEndpoint;
                    if (endpoint != null)
                    {
                        _messageBroker.AddEndpoint(endpoint);
                    }
                }
                else
                {
                    log.Error(__Res.GetString(__Res.Type_InitError, channelDefinition.Class));
                }
            }
            ChannelDefinition rtmptChannelDefinition = new ChannelDefinition();

            rtmptChannelDefinition.Id = RtmptEndpoint.FluorineRtmptEndpointId;
            IEndpoint rtmptEndpoint = new RtmptEndpoint(_messageBroker, rtmptChannelDefinition);

            _messageBroker.AddEndpoint(rtmptEndpoint);

            if (_servicesConfiguration.Factories != null)
            {
                foreach (Factory factory in _servicesConfiguration.Factories)
                {
                    Type type = ObjectFactory.Locate(FluorineConfiguration.Instance.ClassMappings.GetType(factory.Class));
                    if (type != null)
                    {
                        IFlexFactory flexFactory = ObjectFactory.CreateInstance(type, new object[0]) as IFlexFactory;
                        if (flexFactory != null)
                        {
                            _messageBroker.AddFactory(factory.Id, flexFactory);
                        }
                    }
                    else
                    {
                        log.Error(__Res.GetString(__Res.Type_InitError, factory.Class));
                    }
                }
            }
            //Add the dotnet Factory
            _messageBroker.AddFactory(DotNetFactory.Id, new DotNetFactory());

            if (serviceBrowserAvailable)
            {
                ServiceDefinition serviceConfiguration = _servicesConfiguration.GetServiceByClass("flex.messaging.services.RemotingService");
                if (serviceConfiguration != null)
                {
                    AdapterDefinition adapter = serviceConfiguration.GetAdapterByClass(typeof(Remoting.RemotingAdapter).FullName);
                    if (adapter != null)
                    {
                        InstallServiceBrowserDestinations(serviceConfiguration, adapter);
                    }
                    else
                    {
                        adapter = serviceConfiguration.GetDefaultAdapter();
                        if (adapter != null)
                        {
                            InstallServiceBrowserDestinations(serviceConfiguration, adapter);
                        }
                    }
                }
            }
            if (_servicesConfiguration.Services.ServiceDefinitions != null)
            {
                foreach (ServiceDefinition serviceDefinition in _servicesConfiguration.Services.ServiceDefinitions)
                {
                    Type type = ObjectFactory.Locate(FluorineConfiguration.Instance.ClassMappings.GetType(serviceDefinition.Class));//current assembly only
                    if (type != null)
                    {
                        IService service = ObjectFactory.CreateInstance(type, new object[] { _messageBroker, serviceDefinition }) as IService;
                        if (service != null)
                        {
                            _messageBroker.AddService(service);
                        }
                    }
                    else
                    {
                        log.Error(__Res.GetString(__Res.Type_InitError, serviceDefinition.Class));
                    }
                }
            }
            if (_servicesConfiguration.Services.Includes != null)
            {
                foreach (ServiceInclude include in _servicesConfiguration.Services.Includes)
                {
                    ServiceDefinition serviceDefinition = include.ServiceDefinition;
                    Type type = ObjectFactory.Locate(FluorineConfiguration.Instance.ClassMappings.GetType(serviceDefinition.Class));//current assembly only
                    if (type != null)
                    {
                        IService service = ObjectFactory.CreateInstance(type, new object[] { _messageBroker, serviceDefinition }) as IService;
                        if (service != null)
                        {
                            _messageBroker.AddService(service);
                        }
                    }
                    else
                    {
                        log.Error(__Res.GetString(__Res.Type_InitError, serviceDefinition.Class));
                    }
                }
            }
            if (_servicesConfiguration.Security != null)
            {
                if (_servicesConfiguration.Security.LoginCommands != null && _servicesConfiguration.Security.LoginCommands.Length > 0)
                {
                    LoginCommand loginCommand = _servicesConfiguration.Security.GetLoginCommand(LoginCommand.FluorineLoginCommand);
                    if (loginCommand != null)
                    {
                        Type type = ObjectFactory.Locate(FluorineConfiguration.Instance.ClassMappings.GetType(loginCommand.Class));
                        if (type != null)
                        {
                            ILoginCommand loginCommandObj = ObjectFactory.CreateInstance(type, new object[] { }) as ILoginCommand;
                            _messageBroker.LoginManager.LoginCommand = loginCommandObj;
                            _messageBroker.LoginManager.IsPerClientAuthentication = loginCommand.IsPerClientAuthentication;
                        }
                        else
                        {
                            log.Error(__Res.GetString(__Res.Type_InitError, loginCommand.Class));
                        }
                    }
                    else
                    {
                        log.Error(__Res.GetString(__Res.Type_InitError, "<<LoginCommand class>>"));
                    }
                }
            }
            InitAuthenticationService();

            try
            {
                if (FluorineConfiguration.Instance.FluorineSettings.Silverlight.PolicyServerSettings != null &&
                    FluorineConfiguration.Instance.FluorineSettings.Silverlight.PolicyServerSettings.Enable)
                {
                    IResource resource;
                    if (FluorineContext.Current != null)
                    {
                        resource = FluorineContext.Current.GetResource(FluorineConfiguration.Instance.FluorineSettings.Silverlight.PolicyServerSettings.PolicyFile);
                    }
                    else
                    {
                        resource = new FileSystemResource(FluorineConfiguration.Instance.FluorineSettings.Silverlight.PolicyServerSettings.PolicyFile);
                    }
                    if (resource.Exists)
                    {
                        log.Info(__Res.GetString(__Res.Silverlight_StartPS, resource.File.FullName));
                        _policyServer = new PolicyServer(resource.File.FullName);
                    }
                    else
                    {
                        throw new FileNotFoundException("Policy file not found", FluorineConfiguration.Instance.FluorineSettings.Silverlight.PolicyServerSettings.PolicyFile);
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(__Res.GetString(__Res.Silverlight_PSError), ex);
            }
        }
예제 #7
0
        /// <summary>
        /// Creates a destination with the specified settings.
        /// </summary>
        /// <param name="destinationDefinition">Destination settings.</param>
        /// <param name="adapterDefinition">Adapter settings.</param>
        /// <returns>The created destination instance.</returns>
        public virtual Destination CreateDestination(DestinationDefinition destinationDefinition, AdapterDefinition adapterDefinition)
        {
            lock (_objLock)
            {
                if (!_destinations.ContainsKey(destinationDefinition.Id))
                {
                    Destination destination = NewDestination(destinationDefinition);
                    destination.Init(adapterDefinition);

                    /*
                     * if (destinationDefinition.Adapter != null)
                     *  destination.Init(destinationSettings.Adapter);
                     *                  else
                     *  destination.Init(_serviceSettings.DefaultAdapter);
                     */
                    _destinations[destination.Id] = destination;

                    string source = destination.DestinationDefinition.Properties.Source;
                    //TODO: warn if more then one "*" source occurs.
                    if (source != null && source == "*")
                    {
                        _defaultDestination = destination;
                    }
                    return(destination);
                }
                else
                {
                    return(_destinations[destinationDefinition.Id] as Destination);
                }
            }
        }
 internal void SetAdapterSettings(AdapterDefinition value)
 {
     _adapterDefinition = value;
 }