This plugin is located in the com.dotcms.tuckey subdirectory in the examples directory (/dotCMS/docs/examples/osgi/com.dotcms.tuckey).
To implement the plugin, you must do the following:
- Modify the following files:
- Update the OSGI Exported Packages list.
To be able to deploy the plugin, you must specify the following in the META-INF/MANIFEST.MF file (please see the template plugin for examples):
|Bundle-Name||The name of your bundle.|
|Bundle-SymbolicName||A short an unique name for the bundle.|
|Bundle-Activator||Package and name of your Activator class (example: com.dotmarketing.osgi.tuckey.Activator).|
|DynamicImport-Package||Dynamically add required imports the plugin may need without add them explicitly.|
|Import-Package||This is a comma separated list of package's name.|
List the packages that you are using inside the bundle plugin and that are exported by dotCMS.
In order for the plugin to work inside the Apache Felix OSGI runtime, the import and export directives must be bidirectional.
The bundle activator extends from com.dotmarketing.osgi.GenericBundleActivator and implements
BundleActivator.start(). It manually registers Tuckey Rewrite Rules, making use of the method
unregisterServices()must be called in the stop method.
- This call is MANDATORY as it stops and removes the register Quartz Job when the plugin is undeployed.
This is a simple and standard implementation of an HttpServlet used to test the added Tuckey Rewrite Rules.
Update Exported Packages
Your OSGI plugins may access any dotCMS packages which have been exported. When you add the rewrite plugin, you must add the tuckey package to the list of exported packages to ensure your plugin has access to it.
You may update the list of exported packages either through the OSGI Plugins portlet or by manually editing the osgi-extra.conf file.
You can test the rewrite plugin in several different ways:
- Access the simple test servlet built-in to your dotCMS instance:
- Test the forward rule:
- Test the redirect rule:
- Test the conditions:
- Note: If you call this using google Chrome, it will display the message “from google Chrome”
- Otherwise it will do nothing (404 error).
You can enable logging to help in troubleshooting any issues. To enable logging, add the following lines to the web.xml file ():
<init-param> <param-name>logLevel</param-name> <param-value>DEBUG</param-value> </init-param>
- It is strongly recommended that all changes to the web.xml file be made through a properties file extension.
- Enabling logging generates a large number of log messages.
- Logging should be used for testing and troubleshooting only.
- Logging should be disabled for production systems.
Fore more information on OSGI plugin logging, please see the OSGI Plugin Logging documentation.