changes to plugins

small change in function that finds plugins to make it easier to add
temporary ones while developing.
This commit is contained in:
Douglas Gillespie 2023-05-26 17:07:18 +01:00
parent af5d21df5f
commit d24687dfe9
2 changed files with 6 additions and 32 deletions

View File

@ -36,7 +36,7 @@ public class PamguardVersionInfo {
/**
* Release date
*/
static public final String date = "9 May 2023";
static public final String date = "26 May 2023";
// /**
// * Release type - Beta or Core

View File

@ -45,14 +45,10 @@ import fftManager.FFTDataUnit;
import fftManager.PamFFTControl;
import group3dlocaliser.Group3DLocaliserControl;
import meygenturbine.MeygenTurbine;
import networkTransfer.receive.BuoyStatusDataUnit;
import networkTransfer.receive.NetworkReceiver;
import printscreen.PrintScreenControl;
import rockBlock.RockBlockControl;
import turbineops.TurbineOperationControl;
import GPS.GpsDataUnit;
import Map.MapController;
import Map.gridbaselayer.GridbaseControl;
import NMEA.NMEADataUnit;
import PamController.PamControlledUnitSettings;
import PamController.PamController;
@ -66,7 +62,6 @@ import PamguardMVC.PamDataBlock;
import analogarraysensor.ArraySensorControl;
import backupmanager.BackupManager;
import beamformer.continuous.BeamFormerControl;
import beamformer.localiser.BeamFormLocaliserControl;
import bearinglocaliser.BearingLocaliserControl;
import binaryFileStorage.SecondaryBinaryStore;
import cepstrum.CepstrumControl;
@ -1067,7 +1062,7 @@ final public class PamModel implements PamModelInterface, PamSettings {
// clear the current list
pluginList.clear();
daqList.clear();
/*
* If developing a new PAMPlugin in eclipse, the easiest way to do it is to make a new
* Eclipse project for your plugin code. Within that project, copy this PamModel class
@ -1082,7 +1077,6 @@ final public class PamModel implements PamModelInterface, PamSettings {
* When you export the code for your plugin to a jar file, remember to NOT inlcude the copy of
* PamModel !
*/
// Load up whatever default classloader was used to create this class. Must use the same classloader
// for all plugins, or else we will not be able to create proper dependencies between them or be able
@ -1150,30 +1144,11 @@ final public class PamModel implements PamModelInterface, PamSettings {
// to add that URL to the default classloader path.
URL newURL = jarList.get(i).toURI().toURL();
// original method
// Method method = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
// method.setAccessible(true);
// method.invoke(cl, newURL);
// first fix attempt - create a brand new URLClassLoader. As expected, we get a ClassCastException when trying
// to load the parameters so we can't save params using this method
// URL[] newURLArray = new URL[1];
// newURLArray[0] = newURL;
// cl = new URLClassLoader(newURLArray);
// second attempt - custom class loader with the system app loader specified as the parent. Loads controlled unit, but
// as before it doesn't load the parameters
classLoader.addURL(newURL);
// third attempt
// Class<?> genericClass = cl.getClass();
// Method method = genericClass.getSuperclass().getDeclaredMethod("addURL", new Class[] {URL.class});
// method.setAccessible(true);
// method.invoke(cl, new Object[] {newURL});
// Save the name of the class to the global pluginBeingLoaded variable, and load the class.
this.setPluginBeingLoaded(className);
// Class c = cl.loadClass(className);
@ -1254,9 +1229,8 @@ final public class PamModel implements PamModelInterface, PamSettings {
"for help.<p>" +
"This plug-in will not be available for loading";
String help = null;
int ans = WarnOnce.showWarning(PamController.getMainFrame(), title, msg, WarnOnce.WARNING_MESSAGE, help, e1);
int ans = WarnOnce.showWarning(PamController.getInstance().getGuiFrameManager().getFrame(0), title, msg, WarnOnce.WARNING_MESSAGE, help, e1);
System.err.println("Exception while loading " + className);
System.err.println(e1.getMessage());
continue;
}
}
@ -1269,7 +1243,7 @@ final public class PamModel implements PamModelInterface, PamSettings {
"for help.<p>" +
"This plug-in will not be available for loading";
String help = null;
int ans = WarnOnce.showWarning(PamController.getMainFrame(), title, msg, WarnOnce.WARNING_MESSAGE, help, ex);
int ans = WarnOnce.showWarning(PamController.getInstance().getGuiFrameManager().getFrame(0), title, msg, WarnOnce.WARNING_MESSAGE, help, ex);
System.err.println("Exception while loading " + jarList.get(i).getName());
continue;
}
@ -1294,7 +1268,7 @@ final public class PamModel implements PamModelInterface, PamSettings {
// instantiate the plugin control class using the custom class loader
try {
File classFile = new File(pf.getJarFile());
// File classFile = new File(pf.getJarFile());
//URLClassLoader cl = new URLClassLoader(new URL[]{classFile.toURI().toURL()});
// mi = PamModuleInfo.registerControlledUnit(pf.getClassName(), pf.getDescription(),cl);
mi = PamModuleInfo.registerControlledUnit(pf.getClassName(), pf.getDescription(),classLoader);
@ -1360,7 +1334,7 @@ final public class PamModel implements PamModelInterface, PamSettings {
"for help.<p>" +
"This plug-in will not be available for loading";
String help = null;
int ans = WarnOnce.showWarning(PamController.getMainFrame(), title, msg, WarnOnce.WARNING_MESSAGE, help, e1);
int ans = WarnOnce.showWarning(PamController.getInstance().getGuiFrameManager().getFrame(0), title, msg, WarnOnce.WARNING_MESSAGE, help, e1);
System.err.println("Exception while loading " + pf.getDefaultName());
pluginList.remove(pf);
continue;