I have a feeling I know the answer, but I want to see what the experts think.
I have a lot of different Script Modules that get loaded into my module and I will have others to add.
Based on what I originally was learning how the scripting modules worked the SDK example included the BundleUtil section in the static{}
static {
BundleUtil.get().addBundle(
myScriptModule.class.getSimpleName(),
myScriptModule.class.getClassLoader(),
myScriptModule.class.getName().replace('.', '/'));
}
Initially I thought I would make an abstract class to house the Bundle section so I could not have to have the same code in every script module class.
abstract class
public abstract class ScriptModule {
public ScriptModule () {
BundleUtil.get().addBundle(
this.getClass().getSimpleName(),
this.getClass().getClassLoader(),
this.getClass().getName().replace('.', '/'));
}
}
I think this causes a problem since it would attempt to addBundle every time the class is created which makes sense based on it being in the constructor and not static.
Any ideas on making the code cleaner or should I just roll with the punches and just have the code be in each class?
I could also be going about this all wrong, so guidance is much appreciated.