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 <[email protected]> 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 <[email protected]> > 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: [email protected] >> For additional commands, e-mail: [email protected] >> >> > > > > -- > Howard M. Lewis Ship > > Creator of Apache Tapestry > Director of Open Source Technology at Formos > > --------------------------------------------------------------------- > 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]
