so,after add the buildLogger function,we can use these code to inject Logger service:
Class Start{ ... @Inject private Logger log; ... } On Wed, Sep 23, 2009 at 12:29 PM, cleverpig <greatclever...@gmail.com> wrote: > I got the answer! It's so easy...thank all of my helpers and opensource! > > my problem's solution:add this function in AppModule class: > > public Logger buildLogger(final Logger log){ > return log; > } > > I'd read this > article:http://java.dzone.com/news/tapestry-5-ioc-binding-and-bui,and > learned what's the secret & key in there: > > ---Service Builder Methods--- > > Sometimes just instantiating a class is not enough; there may be > additional configuration needed as part of instantiating the class. > Tapestry 5 IoC's predecessor, HiveMind, accomplished such goals with > complex service-building services. It ended up being a lot of XML. > > T5 IoC accomplishes the same, and more, using service builder methods; > module methods that construct a service. A typical case is when a > service implementation needs to listen to events from some other > service: > > public static TranslatorSource > buildTranslatorSource(ComponentInstantiatorSource > componentInstantiatorSource, > ServiceResources resources) > { > TranslatorSourceImpl service = > resources.autobuild(TranslatorSourceImpl.class); > componentInstantiatorSource.addInvalidationListener(service); > return service; > } > > Module methods prefixed with "build" are service builder methods. The > service interface is defined from the return value (TranslatorSource). > The service id is explicitly "TranslatorSource" (that is, everything > after "build" in the method name). > > Here, Tapestry has injected into the service builder method. > ComponentInstantiatorSource is a service that fires events. > ServiceResources is something else: it is a bundle of resources > related to the service being constructed ... including the ability to > instantiate an object including dependencies. What's great here is > that buildTranslatorSource() doesn't need to know what the > dependencies of TranslatorSourceImpl are, it can instantiate the class > with dependencies using the autobuild() method. The service builder > then adds the new service as a listener of the > ComponentInstantiatorSource, before returning it. > > > 2009/9/23 cleverpig <greatclever...@gmail.com>: >> yes,i'd read it..but i can't get the door to answer... >> >> On Wed, Sep 23, 2009 at 9:57 AM, Thiago H. de Paula Figueiredo >> <thiag...@gmail.com> wrote: >>> Em Tue, 22 Sep 2009 21:55:44 -0300, cleverpig <greatclever...@gmail.com> >>> escreveu: >>> >>>> oh,thanks for your reply,Alfonso! >>>> just now,i get know i need a slf4j implementation.i found a >>>> implementation class from slf4j.jar:org.slf4j.impl.Log4jLoggerAdapter. >>>> but how to declare the binding of them? what's need to add in the >>>> AppModule? >>> >>> Take a look at >>> http://tapestry.apache.org/tapestry5.1/tapestry-ioc/service.html. >>> >>> -- >>> Thiago H. de Paula Figueiredo >>> Independent Java consultant, developer, and instructor >>> http://www.arsmachina.com.br/thiago >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org >>> For additional commands, e-mail: users-h...@tapestry.apache.org >>> >>> >> >> >> >> -- >> cleverpig(Dan) >> Location: Beijing >> Address: Room 4018,No.A2 South Avenue Fuxingmen Beijing,P.R.China >> Zipcode: 100031 >> MSN: great_liu...@hotmail.com >> QQ: 149291732 >> Skype: cleverpigatmatrix >> Facebook ID:cleverpig >> Blog: www.cleverpig.name >> Tags: del.icio.us/cleverpig >> Twitter: twitter.com/cleverpig >> 新浪微博: t.sina.com.cn/cleverpig >> Organization: www.beijing-open-party.org >> or...@facebook: http://www.facebook.com/group.php?gid=8159558294 >> > > > > -- > cleverpig(Dan) > Location: Beijing > Address: Room 4018,No.A2 South Avenue Fuxingmen Beijing,P.R.China > Zipcode: 100031 > MSN: great_liu...@hotmail.com > QQ: 149291732 > Skype: cleverpigatmatrix > Facebook ID:cleverpig > Blog: www.cleverpig.name > Tags: del.icio.us/cleverpig > Twitter: twitter.com/cleverpig > 新浪微博: t.sina.com.cn/cleverpig > Organization: www.beijing-open-party.org > or...@facebook: http://www.facebook.com/group.php?gid=8159558294 > -- cleverpig(Dan) Location: Beijing Address: Room 4018,No.A2 South Avenue Fuxingmen Beijing,P.R.China Zipcode: 100031 MSN: great_liu...@hotmail.com QQ: 149291732 Skype: cleverpigatmatrix Facebook ID:cleverpig Blog: www.cleverpig.name Tags: del.icio.us/cleverpig Twitter: twitter.com/cleverpig 新浪微博: t.sina.com.cn/cleverpig Organization: www.beijing-open-party.org or...@facebook: http://www.facebook.com/group.php?gid=8159558294 --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org