use of org.apache.wicket.application.CompoundClassResolver in project pf4j-wicket by pf4j.
the class PluginManagerInitializer method init.
@Override
public void init(Application application) {
pluginManager = createPluginManager(application);
if (pluginManager == null) {
throw new WicketRuntimeException("Plugin manager cannot be null");
}
log.debug("Created plugin manager {}", pluginManager);
// load plugins
pluginManager.loadPlugins();
// init plugins
List<PluginWrapper> resolvedPlugins = pluginManager.getResolvedPlugins();
for (PluginWrapper plugin : resolvedPlugins) {
if (plugin.getPlugin() instanceof WicketPlugin) {
((WicketPlugin) plugin.getPlugin()).init(application);
}
}
// start plugins
pluginManager.startPlugins();
// set class resolver
CompoundClassResolver classResolver = new CompoundClassResolver();
classResolver.add(new DefaultClassResolver());
List<PluginWrapper> startedPlugins = pluginManager.getStartedPlugins();
for (PluginWrapper plugin : startedPlugins) {
classResolver.add(new PluginClassResolver(plugin));
}
application.getApplicationSettings().setClassResolver(classResolver);
// store plugin manager in application
application.setMetaData(PLUGIN_MANAGER_KEY, pluginManager);
// add PluginComponentInjector
application.getComponentInstantiationListeners().add(new PluginComponentInjector(application));
}
Aggregations