Trinidad extensions, the hacking guide

published

From the beginning, some of my ideas behind Trinidad were that it had to be small, easy to use and easy to configure. These ideas still remain, but as soon I stopped being the only user I bumped into other requirements and new features. So, I decided to write a plugins system, basically because I didn’t want to bother users with new versions when I just was adding new features that perhaps then won’t ever use.

After the release of the first extension, the dbpool connector, I wrote a guide to let other people to write their own plugins. It includes everything we need to know about the extensions architecture, but it doesn’t explain the master pieces, something that I’m trying to explain in this post. What the world are the variables tomcat and app_context that the extensions receive and what they are used for??!!

It turns out that Tomcat has a pretty straight forward structure. Each element into its configuration files is mapped by a class which name starts with Standard followed by the element’s name. So, the element server into the file server.xml, the main Tomcat’s configuration file, is mapped by a class called StandardServer and the root element of the file context.xml, called also context, is mapped by the class StandardContext. And those are mostly the pieces that we need to start to work.

Well, arrived to this point it’s obvious what the variable app_context is, it’s an instance of StandardContext, and a context is just a representation of each application deployed on the server. This class, for instance, lets us to reload the application, play with the initial parameters and ultimately add more configuration elements to any application just before the server starts it up.

Now, it’s the server’s turn and no, the tomcat parameter is not the server instance, that would be very easy :D, it’s even better. That parameter is an instance of the class Tomcat, which is a helper that lets us access to the server instance itself, and it also helps us to create Tomcat’s configuration elements, Trinidad uses it to create each application instance, and manage the server.

And now that we know what those classes are for, we’ll find out quickly how anything that’s explained into the Tomcat’s documentation can be easily added piece by piece to Trinidad. Who will be the first one to deal with Trinidad’s clustering extension?


blog comments powered by Disqus