Thanks Jakub!

On Wednesday, March 5, 2014 2:21:24 PM UTC-6, Jakub Bereżański wrote:
>
> Rhino Service Bus [1] has a similar scenario, where for each received 
> message type the bus needs to find consumers interested in processing that 
> type (or one of its base types). Consumers implement the 
> ConsumerOf<TMessage> interface, with no constraint on TMessage (unlike your 
> IExceptionHandler<TException>, but the difference is irrelevant).
>
> The relevant logic is implemented in DefaultServiceBus*.*
> GetAllNonOccasionalConsumers()[2] with help from CastleServiceLocator.
> GetAllHandlersFor()[3]. Basically the bus walks the inheritance 
> hierarchy[4] of the message currently being processed and for each type 
> T in that hierarchy it asks Windsor for components registered as 
> ConsumerOf<T> (caching reflection information for efficiency).
>
> You might want to take a look at that code and perhaps write something 
> similar as the implementation of your factory.
>
> [1] https://github.com/hibernating-rhinos/rhino-esb/
> [2] 
> https://github.com/hibernating-rhinos/rhino-esb/blob/master/Rhino.ServiceBus/Impl/DefaultServiceBus.cs#L489
> [3] 
> https://github.com/hibernating-rhinos/rhino-esb/blob/master/Rhino.ServiceBus.Castle/CastleServiceLocator.cs#L40
> [4] 
> https://github.com/hibernating-rhinos/rhino-esb/blob/master/Rhino.ServiceBus/Impl/DefaultServiceBus.cs#L447
>
> --
> Jakub Bereżański
>
> On Tuesday, March 4, 2014 6:32:20 AM UTC+1, Krzysztof Koźmic wrote:
>
>>  I don’t think it would be impossible, but there’s nothing OOTB in 
>> Windsor to support such scenario, mostly because it would be non-trivial to 
>> provide a generic solution. 
>>
>> But, if you keep track of IExceptionHandlers you register it should be 
>> fairly straightforward to then pick the right one and resolve it by name 
>> using ITypedFactoryComponentSelector
>> -- 
>> Krzysztof Kozmic
>>
>> On Tuesday, 4 March 2014 at 3:46 am, Scott_M wrote:
>>
>> Looking for good way to do selection via inheritance chain with Windsor 
>> for the following scenario:
>>
>> IExceptionHandler<T> : where T : Exception
>>
>> IException<Exception> //default IMPL
>>
>> IExceptionHandler<SqlException>  IMPL for SQL errors.
>>
>> IExceptionHandler<OracleException> IMPL for Oracle errors
>>
>> .
>> .
>> .
>> etc
>>
>>
>> So ideally you would have a typed factory interface that looks like this:
>>
>> public interface IExceptionHandlerFactory : where T : Exception
>> {
>>    IExceptionHandler<T> GetHandler(Exception ex);
>> }
>>
>> The idea being that the most specific exception handler (based upon 
>> Exception inheritance chain) is selected for creation based upon the 
>> current exception being passed in.
>>
>> Example, passing a SQLException into the factory would return 
>> IExceptionHandler<SqlException> but passing a ArgumentNullException into 
>> the factory would return IExceptionHandler<Exception>.
>>
>> Is this possible using Windsor?
>>
>>  
>>   
>> 

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/castle-project-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to