Castle Windsor Component registration of multiple interface on a single service

2,168 views
Skip to first unread message

barroei

unread,
Aug 29, 2010, 2:49:34 AM8/29/10
to Castle Project Users
hello.

i am trying to implement multiple Service Contracts via a single WCF.

i am trying to run this code:

return new WindsorContainer()
.AddFacility<WcfFacility>()
.Register(
Component.For<IServiceBehavior>().Instance(metadata),
Component.For<IServiceBehavior>().Instance(debug),
Component
.For<IBlogService>()
.ImplementedBy<DefaultBlogService>()
.Named("blogService")
.LifeStyle.Transient
.ActAs(new DefaultServiceModel().Hosted()
.AddEndpoints(
WcfEndpoint.BoundTo(new
BasicHttpBinding()))),
Component
.For<IBlogServiceAlternate>()
.ImplementedBy<AlternateBlogService>()
.Named("blogService")
.LifeStyle.Transient
.ActAs(new DefaultServiceModel().Hosted()
.AddEndpoints(
WcfEndpoint.BoundTo(new
BasicHttpBinding()))),


Component
.For<ILogger>()
.ImplementedBy<DefaultLogger>()
.LifeStyle.Transient
);
but it tells me that the "blogservice" is already registered. i am
loading 2 differant Interfaces which are implemented via differant
classes. and i got stuck in this point.

i cant use the :

Component.For<IFirst,ISecond>()

option since i need the ImplementBy to be
<First,Second>

meaning that IFirst will be implementedBy First
and
ISecond will be ImplementedBy Second

Ayende Rahien

unread,
Aug 29, 2010, 3:05:19 AM8/29/10
to castle-pro...@googlegroups.com
You need different names


--
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.


barroei

unread,
Aug 29, 2010, 7:16:57 AM8/29/10
to Castle Project Users
i cant use different names.
its the same service.
i want it to have multiple interfaces.

meaning multiple servicecontracts on the same service.

i can easily do it if implement all interfaces by the same class.
but i want it to be generic and have an implementation class per each
interface
> > castle-project-u...@googlegroups.com<castle-project-users%2Bun­subs...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/castle-project-users?hl=en.- Hide quoted text -
>
> - Show quoted text -

Krzysztof Koźmic

unread,
Aug 29, 2010, 7:19:54 AM8/29/10
to castle-pro...@googlegroups.com

This doesn't make any sense.

sent from my HTC Desire

On 29/08/2010 9:16 PM, "barroei" <bar.ro...@gmail.com> wrote:

i cant use different names.
its the same service.
i want it to have multiple interfaces.

meaning multiple servicecontracts on the same service.

i can easily do it if implement all interfaces by the same class.
but i want it to be generic and have an implementation class per each
interface


On Aug 29, 10:05 am, Ayende Rahien <aye...@ayende.com> wrote:
> You need different names
>
>
>

> On Sun, Aug 29, 2010 at 9:49 AM, barroei <bar.roei.w...@gmail.com> wrote:
> > hello.
>

> > i am tr...

> > castle-project-u...@googlegroups.com<castle-project-users%2Bun­subs...@googlegroups.com>

> > .
> > For more options, visit this group at

> >http://groups.google.com/group/castle-project-users?hl=en.- Hide quoted text -
>
> - Show quoted text -


--

You received this message because you are subscribed to the Google Groups "Castle Project Users" gro...

barroei

unread,
Aug 29, 2010, 7:41:12 AM8/29/10
to Castle Project Users
why doesnt it make sense?

i want to make the entire service generic.

add Interfaces dynamicaly and add the Implementation class that is
attached to it.
without touching the once that are already registered.

there must be an option to do it.

is there an option to tell the Implementation class to implement
another interface ?
and load the interface implementation as a dependency class?



On Aug 29, 2:19 pm, Krzysztof Koźmic <krzysztof.koz...@gmail.com>
wrote:
> This doesn't make any sense.
>
> sent from my HTC Desire
>
> On 29/08/2010 9:16 PM, "barroei" <bar.roei.w...@gmail.com> wrote:
>
> i cant use different names.
> its the same service.
> i want it to have multiple interfaces.
>
> meaning multiple servicecontracts on the same service.
>
> i can easily do it if implement all interfaces by the same class.
> but i want it to be generic and have an implementation class per each
> interface
>
> On Aug 29, 10:05 am, Ayende Rahien <aye...@ayende.com> wrote:
>
> > You need different names
>
> > On Sun, Aug 29, 2010 at 9:49 AM, barroei <bar.roei.w...@gmail.com> wrote:
> > > hello.
>
> > > i am tr...
> > > castle-project-u...@googlegroups.com<castle-project-users%2Bun­subs...@googlegroups.com>
>
> <castle-project-users%2Bun­subs...@googlegroups.com>
>
>
>
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/castle-project-users?hl=en.-Hide quoted

Krzysztof Koźmic

unread,
Aug 29, 2010, 7:48:18 AM8/29/10
to castle-pro...@googlegroups.com
Can we step back a little?

What are you trying to do? Container aside.

barroei

unread,
Aug 29, 2010, 7:52:35 AM8/29/10
to Castle Project Users, Krzysztof Koźmic
do u have google talk ? or msn? it will be much easier...

the general idea is to make a dynamic multi endpoint WCF service over
IIS

meaning i want the service to be able to load Interface dynamicly as i
am doing if i set a single Interface.

but i would also like to make it so that the Interface and
Implementation are built by differant users

meaning that every user that will built an Interface will also build
his very own Implementation.

and via configuration i will have the service register them.



On Aug 29, 2:48 pm, Krzysztof Koźmic <krzyszto...@gmail.com>
wrote:
> >> "Castle Project Users" gro...- Hide quoted text -

Krzysztof Koźmic

unread,
Aug 29, 2010, 8:04:27 AM8/29/10
to barroei, Castle Project Users
ah I think I vaguely begin to see what you're trying to do

so you want an umbrella object that would implement multiple interfaces
and contain multiple other obects that each implement one of these
interfaces and then route calls to each interface to its respective
implementation object and on top of that expose everything as WCF service?

barroei

unread,
Aug 29, 2010, 8:34:29 AM8/29/10
to Castle Project Users
yep,

you got exactly the idea :-)

the thing is building it is abit complex since i cant get the howto
build the damn thing.

this is the first IOC that seems todo so, very close to what
Spring .NET does.

but still, there is something missing, and i cant get the damn thing
to work.
i have tried multiple overrides to try to use the current registration
model, but it just doesnt add up.

i can download the sources and try to fix it, but i think i am missing
something
and it can be done in the current registration model.
i just cant figure out the how...

On Aug 29, 3:04 pm, Krzysztof Koźmic <krzysztof.koz...@gmail.com>
wrote:
>   ah I think I vaguely begin to see what you're trying to do
>
> so you want an umbrella object that would implement multiple interfaces
> and contain multiple other obects that each implement one of these
> interfaces and then route calls to each interface to its respective
> implementation object and on top of that expose everything as WCF service?
>
> On 29/08/2010 9:52 PM, barroei wrote:
>
>
>
> > do u have google talk ? or msn? it will be much easier...
>
> > the general idea is to make a dynamic multi endpoint WCF service over
> > IIS
>
> > meaning i want the service to be able to load Interface dynamicly as i
> > am doing if i set a single Interface.
>
> > but i would also like to make it so that the Interface and
> > Implementation are built by differant users
>
> > meaning that every user that will built an Interface will also build
> > his very own Implementation.
>
> > and via configuration i will have the service register them.
>
> > On Aug 29, 2:48 pm, Krzysztof Koźmic<krzysztof.koz...@gmail.com>
> >> - Show quoted text -- Hide quoted text -

Krzysztof Koźmic

unread,
Aug 29, 2010, 8:40:02 AM8/29/10
to castle-pro...@googlegroups.com
Well what I think might work, is registering all the pieces separately
and then picking one of them as the host and mixing in all the remaining
ones.

container.Register(

Component.For<IFirst>().ImplementedBy<First>().Proxy.MixIns(m => m.Service<ISecond>()),

Component.For<ISecond>().ImplementedBy<Second>());

This is the idea, but I'm not sure how DynamicProxy will handle all the
WCF attributes.

barroei

unread,
Aug 29, 2010, 8:47:29 AM8/29/10
to Castle Project Users
I didnt try the proxy option yet.
but will it work with more then 2 interfaces?


On Aug 29, 3:40 pm, Krzysztof Koźmic <krzysztof.koz...@gmail.com>

Krzysztof Koźmic

unread,
Aug 29, 2010, 8:48:41 AM8/29/10
to castle-pro...@googlegroups.com
How else would you want to do it than via dynamic proxy? Again -
container aside.

barroei

unread,
Aug 29, 2010, 8:58:30 AM8/29/10
to Castle Project Users
i cant get the damn syntax for the MixIn,

i had in mind another idea, to have a single Implenetation Class, that
has dependencies to all
other Implementation classes.

that should be easier to implement wont you think?

On Aug 29, 3:48 pm, Krzysztof Koźmic <krzysztof.koz...@gmail.com>

Krzysztof Koźmic

unread,
Aug 29, 2010, 9:00:55 AM8/29/10
to castle-pro...@googlegroups.com
I forgot to add you need version 2.5 to get that Mixin syntax.

Yes you can have one implementation that forwards to other
implementation but I thought you mentioned you wanted this to be dynamic...

barroei

unread,
Aug 29, 2010, 9:08:10 AM8/29/10
to Castle Project Users
i can have the implementaion class also as a container class

On Aug 29, 4:00 pm, Krzysztof Koźmic <krzysztof.koz...@gmail.com>

Krzysztof Koźmic

unread,
Aug 29, 2010, 9:17:55 AM8/29/10
to castle-pro...@googlegroups.com
Yes but it won't be dynamic. It has to implement interfaces it
exposes, and a type can't gain an interface dynamically.

barroei

unread,
Aug 29, 2010, 9:27:19 AM8/29/10
to Castle Project Users
oh, ok, that is one i missed :-)

tell me is there a built on WCFIntegration.Dll that support 2.5
version
cause if i remove the MicroKernel Dll it says that :

The type 'Castle.MicroKernel.Facilities.AbstractFacility' is defined
in an assembly that is not referenced. You must add a reference to
assembly 'Castle.MicroKernel, Version=1.0.3.0, Culture=neutral,
PublicKeyToken=407dd0808d44fbdc'.

On Aug 29, 4:17 pm, Krzysztof Koźmic <krzysztof.koz...@gmail.com>

Krzysztof Koźmic

unread,
Aug 29, 2010, 9:30:26 AM8/29/10
to castle-pro...@googlegroups.com
I'm not sure if it's updated already, check the version:
http://builds.castleproject.org/viewLog.html?buildId=7085&buildTypeId=bt102&tab=artifacts

barroei

unread,
Aug 29, 2010, 10:00:52 AM8/29/10
to Castle Project Users
ok, i made it work by rebuilding the latest build.

now i will try the idea you gave. i will keep you updated on the
results.

thx for now mate

On Aug 29, 4:30 pm, Krzysztof Koźmic <krzysztof.koz...@gmail.com>
wrote:
>   I'm not sure if it's updated already, check the version:http://builds.castleproject.org/viewLog.html?buildId=7085&buildTypeId...

barroei

unread,
Aug 29, 2010, 10:35:47 AM8/29/10
to Castle Project Users
well, i tried the Proxy mixins
it did nothing, compile and runtime are OK, but the WSDL didnt contain
the second interface

On 29 אוגוסט, 17:00, barroei <bar.roei.w...@gmail.com> wrote:
> ok, i made it work by rebuilding the latest build.
>
> now i will try the idea you gave. i will keep you updated on the
> results.
>
> thx for now mate
>
> On Aug 29, 4:30 pm, Krzysztof Ko¼mic <krzysztof.koz...@gmail.com>
> wrote:
>
>
>
> >   I'm not sure if it's updated already, check the version:http://builds.castleproject.org/viewLog.html?buildId=7085&buildTypeId...
>
> > On 29/08/2010 11:27 PM, barroei wrote:
>
> > > oh, ok, that is one i missed :-)
>
> > > tell me is there a built on WCFIntegration.Dll that support 2.5
> > > version
> > > cause if i remove the MicroKernel Dll it says that :
>
> > > The type 'Castle.MicroKernel.Facilities.AbstractFacility' is defined
> > > in an assembly that is not referenced. You must add a reference to
> > > assembly 'Castle.MicroKernel, Version=1.0.3.0, Culture=neutral,
> > > PublicKeyToken=407dd0808d44fbdc'.
>
> > > On Aug 29, 4:17 pm, Krzysztof Ko¼mic<krzysztof.koz...@gmail.com>
> > > wrote:
> > >>    Yes but it won't be dynamic. It has to implement interfaces it
> > >> exposes, and a type can't gain an interface dynamically.
>
> > >> On 29/08/2010 11:08 PM, barroei wrote:
>
> > >>> i can have the implementaion class also as a container class
> > >>> On Aug 29, 4:00 pm, Krzysztof Ko¼mic<krzysztof.koz...@gmail.com>
> > >>> wrote:
> > >>>>     I forgot to add you need version 2.5 to get that Mixin syntax.
> > >>>> Yes you can have one implementation that forwards to other
> > >>>> implementation but I thought you mentioned you wanted this to be dynamic...
> > >>>> On 29/08/2010 10:58 PM, barroei wrote:
> > >>>>> i cant get the damn syntax for the MixIn,
> > >>>>> i had in mind another idea, to have a single Implenetation Class, that
> > >>>>> has dependencies to all
> > >>>>> other Implementation classes.
> > >>>>> that should be easier to implement wont you think?
> > >>>>> On Aug 29, 3:48 pm, Krzysztof Ko¼mic<krzysztof.koz...@gmail.com>
> > >>>>> wrote:
> > >>>>>>      How else would you want to do it than via dynamic proxy? Again -
> > >>>>>> container aside.
> > >>>>>> On 29/08/2010 10:47 PM, barroei wrote:
> > >>>>>>> I didnt try the proxy option yet.
> > >>>>>>> but will it work with more then 2 interfaces?
> > >>>>>>> On Aug 29, 3:40 pm, Krzysztof Ko¼mic<krzysztof.koz...@gmail.com>
> > >>>>>>> wrote:
> > >>>>>>>>       Well what I think might work, is registering all the pieces separately
> > >>>>>>>> and then picking one of them as the host and mixing in all the remaining
> > >>>>>>>> ones.
> > >>>>>>>>                  container.Register(
> > >>>>>>>>                      Component.For<IFirst>().ImplementedBy<First>().Proxy.MixIns(m =>          m.Service<ISecond>()),
> > >>>>>>>>                      Component.For<ISecond>().ImplementedBy<Second>());
> > >>>>>>>> This is the idea, but I'm not sure how DynamicProxy will handle all the
> > >>>>>>>> WCF attributes.
> > >>>>>>>> On 29/08/2010 10:34 PM, barroei wrote:
> > >>>>>>>>> yep,
> > >>>>>>>>> you got exactly the idea :-)
> > >>>>>>>>> the thing is building it is abit complex since i cant get the howto
> > >>>>>>>>> build the damn thing.
> > >>>>>>>>> this is the first IOC that seems todo so, very close to what
> > >>>>>>>>> Spring .NET does.
> > >>>>>>>>> but still, there is something missing, and i cant get the damn thing
> > >>>>>>>>> to work.
> > >>>>>>>>> i have tried multiple overrides to try to use the current registration
> > >>>>>>>>> model, but it just doesnt add up.
> > >>>>>>>>> i can download the sources and try to fix it, but i think i am missing
> > >>>>>>>>> something
> > >>>>>>>>> and it can be done in the current registration model.
> > >>>>>>>>> i just cant figure out the how...
> > >>>>>>>>> On Aug 29, 3:04 pm, Krzysztof Ko¼mic<krzysztof.koz...@gmail.com>
> > >>>>>>>>> wrote:
> > >>>>>>>>>>        ah I think I vaguely begin to see what you're trying to do
> > >>>>>>>>>> so you want an umbrella object that would implement multiple interfaces
> > >>>>>>>>>> and contain multiple other obects that each implement one of these
> > >>>>>>>>>> interfaces and then route calls to each interface to its respective
> > >>>>>>>>>> implementation object and on top of that expose everything as WCF service?
> > >>>>>>>>>> On 29/08/2010 9:52 PM, barroei wrote:
> > >>>>>>>>>>> do u have google talk ? or msn? it will be much easier...
> > >>>>>>>>>>> the general idea is to make a dynamic multi endpoint WCF service over
> > >>>>>>>>>>> IIS
> > >>>>>>>>>>> meaning i want the service to be able to load Interface dynamicly as i
> > >>>>>>>>>>> am doing if i set a single Interface.
> > >>>>>>>>>>> but i would also like to make it so that the Interface and
> > >>>>>>>>>>> Implementation are built by differant users
> > >>>>>>>>>>> meaning that every user that will built an Interface will also build
> > >>>>>>>>>>> his very own Implementation.
> > >>>>>>>>>>> and via configuration i will have the service register them.
> > >>>>>>>>>>> On Aug 29, 2:48 pm, Krzysztof Ko¼mic<krzysztof.koz...@gmail.com>
> > >>>>>>>>>>> wrote:
> > >>>>>>>>>>>>         Can we step back a little?
> > >>>>>>>>>>>> What are you trying to do? Container aside.
> > >>>>>>>>>>>> On 29/08/2010 9:41 PM, barroei wrote:
> > >>>>>>>>>>>>> why doesnt it make sense?
> > >>>>>>>>>>>>> i want to make the entire service generic.
> > >>>>>>>>>>>>> add Interfaces dynamicaly and add the Implementation class that is
> > >>>>>>>>>>>>> attached to it.
> > >>>>>>>>>>>>> without touching the once that are already registered.
> > >>>>>>>>>>>>> there must be an option to do it.
> > >>>>>>>>>>>>> is there an option to tell the Implementation class to implement
> > >>>>>>>>>>>>> another interface ?
> > >>>>>>>>>>>>> and load the interface implementation as a dependency class?
> > >>>>>>>>>>>>> On Aug 29, 2:19 pm, Krzysztof Ko¼mic<krzysztof.koz...@gmail.com>
> > - Show quoted text --הסתר טקסט מצוטט-
>
> -הראה טקסט מצוטט-

barroei

unread,
Aug 30, 2010, 10:21:10 AM8/30/10
to Castle Project Users
using the ProxyMixIns doesnt seem to work

here is the current Code

i am trying to implement the following:

return new WindsorContainer()
.AddFacility<WcfFacility>()
.Register(

Component.For<IServiceBehavior>().Instance(metadata),
Component.For<IServiceBehavior>().Instance(debug),
//Component
// .For<IBlogServiceAlternate>()
// .ImplementedBy<AlternateBlogService>()
// .LifeStyle.Transient,
Component
.For<IBlogService, IBlogServiceAlternate>()
.ImplementedBy<DefaultBlogService>()
.Named("blogService")
.LifeStyle.Transient
.ActAs(new DefaultServiceModel().Hosted()
.AddBaseAddresses("http://localhost:50388/
BlogService.svc")
.AddEndpoints(WcfEndpoint.ForContract(typeof(IBlogService)).BoundTo(new
BasicHttpBinding()).At("/BlogService"),

WcfEndpoint.ForContract(typeof(IBlogServiceAlternate)).BoundTo(new
BasicHttpBinding()).At("/BlogServiceAlternate"))),

Component
.For<ILogger>()
.ImplementedBy<DefaultLogger>()
.LifeStyle.Transient
);

this code works gr8, but i want that IBlogService will be Implemented
By DefaultBlogService
and IBlogServiceAlternate will be Implemented by BlogServiceAlternate

i tried playing around with :

Proxy.MixIns(m => m.Service<IBlogServiceAlternate>)
but the thing i cant get the Service WSDL to add the new Interface.

maybe someone tried using Interceptors for doing it?
> > -הראה טקסט מצוטט--הסתר טקסט מצוטט-
>
> -הראה טקסט מצוטט-

Roei Bar

unread,
Aug 30, 2010, 10:51:12 AM8/30/10
to castle-pro...@googlegroups.com

using the ProxyMixIns doesnt seem to work

here is the current Code

i am trying to implement the following:


   return new WindsorContainer()
               .AddFacility<WcfFacility>()
               .Register(

Component.For<IServiceBehavior>().Instance(metadata),
                   Component.For<IServiceBehavior>().Instance(debug),

                   //Component

                   //    .For<IBlogServiceAlternate>()
                   //    .ImplementedBy<AlternateBlogService>()
                   //    .LifeStyle.Transient,
                   Component

                       .For<IBlogService, IBlogServiceAlternate>()

                       .ImplementedBy<DefaultBlogService>()
                       .Named("blogService")
                       .LifeStyle.Transient
                       .ActAs(new DefaultServiceModel().Hosted()

                           .AddBaseAddresses("http://localhost:50388/


BlogService.svc")
                           .AddEndpoints(WcfEndpoint.ForContract(typeof(IBlogService)).BoundTo(new
BasicHttpBinding()).At("/BlogService"),

WcfEndpoint.ForContract(typeof(IBlogServiceAlternate)).BoundTo(new
BasicHttpBinding()).At("/BlogServiceAlternate"))),


                   Component
                       .For<ILogger>()
                       .ImplementedBy<DefaultLogger>()
                       .LifeStyle.Transient
               );

this code works gr8, but i want that IBlogService will be Implemented
By DefaultBlogService
and IBlogServiceAlternate will be Implemented by BlogServiceAlternate

i tried playing around with :

Proxy.MixIns(m =>  m.Service<IBlogServiceAlternate>)
but the thing i cant get the Service WSDL to add the new Interface.

maybe someone tried using Interceptors for doing it?

2010/8/29 Krzysztof Koźmic <krzyszto...@gmail.com>
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.
Reply all
Reply to author
Forward
0 new messages