If you want to use Spring api to create and reference an injector, then you can implement Spring's FactoryBean<http://static.springsource.org/spring/docs/current/api/org/springframework/beans/factory/FactoryBean.html> api to return Guice's injector. In your xml (not sure how to do it with annotations)
<bean id = "injector" class = "MyInjectorFactoryBean"> <property name = "modules" values="Module1, Module2, Module3" /> ...... </bean> To set up an injector, you need to implement getObject method. To instantiate the modules, you can do it two ways. 1. The modules property could be set up as a String array and then instantiate the modules one by one to set up in your Factory implementation using Class.forName and newInstance methods. 2. You delegate it to a Java or Spring's PropertyEditor api to transform fully qualified module path names to modules. The link might prove useful. http://static.springsource.org/spring/docs/2.0.x/reference/validation.html#beans-beans-conversion On Wed, Mar 2, 2011 at 9:29 AM, zixzigma <[email protected]> wrote: > - so when you use Spring Component, for JMS, etc > you inject your own components/classes using Guice ? > > > - and by manually initializing Spring, > do you mean using ApplicationContext context = new > ClassPathXmlApplicationContext(xxx) > in a Guice module ? and then you Guice @Inject this spring > ApplicationContext ? > > - don't you need to annotate your classes with @Component, or somehow tell > spring about the beans you want to have access to spring services ? > and if you have a constructor with dependencies injected with Guice > @Inject, and with no default constructor, Spring cannot instantiate your > class, > and gives error ? or you never let Spring instantiate anything ? > > > Thank You > > -- > You received this message because you are subscribed to the Google Groups > "google-guice" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/google-guice?hl=en. > -- You received this message because you are subscribed to the Google Groups "google-guice" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-guice?hl=en.
