package de.chandre.admintool;

import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jminix.console.servlet.MiniConsoleServlet;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.embedded.ServletRegistrationBean;
import org.springframework.boot.context.web.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Servlet initializer for JMiniX (JMX) Servlet
 *  
 * @author adhr
 *
 */
@Configuration
public class JMiniXConfiguration extends SpringBootServletInitializer
{
	private static final Logger LOGGER = LogManager.getFormatterLogger(JMiniXConfiguration.class);
	
	@Bean
    public MiniConsoleServlet jMiniXServlet() {
        return new MiniConsoleServlet();
    }
	
	@Bean
	public ServletRegistrationBean jMiniXServletRegistration(@Value("${jminix.urlMappings:/jmx/*}") String urlMappings) {
		ServletRegistrationBean registration = new ServletRegistrationBean(jMiniXServlet());
		LOGGER.info("initalize JMX-Servlet with URL mapping: %s", urlMappings);
		for (String urlMapping : urlMappings.split(";")) {
			if (StringUtils.isNotBlank(urlMapping)) {
				registration.addUrlMappings(urlMapping);
			}
		}
		return registration;
	}
}

@@ -207,16 +207,79 @@
 ervlet;%0A
+import org.springframework.beans.factory.annotation.Autowired;%0A
 import o
@@ -329,16 +329,16 @@
 .Value;%0A
-
 import o
@@ -589,16 +589,65 @@
 uration;
+%0Aimport org.springframework.core.env.Environment;
 %0A%0A/**%0A *
@@ -905,16 +905,64 @@
 ass);%0A%09%0A
+%09@Autowired%0A%09private Environment environment;%0A%09%0A
 %09@Bean%0A 
@@ -1183,16 +1183,16 @@
 ings) %7B%0A
-
 %09%09Servle
@@ -1270,16 +1270,286 @@
 let());%0A
+%09%09%0A%09%09if (null == urlMappings %7C%7C urlMappings.startsWith(%22$%22)) %7B%0A%09%09%09if (null != environment && null != environment.getProperty(%22jminix.urlMappings%22)) %7B%0A%09%09%09%09urlMappings = environment.getProperty(%22jminix.urlMappings%22);%0A%09%09%09%7D else %7B%0A%09%09%09%09urlMappings = %22/jmx/*%22;%0A%09%09%09%7D%0A%09%09%7D%0A%09%09%0A%09%09%0A
 %09%09LOGGER

servlet configuration