de.chandre.admintool.melody.AdminToolJavaMelodyLoader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of admin-tools-melody Show documentation
Show all versions of admin-tools-melody Show documentation
admin-tools javamelody integrator
package de.chandre.admintool.melody;
import javax.annotation.PostConstruct;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import de.chandre.admintool.core.AbstractAdminToolLoader;
import de.chandre.admintool.core.AdminTool;
import de.chandre.admintool.core.component.AdminComponent;
import de.chandre.admintool.core.component.AdminComponentImpl;
import de.chandre.admintool.core.component.MenuEntry;
/**
* @author Andre
*/
@Component
public class AdminToolJavaMelodyLoader extends AbstractAdminToolLoader
{
private static final Log LOGGER = LogFactory.getLog(AdminToolJavaMelodyLoader.class);
@Autowired
private AdminTool adminTool;
@Autowired
private AdminToolJavaMelodyConfig config;
@PostConstruct
public void configureAdminTool()
{
if(!coreConfig.isEnabled() || !config.isEnabled()) {
LOGGER.info("admin tool's javaMelody view integration is deactivated");
return;
}
LOGGER.info("adding JavaMelody view to admin tool");
LOGGER.debug(toString());
AdminComponent component = new AdminComponentImpl();
component.setPosition(config.getComponentPosition());
component.getSecurityRoles().addAll(config.getSecurityRoles());
component.setDisplayName("JavaMelody");
component.addAdditionalCSS("/static/admintool/melody.css", true);
MenuEntry mainMenu = new MenuEntry();
mainMenu.setDisplayName("JavaMelody");
mainMenu.setName("javamelody");
mainMenu.setTarget("content/melody");
mainMenu.addVariable("melodyPath", config.getMelodyPath());
mainMenu.setResouceMessageKey(AdminTool.RESOURCE_MESSAGE_KEY_PREFIX + "javamelody.displayName");
component.setMainMenu(mainMenu);
adminTool.addComponent(component);
}
}