Web Console Output TemplatingPage edited by Felix Meschberger
Internationalization support of the Web Console is based on Java Resource Bundles loaded from the plugin bundles and is transparent to the plugin itself. In addition to localization the mechanism described here can also be used for generic templating of Web Console responses. Basic MechanismAll requests handled by web console plugins are wrapped by response wrapper, which installs a Writer filter if the response is a text/html response. This writer filter recognizes variables of the pattern ${name} and tries to replace that part of the output with another string:
Variable ResolutionVariable Resolution is based on a org.apache.felix.webconsole.VariableResolver object provided as a request attribute prior to calling the ServletResponse.getWriter() method. If no such resolver is provided in the request, an instance of the org.apache.felix.webconsole.DefaultVariableResolver is used and stored in the request. Replacing the VariableResolver after the getWriter() has been called has no effect for variable resolution. Variables may be added to the VariableResolver even after the getWriter() method has been called. Resource BundlesResources for the Resource Bundles is provided by the Web Console bundle on the one hand and by the bundle providing the plugin on the other hand. Resources are identified inside a bundle with the Bundle-Localization manifest header as described in Section 3.10 Localization in the Core Specification. This also means, that additional translations may be provided by fragment bundles. During request processing the Locale of the request (ServletRequest.getLocale()) is used to identify the actual resources to use. From this information a ResourceBundle is constructed from a collection of the resources provided by the plugin bundle and the resources provided by the Web Console. Web Console LocalizationThe Web Console contains a single localization file OSGI-INF/l10n/bundle.properties. Fragments attached to the Web Console bundle may provide translations for these resources. All plugins of the Web Console itself will use a ReosurceBundle, which is only based on the localization of the Web Console itself. Using Templating
Change Notification Preferences
View Online
|
View Change
|
Add Comment
|
- [CONF] Apache Felix > Web Console Output Templating confluence