Esempio n. 1
0
        protected virtual ActorBase CreateNewActorInstance()
        {
            var actor = _props.NewActor();
            var initializableActor = actor as InitializableActor;

            if (initializableActor != null)
            {
                initializableActor.Init();
            }
            return(actor);
        }
Esempio n. 2
0
 public virtual void NewActor()
 {
     //set the thread static context or things will break
     UseThreadContext(() =>
     {
         behaviorStack.Clear();
         ActorBase instance          = Props.NewActor();
         instance.supervisorStrategy = Props.SupervisorStrategy;
         //defaults to null - won't affect lazy instantion unless explicitly set in props
         instance.AroundPreStart();
     });
 }
Esempio n. 3
0
        /// <summary>
        /// TBD
        /// </summary>
        /// <returns>TBD</returns>
        protected virtual ActorBase CreateNewActorInstance()
        {
            var actor = _props.NewActor();

            // Apply default of custom behaviors to actor.
            var pipeline = _systemImpl.ActorPipelineResolver.ResolvePipeline(actor.GetType());

            pipeline.AfterActorIncarnated(actor, this);

            if (actor is IInitializableActor initializableActor)
            {
                initializableActor.Init();
            }
            return(actor);
        }
Esempio n. 4
0
        protected virtual ActorBase CreateNewActorInstance()
        {
            var actor = _props.NewActor();

            //Check if the actor needs a stash
            var actorStash = actor as IActorStash;

            if (actorStash != null && actorStash.Stash == null)
            {
                //Only assign a new stash if one hasn't been created by the actor already
                actorStash.Stash = StashFactory.CreateStash(this, actorStash);
            }

            var initializableActor = actor as InitializableActor;

            if (initializableActor != null)
            {
                initializableActor.Init();
            }
            return(actor);
        }
        /// <summary>
        ///     Faults the recreate.
        /// </summary>
        /// <param name="m">The m.</param>
        private void FaultRecreate(Recreate m)
        {
            isTerminating = false;
            ActorBase failedActor = Actor;

            object optionalMessage = CurrentMessage;

            if (System.Settings.DebugLifecycle)
            {
                Publish(new Debug(Self.Path.ToString(), failedActor.GetType(), "restarting"));
            }

            try
            {
                failedActor.AroundPreRestart(m.Cause, optionalMessage);
            }
            catch (Exception e)
            {
                HandleNonFatalOrInterruptedException(() =>
                {
                    var ex = new PreRestartException(Self, e, m.Cause, optionalMessage);
                    Publish(new Error(ex, Self.Path.ToString(), failedActor.GetType(), e.Message));
                });
            }

            UseThreadContext(() =>
            {
                behaviorStack.Clear(); //clear earlier behaviors

                ActorBase created = Props.NewActor();
                //ActorBase will register itself as the actor of this context

                if (System.Settings.DebugLifecycle)
                {
                    Publish(new Debug(Self.Path.ToString(), created.GetType(), "started (" + created + ")"));
                }
                created.AroundPostRestart(m.Cause, null);
            });
        }
Esempio n. 6
0
 protected virtual ActorBase CreateNewActorInstance()
 {
     return(_props.NewActor());
 }