Sure, nothing special there:
public class SearchFacility : AbstractFacility
{
protected override void Init()
{
Converter<IKernel, SearchEngine> CreateSearchEngine = kernel =>
{
var systemSettings = kernel.Resolve<ISystemSettings>();
SearchEnvironment.SetIndexPath(systemSettings.SearchIndexLocation);
return new SearchEngine();
};
Kernel.Register(
Component.For<SearchEngine>().UsingFactoryMethod(CreateSearchEngine),
Component.For<IFluentSearch>().ImplementedBy<FluentSearch>().LifeStyle.Transient
);
}
}
On Thursday, March 22, 2012 8:02:04 PM UTC+2, Simon wrote:
>
> Can you share your facility code?
>
> On Thu, Mar 22, 2012 at 9:22 AM, mynkow <> wrote:
>
>> Hello Simon
>>
>> I have a facility because the additional handlers are coming from a
>> plugin.
>>
>> Is there any other way because I really do not want to resolve handlers
>> on publish. The handlers are always the same and they are initialized
>> upfront because this is a web application. For winforms is other story.
>>
>> 10x
>>
>>
>> On Thursday, March 22, 2012 3:03:36 PM UTC+2, Simon wrote:
>>
>>> Hi Mynkow,
>>>
>>> One way we do this is to have the InProcessEventBus have a dependency on
>>> IKernel and resolve the dependencies when we publish to the bus.
>>>
>>> I'm not sure why you have a facility for this, facilities are use the
>>> extend de container, registrations should be done with an Installer.
>>>
>>> Simon
>>>
>>> On Thu, Mar 22, 2012 at 7:34 AM, mynkow wrote:
>>>
>>> Hi people,
>>>>
>>>> I have a web application with internal EventBus. The registration of
>>>> the component is like this:
>>>>
>>>> Component.For<IEventBus>().**ImplementedBy<InProcessEventBu**s>().OnCreate((kernel,
>>>> **eventBus) =>
>>>> {
>>>> (eventBus **as
>>>> InProcessEventBus).**RegisterAllHandlersInAssembly(**Assembly.GetAssembly(typeof(IH**aveEventHandlers)),
>>>> type => **kernel.Resolve(type));
>>>>
>>>> }
>>>>
>>>> As you can see each handler is initialized as a singleton when the
>>>> Event Bus is created. The IWindsorContainer instance is initialized in
>>>> global.asax.
>>>>
>>>> Not the problem.
>>>> I have an external facility which registers additional event handlers.
>>>> Right now I am doing it wrong. I resolve IEventBus instance within the
>>>> facility and call the RegisterAllHandlersInAssem**bly(...) method.
>>>> The facility is called with all other component registrations in
>>>> global.asax
>>>> Obviously this is wrong and I get an exception that the castle http
>>>> module is not initialized because we are still in global.asax. Can you
>>>> give
>>>> me a hint how this should be done correctly? What concept am I missing
>>>> here.
>>>>
>>>> Best regards
>>>>
>>>>
>>>> --
>>>>
>>>
>>> --
>>
>
>
--
You received this message because you are subscribed to the Google Groups
"Castle Project Users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/castle-project-users/-/km1mEfmksuIJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/castle-project-users?hl=en.