package com.mindoo.domino.jna.xsp.internal;

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

public class DominoJNAActivator extends Plugin {
	public static final String PLUGIN_ID = "com.mindoo.domino.jna.xsp";
	
	private static DominoJNAActivator plugin;
	
	@Override
	public void start(BundleContext context) throws Exception {
		super.start(context);
		plugin = this;
	}
	
	@Override
	public void stop(BundleContext context) throws Exception {
		plugin = null;
		super.stop(context);
	}
	
	public static DominoJNAActivator getDefault() {
		return plugin;
	}
}

@@ -38,16 +38,95 @@
 ernal;%0A%0A
+import java.security.AccessController;%0Aimport java.security.PrivilegedAction;%0A%0A
 import o
@@ -157,16 +157,16 @@
 Plugin;%0A
-
 import o
@@ -362,16 +362,56 @@
 plugin;%0A
+%09private static Class m_jnaNativeClazz;%0A
 %09%0A%09@Over
@@ -500,16 +500,16 @@
 ntext);%0A
-
 %09%09plugin
@@ -517,16 +517,1011 @@
 = this;%0A
+%09%09if (m_jnaNativeClazz==null) %7B%0A%09%09%09m_jnaNativeClazz = AccessController.doPrivileged(new PrivilegedAction%3CClass%3E() %7B%0A%0A%09%09%09%09@Override%0A%09%09%09%09public Class run() %7B%0A%09%09%09%09%09//enforce using the extracted JNA .dll/.so file instead of what we find on the PATH%0A%09%09%09%09%09System.setProperty(%22jna.nosys%22, %22true%22);%0A%09%09%09%09%09//change the library name from the default %22jnidispatch%22 to our own name, so that%0A%09%09%09%09%09//JNA does not load an jnidispatcher.dll from the Server's program directory%0A%09%09%09%09%09String oldLibName = System.getProperty(%22jna.boot.library.name%22);%0A%09%09%09%09%09System.setProperty(%22jna.boot.library.name%22, %22dominojnadispatch%22);%0A%09%09%09%09%09try %7B%0A%09%09%09%09%09%09//loading the Native class runs its static code that extracts and loads the jna dll%0A%09%09%09%09%09%09return DominoJNAActivator.class.forName(%22com.sun.jna.Native%22);%0A%09%09%09%09%09%7D catch (ClassNotFoundException e) %7B%0A%09%09%09%09%09%09e.printStackTrace();%0A%09%09%09%09%09%7D%0A%09%09%09%09%09finally %7B%0A%09%09%09%09%09%09if (oldLibName!=null)%0A%09%09%09%09%09%09%09System.setProperty(%22jna.boot.library.name%22,oldLibName);%0A%09%09%09%09%09%7D%0A%09%09%09%09%09return null;%0A%09%09%09%09%7D%0A%09%09%09%7D);%0A%09%09%7D%0A
 %09%7D%0A%09%0A%09@O

Work around dll version conflicts w/ jnidispatch.dll in Domino progdir