Defining and Using Plug-ins

Developing Plug-ins 7-5 The XML shows two plug-in declarations. Both the plug-ins extend from the same plug-in point.

7.3.2 Specifying Plug-in Metadata

Along with each plug-in that is defined in plugin.xml, you can specify a list of properties that comprise the plug-in metadata. For an example of using the plug-in metadata, see Extending Request Management Operations on page 23-30. In this example, the metadata consists of a single property known as PasswordElementNum , with the value 1: ?xml version=1.0 encoding=UTF-8? oimplugins .... plugins pluginpoint=oracle.iam.sample.passwdmgmt.service.PasswordElement plugin pluginclass= oracle.iam.sample.passwdmgmt.custom.NumCustomPasswordElement version=1.0.1 name=num pwd element metadata name=PasswordElementNumvalue1valuemetadata plugin plugin pluginclass= oracle.iam.sample.passwdmgmt.custom.DictionaryPasswordElement version=1.0.1 name=Dictionary password element metadata name=PasswordElementNumvalue2valuemetadata plugin plugins .... oimplugins

7.3.3 Developing Plug-ins

The develop a plug-in: 1. Identify the plug-in point to extend. 2. Idenitify the Java class that implements the plug-in point interface. Package the Java class and other dependent classes into a JAR file. Put the JAR file in the lib directory. 3. Create the plugin.xml file. See Declaring Plug-ins on page 7-4 for details. 4. Identify the resource files required by the plug-in, such as property files, resource bundles, and image files. 5. Zip the entire package. An Oracle Identity Manager plug-in is distributed as a ZIP file with a specified directory structure. The directory structure is as follows: ■ The plugin.xml file: The XML file contains the metadata associated with all the plug-ins such as the plug-in point it extends, the class implementing the plug-in, name, and the version number. All the fields in the XML are Note: You can have multiple versions of the plug-in stored and the feature can request a specific version of the plug-in from the plug-in framework. 7-6 Oracle Fusion Middleware Developers Guide for Oracle Identity Manager mandatory except the name. If the name is not given, then plugin class name is used as the name. ■ The lib directory: The lib directory consists of JAR files that contains the classes implementing the plug-in logic and the dependent library JAR files. In most instances, this directory consists of a single JAR file with the implementation of all the plug-ins that are specified in plugin.xml. ■ The resources directory: Contains resource files required by the plug-in, such as property files, resource bundles, and image files. These resources given in the resources directory of the plug-in zip can be accessed as follows: this.getClass.getClassLoader.getResourceAsStreamresource_name; Multiple plug-ins implementing the same plug-in point can be part of the same ZIP file. A plug-in has a Java class that implements the plug-in point interface. The plug-in library JAR can contain other dependent classes as well, but the class implementing the plug-in is the only one that is exposed to the feature. This class must be specified in plugin.xml. 6. Place the ZIP file in the file store lib directory or database store. See About Plug-in Stores on page 7-2 for details. 7. If the ZIP is placed in the database store, then register the plug-in by using the Plug-in Registration Utility, as described in Registering Plug-ins on page 7-6.

7.4 Registering Plug-ins

You can register the plug-ins by using APIs and Plugin Registration Utility. ■ Registering and Unregistering Plug-ins By Using APIs ■ Registering and Unregistering Plug-ins By Using the Plugin Registration Utility

7.4.1 Registering and Unregistering Plug-ins By Using APIs

You can use the following APIs for registration-related tasks: ■ PlatformService.registerPlugin ■ PlatformService.unRegisterPlugin Here is an example: ClientPlatform platform = OIMClient.getInstance; platform.loginusername, password; PlatformService service = platform.getServicePlatformService.class; File zipFile = new FilefileName; FileInputStream fis = new FileInputStreamzipFile; int size = int zipFile.length; byte[] b = new byte[size]; int bytesRead = fis.readb, 0, size; while bytesRead size { bytesRead += fis.readb, bytesRead, size - bytesRead; } fis.close; service.registerPluginb; service.unRegisterPluginpluginID, version; Developing Plug-ins 7-7

7.4.2 Registering and Unregistering Plug-ins By Using the Plugin Registration Utility