Providing user-defined rules and dynamic class loading

The OSGi runtime controls package visibility across bundles. If a bundle does not explicitly import a package, then it will not have access to classes within that package when it comes to dynamically loading them. This is especially important to WebSphere MQ Everyplace, because it has been designed with this flexibility in mind. Without some small changes to the bundles, developers cannot use 3rd party or their own Rules or Adapters. There are two ways to remove this problem:

  1. OSGi version 3 includes a DynamicImport-Package statement for the bundles manifest file. This has been included in the MQeBundle.jar and as long as the user-defined class's package is exported from its bundles manifest. WebSphere MQ Everyplace will be able to have access to this class.
    Note:
    This functionality is available to SMF version 3.1.0 or higher.
  2. 2. Create a new MQeLoader and add all the user-defined classes before they are used, most likely within the bundles activator, for example:
    		String MyRule = "UserQMRule";
    		MQeLoader loader = new MQeLoader();
    		loader.addClass(MyRule, Class.forName(MyRule));
    		MQe.setLoader(loader);
     
    

Take care when using the second method, that the loader within WebSphere MQ Everyplace is not replaced with another loader from another bundle during the application runtime.



© IBM Corporation 2002. All Rights Reserved