[jboss-dev-forums] [JBoss AS7 Development] - Subsystem Development Conventions

Jason Greene do-not-reply at jboss.com
Wed Nov 9 15:41:49 EST 2011


Jason Greene [http://community.jboss.org/people/jason.greene] created the document:

"Subsystem Development Conventions"

To view the document, visit: http://community.jboss.org/docs/DOC-17346

--------------------------------------------------------------
There are a number of common problems that a subsystem developer will run into. This document is an attempt to convey the best recommended practices and common conventions that other subsystems follow. Following these will make it easier for UI tools to be developed since everything works according to a similar set of rules.

h3. Use Resources Over Complex Attributes
It is much easier for UI tools to handle a small set of simple operations (add/remove/write) with simple attributes than it is to handle a monolothic resource with complex nested attributes. It also offers more flexibility in runtime updates. For example, it may be possible to increase the max thread size of a pool without restarting and replacing the entire pool. The rule of thumb is to keep creating resources until you hit primitives. 

There is of course exceptions. For example,If the configuration contains an ordered list of which there is no unique name, a resource does not fit well. In this case a complex list type is unavoidable. However in such a scenario a set of "helper" operations should be created (e.g. add-foo).

In some cases it may not be clear how to model a nested child as a resource because it does not have a key->value name which is required. When this happens, you will need to come up with a new naming convention that fits the key/value model yet is still based on the original notion. For example a subsystem that has a foo, and a foo-expanded can change those names to be something like foo=classic and foo=expanded.

h3. Make All Attributes Writable
Anything that can be edited in an xml file *MUST* be writable at runtime. It is possible, however, that modifying such a value can not be done "hot" at runtime, in which case forcing the server to reload or restart is the appropriate action (See ReloadRequiredWriteAttributeHandler)

h3. Make ADD Smart, Don't Expose "Activate" Operations
The common problem is that during boot, or during a composite operation, the parent ADD happens BEFORE a child node ADD. Therefore it's runtime handler is called first. The proper way to deal with this situation is to have the parent add operation add a new "step" runtime handler to make the actual changes. This step will automatically run after all of the ones before it (the children), and so it will be able to read the various child resources that are needed.

h3. Use SimpleResourceDefinition and *AttrributeDefinition
These automate a large portion of validation and description handling, which makes the subsystem less error prone and quicker to develop.
--------------------------------------------------------------

Comment by going to Community
[http://community.jboss.org/docs/DOC-17346]

Create a new document in JBoss AS7 Development at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=102&containerType=14&container=2225]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-dev-forums/attachments/20111109/69caf9d4/attachment.html 


More information about the jboss-dev-forums mailing list