AdempiereActivator vs Incremental2PackActivator (Activator and 2Pack)
AdempiereActivator vs Incremental2PackActivator (Activator)
The purpose of this section is to discuss the relationship between an OSGi plugin and an iDempiere Pack In (2Pack).
There are two developer tools that an integrator will typically use when deploying customizations. One is the OSGi plugin and the second is iDempiere Pack In (also known as a 2Pack). The OSGi plugin packages code into a deploy-able module. Deploying a plugin is demonstrated here. The Pack In (2Pack) packages changes to iDempiere's application dictionary. Deploying a Pack In is demonstrated here.
There are times when it makes sense for a integrator to include a 2Pack file in an OSGi plugin. iDempiere supports this 'single-file' deployment process by providing two OSGi activators:
- AdempiereActivator - used when you have a plugin with a single 2Pack named 2Pack.zip. Note the name includes a capital P. Note this method will try to install the 2Pack file every time the server is launched. If you have one plugin with a small 2Pack, the re-install every launch is a minor issue. If you have many plugins with large 2Packs, this overhead can become noticeable.
- Incremental2PackActivator - used when you have plugin that has multiple 2Pack files. When plugin is activated, it looks at the version of the plugin/bundle and it compares it to the names of the 2Pack files. 2Pack files installed with the Incremental2PackActivator will follow a pattern like: 2Pack_1.2.3.zip. If the bundle's version is less than or equal to the version of the 2Pack file, the 2Pack file gets added to the list to be packed in.
Here are the common questions:
- Why would you include your 2Pack with your plugin? I typically do not. As a result, users of my plugins have a two step install process: (a) install the 2Pack, and (b) install the plugin. If you include your 2Pack in your plugin, your users have an easier install process.
- Which is better? If you are tools provider, and you want to make your user's life easier, include the 2Pack in your plugin. If you tend to have more documented release processes and you have talented people performing the release process, I recommend you keep them separate. Do not couple these files unless there is a compelling reason to do so.
- Where do you specify the plugin's activator? Every plugin has a manifest in the folloiwng location: ../META-INF/MANIFEST.MF. When using Eclipse, you can find the Activator field in the manifest's Overview tab.
- How do you create plugins? Here is a video series on iDempiere's most common plugin features/tools.