2013-10-08 20 views
2

我一直在尋找在xpages擴展庫中使用關係數據訪問。我有它的工作,但我把這個罐子放在服務器上來讓它工作。部署jdbc驅動程序的推薦方法似乎是通過自定義擴展庫。用於關係驅動程序的xPages OSGi擴展庫

是否存在一些關於如何創建的說明。我根本沒有任何創建OSGi插件的經驗,所以我在這裏有點超出我的元素。

+1

FYI:http://www.openntf.org/internal/home.nsf/project.xsp?action=openDocument&name=XPages%20JDBC%20Driver%20Wrapper –

回答

2

Patrick, 它比它看起來更容易。在Eclipse(或Domino Designer的Java視圖)中,創建一個插件項目。在那裏你定義了擴展點,使它成爲擴展庫並實現一個簡單的類(主要返回版本)。

您的插件in.xml是這樣的(你可能有其他的內容太):

<?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> 

在清單(Eclipse有一個很好的編輯器,所以不用擔心),你一定要導出JDBC驅動程序包,以便它們可見。最後您激活器類看起來是這樣的:

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); 
} 

} 

希望幫助

+0

它確實幫助。儘管如此,我仍需要先嚐試一下。你對openNTF上的jdbc驅動包裝項目有意見嗎? –

+0

Andrejus肯定知道他的東西,所以使用該項目http://www.openntf.org/internal/home.nsf/project.xsp?action=openDocument&name=XPages%20JDBC%20Driver%20Wrapper。隨時接受答案 – stwissel

1

也有詳細說明,在書中,XPages Extension Library,從381頁開始筆者使用DB2的例子,但它是相當輕鬆切換到MySQL驅動程序。

+0

我真的需要挑選那本書。 –