Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OF-2717: Allow plugins to register/unregister web context
The embedded webserver (Jetty) that powers the HTTP-Bind (BOSH) and Websocket endpoints can be used by plugins, for them to add web content of their own. To do so, a plugin can dynamically add a 'handler' when it gets loaded in Openfire (that handler should be removed again when the plugin gets unloaded). Due to changes to the Jetty API (which got updated from 10 to 12, using EE8), this mechanism was broken. Prior to the upgrade, a `org.eclipse.jetty.server.handler.HandlerList` was used to maintain the collection of plugin-provided contexts. After upgrading to Jetty 12, this was replaced with a `org.eclipse.jetty.server.handler.ContextHandlerCollection`. This was part of 99fe5f9#diff-55709739e79c9b3141bb106d4e4cf428d2bc54e46acf59450c3d9e8cf988385b The methods used by plugins to add and remove 'handlers' were not modified in that change. The 'handler' passed to them remained of type `org.eclipse.jetty.server.Handler`. This compiles fine, but seems to be a problem. When plugins (which are stand-alone projects with their own source code repositories) get updated to use Jetty 12 instead of 10, their representation of their web-context typically switches from `org.eclipse.jetty.webapp.WebAppContext` to the Jetty 12 EE8 `org.eclipse.jetty.ee8.webapp.WebAppContext`. The former is compatible with the old implementation in Openfire, but the latter is not. The old methods to register and unregister can still be used when the 'core' context handler of the new Jetty 12 EE8 WebAppContext is used (or when the plugin does not use a WebAppContext at all, but a different type of Handler). The core handler can be obtained through `org.eclipse.jetty.ee8.nested.ContextHandler#get`. As it is expected that many/most applications use a WebAppContext, this commit adds new methods to register and unregister (Jetty 12 EE8) web contexts directly (without the need to obtain their 'core' handler).
- Loading branch information