Tuesday, December 16, 2008

Plugin-generator for Jopr, JBoss ON and RHQ

I have written a simple generator that allows to generate plugin skeletons by answering some questions. The generator will afterwards try to generate the respective artifacts. I have added it to RHQ in version 2419. Of course it is also usable in Jopr and JBoss ON.

See below on how to obtain the generator.

Sample run



This is a sample run to create a new plugin called 'test' in my RHQ tree -- user input is marked in bold. Comments at the end of line in italics are mine for explanation. Those will not show up on screen.

$ java -jar rhq-pluginGen-1.0-jar-with-dependencies.jar
Please speficy the plugin root category (Platform, Server, servIce) S What resource category is this plugin using? Most common is server or service.
Please specify its FileSystemRoot: /jon/jonHEAD/rhq/modules/plugins This is the base location of your plugin subtree within RHQ or Jopr
Please specify its PackagePrefix: com.acme.plugins The base in which your plugin should live in. The plugin package itself will be added below it.
Please specify its DiscoveryClass: TestDiscovery The name of the discovery class
Please specify its ComponentClass: TestComponent The name of the component class
Please specify its ParentType: The parent type if this plugin should e.g. be embedded into another one. Can be left empty
Please specify if it should support Monitoring (y/N): y Will the plugin gather measurement data?
Please specify if it should support Operations (y/N): y Will the plugin allow to execute operations on a managed resource?
Please specify if it should support Singleton (y/N): n Is this a singleton kind of server/service? This is e.g. true if it represents a Subsystem with individual resources below it.
Please specify if it should support ResourceConfiguration (y/N): n Will configuration of managed resources be supported?
Please specify if it should support Events (y/N): y Does the plugin gather event type data (e.g. logfile parsing)?
Please specify if it should support CreateChildren (y/N): n Can child resources be created by this server/service?
Please spefify if it should support UsesExternalJarsInPlugin (y/N): y Do you use external chars that need to be put in the plugin?
Please specify its Name: test The name of the plugin. Used for the package, the name and the top level server/service
Please specify its Description: This is a test plugin
15.12.2008 13:53:19 org.jboss.jopr.pluginGen.PluginGen run
INFO:
You have choosen:
Props{category=SERVER, name='test', description='This is a test plugin', packagePrefix='com.acme.plugins', discoveryClass='TestDiscovery', componentClass='TestComponent', parentType='', fileSystemRoot='/jon/jonHEAD/rhq/modules/plugins', monitoring=true, operations=true, singleton=false, resourceConfiguration=false, events=true, createChildren=false, children=null}
15.12.2008 13:53:19 org.jboss.jopr.pluginGen.PluginGen generate
INFO: Generating...
15.12.2008 13:53:19 org.jboss.jopr.pluginGen.PluginGen createFile
INFO: Trying to generate /jon/jonHEAD/rhq/modules/plugins/test/pom.xml
15.12.2008 13:53:19 org.jboss.jopr.pluginGen.PluginGen createFile
INFO: Trying to generate /jon/jonHEAD/rhq/modules/plugins/test/src/main/resources/META-INF/rhq-plugin.xml
15.12.2008 13:53:19 org.jboss.jopr.pluginGen.PluginGen createFile
INFO: Trying to generate /jon/jonHEAD/rhq/modules/plugins/test/src/main/java/com/acme/plugins/test/TestDiscovery.java
15.12.2008 13:53:19 org.jboss.jopr.pluginGen.PluginGen createFile
INFO: Trying to generate /jon/jonHEAD/rhq/modules/plugins/test/src/main/java/com/acme/plugins/test/TestComponent.java
15.12.2008 13:53:19 org.jboss.jopr.pluginGen.PluginGen generate
INFO: Done ..


Please note, that you still need to add the plugin to the parent pom
file - e.g. like this:

<module>test</module>


Please also note that creation of children (Servers, Services) is not supported in this version.

How to get and start it



The generator lives in modules/helpers/pluginGen. So update your source, go into the directory and compile it via mvn install. To run it, change into target directory and issue java -jar rhq-pluginGen-1.0-jar-with-dependencies.jar as seen above.

For convenience you can directly download the generator from the RHQ wiki (Note: this download can go away any time).

Further reading



I am writing from time to time on my blog about RHQ and have also written a "How to write a plugin" series of posts.

We have compiled this "How to" series into a PDF Whitepaper, that you can download. It might make sense to first having a look at this paper before using the generator.

Feedback



Please tell me if this generator is useful for you (of course you can also put feature requests in RHQ-Jira).

1 comment: