use of com.qcadoo.tenant.api.MultiTenantCallback in project qcadoo by qcadoo.
the class DefaultModuleFactoryAccessor method multiTenantDisable.
@Override
public void multiTenantDisable(final int tenantId, final Plugin plugin) {
List<ModuleFactory<?>> factories = new ArrayList<ModuleFactory<?>>(moduleFactoryRegistry.values());
Collections.reverse(factories);
for (ModuleFactory<?> moduleFactory : factories) {
List<Module> modules = ((InternalPlugin) plugin).getModules(moduleFactory);
Collections.reverse(modules);
for (final Module module : modules) {
MultiTenantUtil.doInMultiTenantContext(tenantId, new MultiTenantCallback() {
@Override
public void invoke() {
module.multiTenantDisable();
}
});
}
}
}
use of com.qcadoo.tenant.api.MultiTenantCallback in project qcadoo by qcadoo.
the class DefaultModuleFactoryAccessor method init.
@Override
public void init(final List<Plugin> pluginsToInitialize) {
for (ModuleFactory<?> moduleFactory : moduleFactoryRegistry.values()) {
moduleFactory.preInit();
for (Plugin plugin : pluginsToInitialize) {
for (Module module : ((InternalPlugin) plugin).getModules(moduleFactory)) {
module.init();
}
}
moduleFactory.postInit();
}
List<ModuleFactory<?>> factories = new ArrayList<ModuleFactory<?>>(moduleFactoryRegistry.values());
List<Plugin> plugins = new ArrayList<Plugin>(pluginsToInitialize);
for (ModuleFactory<?> moduleFactory : factories) {
for (final Plugin plugin : plugins) {
List<Module> modules = ((InternalPlugin) plugin).getModules(moduleFactory);
for (final Module module : modules) {
if (plugin.hasState(PluginState.ENABLED)) {
module.enableOnStartup();
MultiTenantUtil.doInMultiTenantContext(new MultiTenantCallback() {
@Override
public void invoke() {
module.multiTenantEnableOnStartup();
}
});
}
}
}
}
Collections.reverse(factories);
Collections.reverse(plugins);
for (ModuleFactory<?> moduleFactory : factories) {
for (final Plugin plugin : plugins) {
List<Module> modules = ((InternalPlugin) plugin).getModules(moduleFactory);
Collections.reverse(modules);
for (final Module module : modules) {
if (!plugin.hasState(PluginState.ENABLED) && !plugin.hasState(PluginState.ENABLING)) {
module.disableOnStartup();
MultiTenantUtil.doInMultiTenantContext(new MultiTenantCallback() {
@Override
public void invoke() {
module.multiTenantDisableOnStartup();
}
});
}
}
}
}
}
Aggregations