Use of Annotations and CDI in agent/server

Elias Ross genman at noderunner.net
Mon Dec 19 23:53:45 UTC 2011


Heiko suggested I create a proposal re: CDI in RHQ.

In short, here are my ideas:
Writing plugins is hard due to the XML description language and not
being able to easily test.
Use of Arquillian is suggested for testing.
Arquillian works best with interacting with EJB/CDI components.
Using annotations for configuration also reduces much of the
complexity the XML descriptors require.
CDI would benefit plugin writers in being able to access necessary
components without boiler-plate code.
CDI would also benefit working on the server-side, where lots of
boiler-plate code is necessary.
CDI is part of JBoss 7, which I imagine you would like to port RHQ at
some point.

A CDI/Arquillian type approach would probably allow you to create
tests that look like this:

public class OracleServerComponentTest extends Arquillian {

   @Inject /* This is the plugin component that gets the measurements */
   private OracleServerComponent server;

   @Named(name="Oracle Advanced Statistics") /* component by name */
   private ResourceComponent details;

   @Deployment
   protected void init() throws Exception {
/* not entirely sure how you could configure components? */
}

... test cases interact with 'server' ...

}

I imagine a compromise might be to simply start with:
1. Create annotations for replacing most of the plugin descriptor language.
2. Add "Weld" and its parts to the plugin agent.
3. Write the parts to boot the plugin.

Then work on the server-side? But then again, you do have server-side
plugins. So you probably need to start top-down on this.

It does sound terribly ambitious, doesn't it?


More information about the rhq-devel mailing list