-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApuOilTankFactory.java
More file actions
31 lines (24 loc) · 1.18 KB
/
ApuOilTankFactory.java
File metadata and controls
31 lines (24 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package factory;
import configuration.Configuration;
import recorder.FlightRecorder;
import java.io.File;
import java.net.URL;
import java.net.URLClassLoader;
public class ApuOilTankFactory {
public static Object build() {
Object apuOilTankPort = null;
try {
URL[] urlList = {new File(Configuration.instance.pathToApuOilTankJavaArchive).toURI().toURL()};
URLClassLoader urlLoader = new URLClassLoader(urlList, ApuOilTankFactory.class.getClassLoader());
Class apuoiltank = Class.forName("APUOilTank", true, urlLoader);
FlightRecorder.instance.insert("ApuOilTankFactory", "ApuOilTank: " + apuoiltank.hashCode());
Object apuoiltankInstance = apuoiltank.getMethod("getInstance").invoke(null);
FlightRecorder.instance.insert("ApuOilTankFactory", "apuOilTankInstance: " + apuoiltankInstance.hashCode());
apuOilTankPort = apuoiltank.getDeclaredField("port").get(apuoiltankInstance);
FlightRecorder.instance.insert("ApuOilTankFactory","apuOilTankPort: "+apuoiltank.hashCode());
} catch (Exception e) {
e.printStackTrace();
}
return apuOilTankPort;
}
}