2

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.

Patrick Sawyer
  • 1,362
  • 7
  • 22

3 Answers3

2

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

stwissel
  • 20,110
  • 6
  • 54
  • 101
  • It does help. I will need to play around with it for a bit first though. Do you have an opinion on the jdbc driver wrapper project on openNTF? – Patrick Sawyer Oct 09 '13 at 16:23
  • Andrejus for sure knows his stuff, so use the project http://www.openntf.org/internal/home.nsf/project.xsp?action=openDocument&name=XPages%20JDBC%20Driver%20Wrapper . Feel free to accept the answer – stwissel Oct 09 '13 at 16:29
1

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.

Lauri Laanti
  • 948
  • 7
  • 11
1

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

Howard
  • 1,503
  • 7
  • 16