You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jose Luis Sanchez <jo...@m-centric.com> on 2011/10/06 16:03:04 UTC

Tapesty CDI at compile time ( or sort of )


Hi guys !

I do need some behaviour in Tapestry already available to me via CDI in 
a non-web Application.

Let me explain myself :

I have a product, made for different customers.

The product is the same, but for some different implementations of 
common services each one has.

For example :


com.mycompany.product.service.customer1.SubscribeService
com.mycompany.product.service.customer2.SubscribeService
com.mycompany.product.service.customer3.SubscribeService


In CDI ( Using weld ), y do use the beans.xml file facility to populate 
the service for the desired customer.
Then, in the code all i need is invoking the @Inject into a service, and 
i will get the customer X service  at my disposal.

But in Tapestry, i do not know how to implement this.

I believe that dinamically adding a service to  the /public static void 
bind(ServiceBinder binder)/ in the AppModule is not the wright way to 
achieve it.


May any of you help me with this ? I do not need any runtime behaviour, 
just compile time.

Thanks everyone, and long life to Tapestry ! ( So to Howard and all the 
maintainers, of course  :) )



-- 
*Jose Luis Sanchez*
Senior Developer

*E-mail*: joseluis.sanchez@m-centric.com
*Phone* : +34 91 277 03 16
mCentric mobilising imagination


c/ Jose Echegaray, 8 Building 3
28230 Las Rozas (Madrid). SPAIN.

This message may contain confidential information or privileged 
material, and is intended only for the individual(s) named. If you are 
not in the named addressee you should not disseminate, distribute or 
copy this e-mail. Please notify the sender immediately by e-mail if you 
have received this e-mail by mistake and delete this e-mail from your 
system E-mail transmission cannot be guaranteed to be secured or 
error-free as information could be intercepted, corrupted, lost, 
destroyed, arrive late or incomplete, or contain viruses. The sender 
therefore does not accept liability for any errors or omissions in the 
contents of this message which arise as a result of e-mail transmission. 
If verification is required please request a hard-copy version.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Tapesty CDI at compile time ( or sort of )

Posted by Howard Lewis Ship <hl...@gmail.com>.
In a non-web application, you can have explicit control over the
constructed Registry via the RegistryBuilder.  It's API allows you to
directly specify which modules will be included.  Your application's
main() can decide which modules to add, selecting a module appropriate
to the particular client.

I might break it up as so:

1) A master module that defines the Java interface SubscribeService.
Other generic services will inject the SubcribeService, even though
nothing in the master module declares the service.

2) For each new client, create a per-client module.  Inside the
per-client module, add:

  binder.bind(SubscribeService.class, ThisCustomerSubscribeImpl.class);

  to the module's static bind() method.

3) When executing the app, choose which per-client module to add to
the Registry via RegistryBuilder.add().

Alternately, you could build N different versions of your app, one for
each client, and just control which client module in on the classpath.

Finally, note that the tapestry.execution-mode logic is part of
tapestry-core (the web framework) not tapestry-ioc (the IoC
container).

On Thu, Oct 6, 2011 at 3:33 PM, Chris Poulsen <ma...@nesluop.dk> wrote:
> Hi,
>
> I think you could have an ioc module for each customer (each customers code
> in his own "project") - and then just drop in the right jar and have it
> autoload.
>
> --
> Chris
>
>
> On Thu, Oct 6, 2011 at 4:03 PM, Jose Luis Sanchez <
> joseluis.sanchez@m-centric.com> wrote:
>
>>
>>
>> Hi guys !
>>
>> I do need some behaviour in Tapestry already available to me via CDI in a
>> non-web Application.
>>
>> Let me explain myself :
>>
>> I have a product, made for different customers.
>>
>> The product is the same, but for some different implementations of common
>> services each one has.
>>
>> For example :
>>
>>
>> com.mycompany.product.service.**customer1.SubscribeService
>> com.mycompany.product.service.**customer2.SubscribeService
>> com.mycompany.product.service.**customer3.SubscribeService
>>
>>
>> In CDI ( Using weld ), y do use the beans.xml file facility to populate the
>> service for the desired customer.
>> Then, in the code all i need is invoking the @Inject into a service, and i
>> will get the customer X service  at my disposal.
>>
>> But in Tapestry, i do not know how to implement this.
>>
>> I believe that dinamically adding a service to  the /public static void
>> bind(ServiceBinder binder)/ in the AppModule is not the wright way to
>> achieve it.
>>
>>
>> May any of you help me with this ? I do not need any runtime behaviour,
>> just compile time.
>>
>> Thanks everyone, and long life to Tapestry ! ( So to Howard and all the
>> maintainers, of course  :) )
>>
>>
>>
>> --
>> *Jose Luis Sanchez*
>> Senior Developer
>>
>> *E-mail*: joseluis.sanchez@m-centric.com
>> *Phone* : +34 91 277 03 16
>> mCentric mobilising imagination
>>
>>
>> c/ Jose Echegaray, 8 Building 3
>> 28230 Las Rozas (Madrid). SPAIN.
>>
>> This message may contain confidential information or privileged material,
>> and is intended only for the individual(s) named. If you are not in the
>> named addressee you should not disseminate, distribute or copy this e-mail.
>> Please notify the sender immediately by e-mail if you have received this
>> e-mail by mistake and delete this e-mail from your system E-mail
>> transmission cannot be guaranteed to be secured or error-free as information
>> could be intercepted, corrupted, lost, destroyed, arrive late or incomplete,
>> or contain viruses. The sender therefore does not accept liability for any
>> errors or omissions in the contents of this message which arise as a result
>> of e-mail transmission. If verification is required please request a
>> hard-copy version.
>>
>> ------------------------------**------------------------------**---------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.**apache.org<us...@tapestry.apache.org>
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Tapesty CDI at compile time ( or sort of )

Posted by Chris Poulsen <ma...@nesluop.dk>.
Hi,

I think you could have an ioc module for each customer (each customers code
in his own "project") - and then just drop in the right jar and have it
autoload.

-- 
Chris


On Thu, Oct 6, 2011 at 4:03 PM, Jose Luis Sanchez <
joseluis.sanchez@m-centric.com> wrote:

>
>
> Hi guys !
>
> I do need some behaviour in Tapestry already available to me via CDI in a
> non-web Application.
>
> Let me explain myself :
>
> I have a product, made for different customers.
>
> The product is the same, but for some different implementations of common
> services each one has.
>
> For example :
>
>
> com.mycompany.product.service.**customer1.SubscribeService
> com.mycompany.product.service.**customer2.SubscribeService
> com.mycompany.product.service.**customer3.SubscribeService
>
>
> In CDI ( Using weld ), y do use the beans.xml file facility to populate the
> service for the desired customer.
> Then, in the code all i need is invoking the @Inject into a service, and i
> will get the customer X service  at my disposal.
>
> But in Tapestry, i do not know how to implement this.
>
> I believe that dinamically adding a service to  the /public static void
> bind(ServiceBinder binder)/ in the AppModule is not the wright way to
> achieve it.
>
>
> May any of you help me with this ? I do not need any runtime behaviour,
> just compile time.
>
> Thanks everyone, and long life to Tapestry ! ( So to Howard and all the
> maintainers, of course  :) )
>
>
>
> --
> *Jose Luis Sanchez*
> Senior Developer
>
> *E-mail*: joseluis.sanchez@m-centric.com
> *Phone* : +34 91 277 03 16
> mCentric mobilising imagination
>
>
> c/ Jose Echegaray, 8 Building 3
> 28230 Las Rozas (Madrid). SPAIN.
>
> This message may contain confidential information or privileged material,
> and is intended only for the individual(s) named. If you are not in the
> named addressee you should not disseminate, distribute or copy this e-mail.
> Please notify the sender immediately by e-mail if you have received this
> e-mail by mistake and delete this e-mail from your system E-mail
> transmission cannot be guaranteed to be secured or error-free as information
> could be intercepted, corrupted, lost, destroyed, arrive late or incomplete,
> or contain viruses. The sender therefore does not accept liability for any
> errors or omissions in the contents of this message which arise as a result
> of e-mail transmission. If verification is required please request a
> hard-copy version.
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.**apache.org<us...@tapestry.apache.org>
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>