The call to the plugin manager’s loadPluginsOfType method is where the plugin object is created from the class specified in the plugin registrant. This is also where the pluginWillLoad method is invoked. It is the responsibility of the code that calls loadPluginsOfType to call unloadPluginOfType whenever it is finished with the plugins. The plugin manager cannot do this automatically because it does not know if the UI code is finished with the plugin. In the shopping cart example, the shopping cart view controller calls unloadPluginsOfType whenever the viewController is unloaded.

The base ATGPlugin class performs some basic clean-up in its pluginWillUnload, such as dropping the references to the parentViewController, and the plugin’s own viewController instance. This is not a retain cycle, since the UI is not be holding a persistent reference to the plugin object, but just in case, it manually releases the objects in pluginWillUnload.

A plugin is unique by plugin type and class combination, so if loadPluginsOfType finds a plugin is already loaded and was never unloaded, it will log a warning stating that plugins should be unloaded when the user is finished. This helps ensure that the plugin’s lifecycle is honored, and that repeated calls to loadPluginsOfType do not result in the creation of duplicate plugins.

The plugin type string constants are defined somewhere common to both the project containing the application UI code, and the project containing the plugin code. In ASA-ORMPOS, this is ATGAgentClient.

Building Plugins

A project containing plugins is configured as a target dependency of the application UI project so it gets built and is included in the list of binaries that are linked against the application so its classes can be resolved. If these two dependencies are removed, then the plugins will not show up.

The reference to the plugin registrant should be removed from the plist if the dependencies are removed. To remove a plugin, remove the dependencies on the plugin project and remove the registrant from the plist.


Copyright © 1997, 2015 Oracle and/or its affiliates. All rights reserved. Legal Notices