Custom servlet in Openfire plugin
I’ve been working on creating a plugin for our Openfire server, which is
currently on version 3.3.3. The Plugin
developer guide is a little help, and so are the message boards, but
there is still some detail missing.
Situation: I want to have a custom
servlet that is available on the same url:port as our admin server. I don’t want to have to
login to the admin server to reach this url, and the output from this servlet should not be
wrapped by the openfire sitemesh template.
First, I registered the
servlet in a web-custom.xml, but I could not get my servlet to appear. I had a url like
http://localhost:9090/plugins/myplugin/CustomServlet. I couldn’t find
an answer on the message boards so I pulled down the source and started debugging. Turns out
that the PluginServlet class does a toLower on the servlet url. So changing the url pattern
from /CustomServlet to /customservlet in the web-custom.xml fixed the problem.
Next, to remove the security for hitting the servlet, I used the information
to the initializePlugin method fixed it up.
Lastly, as mentioned here and
<meta name=‘decorator’ content=‘none’/> tells
sitemesh to not use the normal openfire template.
Hopefully this info
will help me remember this stuff down the line…