public class MyModule {

  public static TroubleMaker decorateTroubleMaker(TroubleMaker defaultImpl) {
    return new MyTroubleMakerImpl(...);
  }
}

The convention is that decorateFoo decorates service id "Foo".
There's other options, based on annotations, to decorate a wider swath
of services (though the modern technique is to use advice for that
situation, and only use decoration when the service interface is known
at build time).  The decoration method may return null if it does not
wish to decorate the default implementation.

Normally, the decorator method will return an interceptor, that
overrides some methods of the interface, and passes other method
invocations right on through.

When there's multiple decorator methods for the same service, one
receives the default implementation, the next receives the output of
the first.

On Thu, Jun 7, 2012 at 6:40 PM, Ray Nicholus <rnicho...@widen.com> wrote:
> I've never used decorators in Tapestry before.  I took a peek at the
> documentation, and I'm afraid I'm not really sure what I'm supposed to do
> here, specifically.  I'm not even sure what code I should add to my local
> app module at this point.
>
> On Thu, Jun 7, 2012 at 8:19 PM, Howard Lewis Ship <hls...@gmail.com> wrote:
>
>> You have to get sneaky and decorate the TheModule.Symbols.SOME_SYMBOL
>> service implementation with a new implementation (discarding the
>> original).  Not ideal and I've been thinking about how to address this
>> more cleanly in Tapestry IoC.  It would be nice if there was an
>> explicit overrideXXX() module method that would expressly replace the
>> core implementation of a service.
>>
>> When decorating, your decorateXXX() method must take a parameter of
>> the service type ... normally it would make use of the core service
>> implementation, but in your case, you'll just ignore it.
>>
>> This can be tricky if there are other decorations on the service.
>>
>> On Thu, Jun 7, 2012 at 4:55 PM, Ray Nicholus <rnicho...@widen.com> wrote:
>> > I'm pulling in a library that also uses T5, and in it's "module" class,
>> it
>> > contains the following method:
>> >
>> > @ServiceId (Symbols.SOME_SYMBOL)
>> >  public static Something buildThisThing(SomeObj someObj)
>> > {
>> >             ......
>> >         }
>> >
>> > In the library, this service is injected into the constructor of another
>> > service (@InjectService(TheModule.Symbols.SOME_SYMBOL) Something
>> something).
>> >
>> > How can I override the SOME_SYMBOL service implementation in my local
>> code?
>>
>>
>>
>> --
>> 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-unsubscr...@tapestry.apache.org
>> For additional commands, e-mail: users-h...@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-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to