예제 #1
0
        protected ActorSystem([NotNull] string name, [NotNull] IBootstrapper bootstrapper)
        {
            if (bootstrapper == null)
            {
                throw new ArgumentNullException("bootstrapper");
            }
            if (bootstrapper.UniqueNameCreator == null)
            {
                throw new ArgumentException("IBootstrapper.UniqueNameCreator was null", "bootstrapper");
            }
            if (bootstrapper.LocalActorRefFactory == null)
            {
                throw new ArgumentException("IBootstrapper.LocalActorRefFactory was null", "bootstrapper");
            }

            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (name.Length == 0)
            {
                throw new ArgumentException("name");
            }
            var nameLegal = new Regex("^[a-zA-Z0-9][a-zA-Z0-9-]*$");

            if (!nameLegal.IsMatch(name))
            {
                throw new ArgumentException(
                          string.Format(
                              "Invalid ActorSystem name [{0}], must contain only word characters (i.e. [a-zA-Z0-9] plus non-leading '-')", name),
                          "name");
            }

            _name            = name;
            _rootPath        = new RootActorPath("/");
            _tempNodeHandler = new TempNodeHandler(_rootPath / "temp");
            _settings        = bootstrapper.Settings;

            _scheduler             = bootstrapper.Scheduler;
            _uniqueNameCreator     = bootstrapper.UniqueNameCreator;
            _localActorRefFactory  = bootstrapper.LocalActorRefFactory;
            _deadLetters           = bootstrapper.DeadLetterActorCreator(_rootPath / "_DeadLetter", this);
            _deadLettersMailbox    = new DeadLetterMailbox(_deadLetters);
            _actionScheduler       = bootstrapper.ActionScheduler;
            _defaultMailboxCreator = bootstrapper.DefaultMailboxCreator;
            _eventStream           = new EventStream(this);
            var standardOutLogger = new StandardOutLogger(new ChildActorPath(_rootPath, "_StandardOutLogger", LocalActorRef.UndefinedInstanceId), this);

            _eventStream.StartStandardOutLogger(standardOutLogger, _settings.StandardOutLoggerSettings);
            _logSource = "ActorSystem:" + name;
        }