There isn't a mechanism for doing this via new C(). Tapestry IoC is less intrusive than tapestry-core, it doesn't instrument your code the way the web framework does, but it will use reflection to inject into private fields.
@Autobuild always creates a new instance. On Wed, Apr 29, 2009 at 11:27 AM, daniel joyce <daniel.a.jo...@gmail.com> wrote: > I have a class C, that is not a service, nor a page/component > > I want to Inject a resource into it > > @Inject > SomeService service > > When I use "new C()", I want them to be seperate instances, not > singletons, or per-thread singletons, with that service wired in. > > Will what you posted do this? > > Because when I hear "Autobuild", my understanding is it generates > singletons. But there is no guarantee this class C which is using > SomeService is itself written to be a threadsafe singleton. > > > On Wed, Apr 29, 2009 at 11:19 AM, Howard Lewis Ship <hls...@gmail.com> wrote: >> In the following scenario: >> >> public void contributeMyConfiguration(Configuration<Foo> >> configuration, @Autobuild FooImpl foo) >> { >> configuration.add(foo); >> } >> >> Tapestry will autobuild foo using the same rules as services. Another >> approach: >> >> public void contributeMyConfiguration(Configuration<Foo> configuration) >> { >> configuration.addInstance(FooImpl.class); >> } >> >> This is an alternate way to inject an autobuild instance of the class. >> >> >> On Wed, Apr 29, 2009 at 10:56 AM, daniel joyce <daniel.a.jo...@gmail.com> >> wrote: >>> Is there any way to have a non-component class work with injection, >>> w/o having to turn it into a service itself? >>> >>> @Inject >>> private SystemProperties sysProps; >>> >>> I have a class that simply zips up files, and it needs access to a >>> system properties service. IIRC, but when I tried this in the past, it >>> didn't work for classes that were not pages/components. I also don't >>> want to necessarily turn a class into a service merely to give it >>> access to another service. >>> >>> Any way to do this? Or was I simply doing it wrong before? >>> >>> -Daniel >>> >>> --------------------------------------------------------------------- >>> 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 >> Director of Open Source Technology at Formos >> >> --------------------------------------------------------------------- >> 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 > > -- Howard M. Lewis Ship Creator of Apache Tapestry Director of Open Source Technology at Formos --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org