Another quick thing I hacked up - this time during vacation (yup, I know, I suck at 100%
relaxing) and finalized while waiting for jbossas trunk to be Mavenized.
What you can do now is these three approaches of MC + Guice integration:
1) programmatically
| Injector injector = Guice.createInjector(new AbstractModule()
| {
| protected void configure()
| {
| bind(Controller.class).toInstance(controller);
|
bind(Singleton.class).toProvider(GuiceIntegration.fromMicrocontainer(Singleton.class,
"singleton"));
|
bind(Prototype.class).toProvider(GuiceIntegration.fromMicrocontainer(Prototype.class,
"prototype"));
| }
| });
|
2) through metadata
| AbstractBeanMetaData injectorBean = new
AbstractBeanMetaData("injector", GuiceInjectorFactory.class.getName());
| AbstractConstructorMetaData constructor = new AbstractConstructorMetaData();
| constructor.setFactoryClass(GuiceInjectorFactory.class.getName());
| constructor.setFactoryMethod("createInjector");
| List<ParameterMetaData> parameters = new
ArrayList<ParameterMetaData>();
| parameters.add(new AbstractParameterMetaData(new
AbstractDependencyValueMetaData(KernelConstants.KERNEL_NAME)));
| AbstractArrayMetaData array = new AbstractArrayMetaData();
| array.add(new AbstractValueMetaData(GuiceObject.ALL));
| parameters.add(new AbstractParameterMetaData(array));
| constructor.setParameters(parameters);
| injectorBean.setConstructor(constructor);
| controller.install(injectorBean);
|
| ControllerContext injectorContext =
controller.getInstalledContext("injector");
| assertNotNull(injectorContext);
| Injector injector = (Injector)injectorContext.getTarget();
|
3) XML
| <bean name="injector"
class="org.jboss.guice.plugins.GuiceInjectorFactory">
| <constructor
factoryClass="org.jboss.guice.plugins.GuiceInjectorFactory"
factoryMethod="createInjector">
| <parameter>jboss.kernel:service=Kernel</parameter>
| <parameter>
| <array>
| <bean name="BindAll"
class="org.jboss.guice.plugins.AllGuiceObject">
| <constructor
factoryClass="org.jboss.guice.plugins.AllGuiceObject"
factoryMethod="getInstance"/>
| </bean>
| </array>
| </parameter>
| </constructor>
| </bean>
|
Or check out GuiceTestSuite. ;-)
I've commited the code --> adding new guice-int module.
Will add some docs asap.
OK, back to ProfileService ...
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4086288#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...