Thanks for this quick response - however the code below is already working
in my case. This simple examples shows how to let Guice and T5 work
together - I was just looking for some thoughts on whether this is
actually a good/the best idea.
> Seems like you'll need access to the Registry, or at least and
> ObjectLocator
> to make them play together (allow Guice beans to be injected into Tapestry
> services/components).
>
> A contribution to MasterObjectProvider could do the job.
>
> Haven't looked into it in detail.
>
> On 10/29/07, Jan Vissers <[EMAIL PROTECTED]> wrote:
>>
>> Partially inspired by a question/some work by Leon Pennings (on this
>> list), partially because of my interest in Guice - if been trying to
>> test some stuff on how best to integrate Guice and T5. Before asking
>> whether my approach is appropriate I would like to ask what your opinion
>> is on the whole idea of mixing Guice and T5 IoC?
>>
>>
>>
>> This is what I've done for the NumberGuess tutorial.
>>
>> public interface IPlayGenerator {
>> int generateRandomNumber();
>> }
>>
>> public class PlayGeneratorImpl implements IPlayGenerator {
>> public int generateRandomNumber() {
>> Random random = new Random();
>> return random.nextInt(10) + 1;
>> }
>> }
>>
>> //Guice stuff
>> public class PlayModule extends AbstractModule {
>> @Override
>> protected void configure() {
>>
>> bind(IPlayGenerator.class).to(PlayGeneratorImpl.class).in(Scopes.SINGLETON
>> );
>> }
>> }
>>
>> //Actual client service
>> public class NumberGuessPlayer {
>> private final IPlayGenerator generator;
>>
>> //Guice Inject
>> @Inject
>> public NumberGuessPlayer(IPlayGenerator generator) {
>> this.generator = generator;
>> }
>>
>> public int play() {
>> return generator.generateRandomNumber();
>> }
>> }
>>
>> //T5/Guice bootstrapping
>> public class AppModule {
>> // Guice Injector instance
>> private static final Injector injector;
>>
>> static {
>> injector = Guice.createInjector(new Module[] { new PlayModule()
>> });
>> }
>>
>> public static NumberGuessPlayer buildNumberGuessPlayerFinder() {
>> return injector.getInstance(NumberGuessPlayer.class);
>> }
>> ...
>> ...
>> }
>>
>> //Start page
>> public class Start {
>> @InjectPage
>> private Guess guess;
>>
>> /T5 Inject
>> @Inject
>> private NumberGuessPlayer player;
>>
>> Object onAction() {
>> int target = player.play();
>>
>> guess.setup(target);
>>
>> return guess;
>> }
>> }
>>
>>
>> Any comments, tips....?
>>
>> -J
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
>
> --
> Howard M. Lewis Ship
> Partner and Senior Architect at Feature50
>
> Creator Apache Tapestry and Apache HiveMind
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]