Search in sources :

Example 1 with PluginMgmtService

use of org.b3log.solo.service.PluginMgmtService in project solo by b3log.

the class PluginRefresher method action.

@Override
public void action(final Event<List<AbstractPlugin>> event) throws EventException {
    final List<AbstractPlugin> plugins = event.getData();
    LOGGER.log(Level.DEBUG, "Processing an event[type={0}, data={1}] in listener[className={2}]", new Object[] { event.getType(), plugins, PluginRefresher.class.getName() });
    final LatkeBeanManager beanManager = Lifecycle.getBeanManager();
    final PluginRepository pluginRepository = beanManager.getReference(PluginRepositoryImpl.class);
    final Transaction transaction = pluginRepository.beginTransaction();
    try {
        final PluginMgmtService pluginMgmtService = beanManager.getReference(PluginMgmtService.class);
        pluginMgmtService.refresh(plugins);
        transaction.commit();
    } catch (final Exception e) {
        if (transaction.isActive()) {
            transaction.rollback();
        }
        LOGGER.log(Level.ERROR, "Processing plugin loaded event error", e);
        throw new EventException(e);
    }
}
Also used : PluginMgmtService(org.b3log.solo.service.PluginMgmtService) Transaction(org.b3log.latke.repository.Transaction) EventException(org.b3log.latke.event.EventException) PluginRepository(org.b3log.solo.repository.PluginRepository) AbstractPlugin(org.b3log.latke.plugin.AbstractPlugin) EventException(org.b3log.latke.event.EventException) LatkeBeanManager(org.b3log.latke.ioc.LatkeBeanManager)

Aggregations

EventException (org.b3log.latke.event.EventException)1 LatkeBeanManager (org.b3log.latke.ioc.LatkeBeanManager)1 AbstractPlugin (org.b3log.latke.plugin.AbstractPlugin)1 Transaction (org.b3log.latke.repository.Transaction)1 PluginRepository (org.b3log.solo.repository.PluginRepository)1 PluginMgmtService (org.b3log.solo.service.PluginMgmtService)1