Question

I have been looking at using the relational data access in the xpages extension library. I have it working, but I put the jar on the server to get it to work. The recommended method of deploying the jdbc driver seems to be through a custom extension library.

Does there exist some instructions on how to create this. I don't have any experience in creating OSGi plugins at all so I am a bit out of my element here.

Was it helpful?

Solution

Patrick, it is easier than it looks like. In Eclipse (or the Java view of Domino Designer) you create a plug-in project. There you define the Extension point that makes it an extension library and implement a simple class (mainly returning the version).

Your plug-in.xml would look like this (you might have other content too):

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
   <!-- This makes the plug-in an XPages extension library -->
   <extension point="com.ibm.commons.Extension">
      <service class="com.ibm.ctp.CoreLibrary" type="com.ibm.xsp.Library">
      </service>
   </extension>
</plugin>

In the manifest (Eclipse has a nice editor, so don't worry) you make sure to export the JDBC driver packages, so they become visible. Finally your activator class looks like this:

import org.eclipse.core.runtime.Plugin;
import org.osgi.framework.BundleContext;

public class Activator extends Plugin {

// The shared instance
private static Activator    plugin;
private static String       version;

/**
 * Returns the shared instance
 * 
 * @return the shared instance
 */
public static CSIActivator getDefault() {
    return plugin;
}

public static String getVersion() {
    if (version == null) {
        try {
            version = plugin.getBundle().getHeaders().get("Bundle-Version").toString();
        } catch (Exception e) {
            e.printStackTrace();
            version = "3.7.2";
        }
    }
    return version;
}

public Activator() {
    // No Action needed
}

/* (non-Javadoc)
 * @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext)
 */
@Override
public void start(final BundleContext context) throws Exception {
    super.start(context);
    plugin = this;
}

/* (non-Javadoc)
 * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
 */
@Override
public void stop(final BundleContext context) throws Exception {
    plugin = null;
    super.stop(context);
}

}

Hope that helps

OTHER TIPS

There are also detailed instructions in the book, XPages Extension Library, starting from page 381. The author uses DB2 in the example, but it was quite easy to switch to MySQL driver.

There is a new OpenNTF project that you can use to create a plug-in for a JDBC driver. See http://www.openntf.org/Internal/home.nsf/project.xsp?action=openDocument&name=XPages%20JDBC%20Driver%20Wrapper

Howard

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top