Search in sources :

Example 1 with CompoundClassResolver

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));
}
Also used : DefaultClassResolver(org.apache.wicket.application.DefaultClassResolver) CompoundClassResolver(org.apache.wicket.application.CompoundClassResolver) WicketRuntimeException(org.apache.wicket.WicketRuntimeException) PluginWrapper(org.pf4j.PluginWrapper)

Aggregations

WicketRuntimeException (org.apache.wicket.WicketRuntimeException)1 CompoundClassResolver (org.apache.wicket.application.CompoundClassResolver)1 DefaultClassResolver (org.apache.wicket.application.DefaultClassResolver)1 PluginWrapper (org.pf4j.PluginWrapper)1