Re: Creating custom service using build() failed
Perfect, worked like a charm. Thanks a million. Cheers -- View this message in context: http://tapestry.1045711.n5.nabble.com/Creating-custom-service-using-build-failed-tp5081119p5081860.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Creating custom service using build() failed
Instead of public static DataGenerator buildDataGenerator() { return new DummyDataGenerator(); } try public static DataGenerator buildDataGenerator(ObjectLocator locator) { return locator.autobuild(DummyDataGenerator.class); } When you use new DummyDataGenerator(), @Inject won't work regards Taha On Dec 17, 2011, at 3:33 AM, bhorvat wrote: > I "solved" or at very least I am aware how to bypass the problem. It seems > that the services can not be injected into the DummyDataGenerator if I > create it using the build method but if I create it in the bind it can > inject the service. > > The only problem is that I have about 20 service so can you imagine the > argument list :( > > Any idea if it possible to solve this in a cleaner way because now I will > have to modify argument list every time I want to add or remove service. > > Thank you for assistance > > -- > View this message in context: > http://tapestry.1045711.n5.nabble.com/Creating-custom-service-using-build-failed-tp5081119p5081570.html > Sent from the Tapestry - User mailing list archive at Nabble.com. > > - > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Creating custom service using build() failed
I "solved" or at very least I am aware how to bypass the problem. It seems that the services can not be injected into the DummyDataGenerator if I create it using the build method but if I create it in the bind it can inject the service. The only problem is that I have about 20 service so can you imagine the argument list :( Any idea if it possible to solve this in a cleaner way because now I will have to modify argument list every time I want to add or remove service. Thank you for assistance -- View this message in context: http://tapestry.1045711.n5.nabble.com/Creating-custom-service-using-build-failed-tp5081119p5081570.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Creating custom service using build() failed
The service is just a hibernate service that saves data to the database. public class StudioServiceHibernate implements StudioService { private final Session session; public StudioServiceHibernate(Session session) { this.session = session; } public Studio save(Studio studio) { return (Studio) session.get(Studio.class, session.save(studio)); } } I was looking at the execution order. First it executes the bind method which binds all the services including binder.bind(StudioService.class, StudioServiceHibernate.class); After that it give control to the @Startup public static void initApplicationData(DataGenerator dataGenerator) { dataGenerator.generate(); } which should fill in the database. Since the DataGenerator is created with the build method it then triggers this method public static DataGenerator buildDataGenerator() { return new DummyDataGenerator(); } Which creates generator and then starts to generate the method. Inside it are the services for filling the database like StudioService which is injected into the Generator class. However for some reason it is as if the bind method didn't bind the StudioService to its implementation. When I remove the buildDataGenerator and manually bind it inside the bind method all is ok. But when I put it in special method it is not. What am I missing? Idea? Thx for trying to help -- View this message in context: http://tapestry.1045711.n5.nabble.com/Creating-custom-service-using-build-failed-tp5081119p5081462.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Creating custom service using build() failed
On Fri, 16 Dec 2011 18:15:29 -0200, bhorvat wrote: On that line I have studioService.save(tempStudio); So the problem is there. ;) Make sure studioService isn't null. Please post the full class here. DummyDataGenerator generated the dummy code for the database and it doing so using the service that are defined in the bind method. Is it possible that the services are are not defined? Please post the classes sources here. -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Creating custom service using build() failed
On that line I have studioService.save(tempStudio); DummyDataGenerator generated the dummy code for the database and it doing so using the service that are defined in the bind method. Is it possible that the services are are not defined? When I put in the bind method binder.bind(DataGenerator.class, DummyDataGenerator.class); and remove the custom builDataGenerator method all works as it should be -- View this message in context: http://tapestry.1045711.n5.nabble.com/Creating-custom-service-using-build-failed-tp5081119p5081312.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Creating custom service using build() failed
On Fri, 16 Dec 2011 17:08:43 -0200, bhorvat wrote: Hi Hi! This line dataGenerator.generate(); throws a NullPointerException Full stack trace please. -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Creating custom service using build() failed
Hi I have probably some small problem but I can not figure it out. According to documentation it should work but it is not. I have defined some servervice using public static void bind(ServiceBinder binder) { binder.bind(StudioService.class, StudioServiceHibernate.class); binder.bind(ProjectService.class, ProjectServiceHibernate.class); } after that I have defined the one service using build() method public static DataGenerator buildDataGenerator() { return new DummyDataGenerator(); } I will later make this method complicated based on some condition it will create service using DummyDataGenerator or NoDataGenerator. Also I have add the initialization database mathod like so @Startup public static void initApplicationData(DataGenerator dataGenerator) { dataGenerator.generate(); } This line dataGenerator.generate(); throws a NullPointerException What am I missing. Thank you in advance -- View this message in context: http://tapestry.1045711.n5.nabble.com/Creating-custom-service-using-build-failed-tp5081119p5081119.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org