Exemple #1
0
        private void Init(IServiceMQ mq, IDictionary serviceKeyTypes)
        {
            if (System.Configuration.ConfigurationManager.GetSection("castle") != null)
            {
                container = new WindsorContainer(new XmlInterpreter());
            }
            else
            {
                container = new WindsorContainer();
            }
            container.AddFacility("startable", new StartableFacility());
            this.mq = mq;
            container.Kernel.AddComponentInstance("NBear.IoC.Service.IServiceMQ", typeof(IServiceMQ), mq);
            container.AddFacility("service subscribe message reqMsg", new Facilities.ServiceSubscribeMessageRequestFacility(mq));

            if (serviceKeyTypes != null && serviceKeyTypes.Count > 0)
            {
                RegisterComponents(serviceKeyTypes);
            }

            serviceProxy        = new ServiceProxy(mq, DEFAULT_MAX_TRY_NUMBER);
            serviceProxy.OnLog += new LogHandler(WriteLog);

            this.DiscoverServices();
        }
Exemple #2
0
        /// <summary>
        /// Creates this instance.
        /// </summary>
        /// <returns>The service factoru singleton instance.</returns>
        public static ServiceFactory Create()
        {
            if (singleton == null)
            {
                Configuration.ServiceFactoryConfigurationSection config = LoadServiceFactoryConfiguration();

                if (config.Type == NBear.IoC.Service.Configuration.ServiceFactoryType.Local)
                {
                    singleton = new ServiceFactory(new SimpleServiceContainer());
                }
                else
                {
                    RemotingClientHelper helper = new RemotingClientHelper(config.Protocol, config.Server, config.Port, 0);
                    IServiceMQ           mq     = helper.GetWellKnownClientInstance <IServiceMQ>(config.ServiceMQName);
                    singleton = new ServiceFactory(new SimpleServiceContainer(mq));
                }
                singleton.ServiceContainer.Compress  = config.Compress;
                singleton.ServiceContainer.MaxTryNum = config.MaxTry;
            }

            return(singleton);
        }
Exemple #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ServiceSubscribeMessageRequestFacility"/> class.
 /// </summary>
 /// <param name="mq">The mq.</param>
 public ServiceSubscribeMessageRequestFacility(IServiceMQ mq)
 {
     this.waitList = new ArrayList();
     this.mq       = mq;
 }
Exemple #4
0
 public ServiceProxy(IServiceMQ mq, int maxTryNum)
 {
     this.mq        = mq;
     this.maxTryNum = maxTryNum;
 }
Exemple #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MessageRequestCallbackHandler"/> class.
 /// </summary>
 /// <param name="mq">The mq.</param>
 /// <param name="service">The service.</param>
 public MessageRequestCallbackHandler(IServiceMQ mq, IService service)
 {
     this.mq      = mq;
     this.service = service;
 }
Exemple #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MathService"/> class.
 /// </summary>
 /// <param name="mq">The mq.</param>
 public MathService(IServiceMQ mq)
     : base("demo.math", mq)
 {
 }
Exemple #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SimpleServiceContainer"/> class.
 /// </summary>
 /// <param name="mq">The mq.</param>
 /// <param name="serviceKeyTypes">The service key types.</param>
 public SimpleServiceContainer(IServiceMQ mq, IDictionary serviceKeyTypes)
 {
     Init(mq, serviceKeyTypes);
 }
Exemple #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SimpleServiceContainer"/> class.
 /// </summary>
 /// <param name="mq">The mq.</param>
 public SimpleServiceContainer(IServiceMQ mq)
 {
     Init(mq, null);
 }
Exemple #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BaseService"/> class.
 /// </summary>
 /// <param name="serviceName">Name of the service.</param>
 /// <param name="mq">The mq.</param>
 public BaseService(string serviceName, IServiceMQ mq)
 {
     this.serviceName = serviceName;
     this.mq          = mq;
     clientId         = Guid.NewGuid();
 }
Exemple #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BaseAutoService"/> class.
 /// </summary>
 /// <param name="serviceName">Name of the service.</param>
 /// <param name="mq">The mq.</param>
 public BaseAutoService(string serviceName, IServiceMQ mq)
     : base(serviceName, mq)
 {
 }