Strange behavior with StartableFacility

4 views
Skip to first unread message

Michael Davis

unread,
Mar 4, 2010, 5:29:03 PM3/4/10
to castle-pro...@googlegroups.com
Given these classes:

public class MyDependency {}

public class MyStartable : IStartable
{
    public MyStartable(MyDependency dep) {}
    public void Start() { Console.WriteLine("MyStartable started"); }
    public void Stop() { Console.WriteLine("MyStartable stopped"); }
}

and this registration code:

WindsorContainer container = new WindsorContainer();
container.AddFacility<StartableFacility>();
container.Register(Component.For<MyStartable>());

why does calling this code:

container.Register(Component.For<MyDependency>());

not cause MyStartable to be started (unless it is explicitly resolved), but calling this code:

container.AddComponent<MyDependency>();

does result in MyStartable being started?

I expected MyStartable to be started in the first case, and was thinking that it might be a bug.  I started to add a test case for it, and that's when I discovered that the AddComponent() version worked the way I expected.  Is it intended that these two registration methods behave differently, and if so, is there any documentation about the differences?

Thanks,
Michael Davis

Mauricio Scheffer

unread,
Mar 4, 2010, 10:14:50 PM3/4/10
to Castle Project Users
This looks like a bug to me... just registered an issue about this:
http://support.castleproject.org/projects/IOC/issues/view/IOC-ISSUE-195

--
Mauricio

Michael Davis

unread,
Mar 5, 2010, 2:57:51 PM3/5/10
to castle-pro...@googlegroups.com
Thanks for taking a look at this.

It looks like the issue can be fixed by modifying AbstractHandler.SetNewState() to call RaiseHandlerStateChanged() if the new value is different from the old one.  I've made this change and added a test case in my fork of the project, and everything seems to be working fine.

What's the preferred method of submitting patches now?  Should I still attach a patch to the case in Donjon, or should I send a pull request to someone on github?

Thanks,
Michael Davis

--
You received this message because you are subscribed to the Google Groups "Castle Project Users" group.
To post to this group, send email to castle-pro...@googlegroups.com.
To unsubscribe from this group, send email to castle-project-u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en.


Reply all
Reply to author
Forward
0 new messages