Adding Multiple Initial Context Factories

You can add multiple initial context factories in the newly created plug-in project.

Prerequisites

Newly created plug-in project is displayed on the Project Explorer pane.

Procedure

  1. Double-click on the Activator.java file from the src folder of the plug-in project.
    Activator.java file is opened. By default, there are getProvider() and getProviders() methods are present in the Activator.java file.
  2. Uncomment the getProviders() method.
  3. Create another copy of the CustomJMSProvider.java file from the src folder in the same folder. You can rename the copy file.
  4. Double-click the newly copied file.
    Newly created Java file is opened.
  5. In the getInitialContextFactory() method, remove the existing context factory and add the name of initial context factory that is to be supported.
  6. Open the Activator.java file and create an object of newly created class.
  7. Add the object to the AbstractJMSProvider array.
  8. Expand the OSGI-INF directory to see CustomJMSProvider.xml file.
  9. Create copy of the CustomJMSProvider.xml file with the same name as given to the newly created copy of the CustomJMSProvider.java file.
  10. Double-click the newly created copy of the CustomJMSProvider.xml file.
    Newly created XML file is opened.
  11. Replace existing class name with the new class name in the <implementation class> attribute.
  12. Expand MetaINF folder to see the MANIFEST.MF file.
  13. Add an entry of the newly created XML file in the service-implement attribute in the form OSGI-INF/<class name>.xml
  14. Save all the open files.
    Note: If you want to add more context factories, repeat the procedure.