public class MyBundle {
public void start() {
System.out.println("MyBundle started!");
}
public void stop() {
System.out.println("MyBundle stopped!");
}
}
properties
bundle.name=MyBundle
bundle.class=com.example.MyBundle
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
public class Main {
public static void main(String[] args) {
try {
Properties properties = new Properties();
FileInputStream fis = new FileInputStream("systemBundle.properties");
properties.load(fis);
fis.close();
String bundleName = properties.getProperty("bundle.name");
String bundleClass = properties.getProperty("bundle.class");
Class<?> clazz = Class.forName(bundleClass);
Object instance = clazz.getDeclaredConstructor().newInstance();
clazz.getMethod("start").invoke(instance);
e.printStackTrace();
}
}
}