yes, thats it - BTW, you don't need an explicit set-service. just exposte a setter in your implementation class, and hivemind will autowire it:
public void setServletContext( ServletContext ctx) {...} Cheers, Ron Cyrille37 wrote: > Ron Piterman a écrit : >> On which class do you need to access the resource? >> > > I've resolved the case with Hivemind. > I pass to the ObjectFactory the ServletContext to get a root path and > the relative filename. > > <service-point id="hangmanFactoryService" > interface="games.hangman.service.HangmanFactory"> > <invoke-factory> > <construct class="games.hangman.service.HangmanFactory"> > <set-service property="servletContext" > service-id="tapestry.globals.ServletContext"/> > <set property="wordsListFilename" value="WordsList.txt"/> > </construct> > </invoke-factory> > </service-point> > <contribution configuration-id="tapestry.state.ApplicationObjects"> > <state-object name="hangmanStateObject" scope="session" > > <!-- <create-instance class="games.hangman.service.Hangman" > /> --> > <invoke-factory object="service:hangmanFactoryService" /> > </state-object> > </contribution> > > I would have liked only the Hivemind's contribution entry, but to pass > parameters to the instance I've understood that we have to use a > Factory. So two Hivemind's entries. > > Perhaps it could be lighter with the Hivemind's "Lightweight Instance > Initialization" > http://hivemind.apache.org/instance-initialization.html > But I do not understand how it works ... > > I would have liked something simple as: > > <bean id="hangman" scope="session" > class="games.hangman.service.Hangman" > > <property name="servletContext" > ref="tapestry.globals.ServletContext" /> > <property name="wordsListFilename" value="WordsList.txt" /> > </bean> > > Cyrille > >> Cheers, >> Ron >> >> >> >> Cyrille37 wrote: >> >>> Hello, >>> Sure it is a beginner question, but I'm a beginner :o) >>> >>> I would like to read a file which is located in the web root folder, and >>> put it in a String. >>> I had a look around the Internet and found some tricks : >>> >>> A la "Servlet" : >>> ServletContext theApplicationsServletContext = (ServletContext) >>> this.getExternalContext().getContext(); >>> String realPath = >>> theApplicationsServletContext.getRealPath("/resources/images"); >>> File file = new File(realPath + File.separatorChar + justFileName); >>> >>> A la "Rife" : >>> import com.uwyn.rife.tools.FileUtils; >>> URL resource = >>> getClass().getClassLoader().getResource("model/WordList.txt"); >>> final String wordlist = FileUtils.readString(resource); >>> >>> Please could you tell me what are methods and usages with Tapestry ? >>> >>> Thanks >>> cyrille >>> > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]