psiprobe.ProbeConfig Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of psi-probe-core Show documentation
Show all versions of psi-probe-core Show documentation
PSI Probe Core - Core logic, data models, and controllers
/**
* Licensed under the GPL License. You may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
* WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
* PURPOSE.
*/
package psiprobe;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.PropertiesFactoryBean;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
import org.springframework.core.io.ClassPathResource;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
import org.springframework.web.servlet.HandlerMapping;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.ThemeResolver;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping;
import org.springframework.web.servlet.i18n.CookieLocaleResolver;
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
import org.springframework.web.servlet.theme.FixedThemeResolver;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.springframework.web.servlet.view.JstlView;
import psiprobe.beans.ClusterWrapperBean;
import psiprobe.beans.ContainerListenerBean;
import psiprobe.beans.ContainerWrapperBean;
import psiprobe.beans.JBossResourceResolverBean;
import psiprobe.beans.JvmMemoryInfoAccessorBean;
import psiprobe.beans.LogResolverBean;
import psiprobe.beans.ResourceResolver;
import psiprobe.beans.ResourceResolverBean;
import psiprobe.beans.RuntimeInfoAccessorBean;
import psiprobe.beans.stats.collectors.AppStatsCollectorBean;
import psiprobe.beans.stats.collectors.ClusterStatsCollectorBean;
import psiprobe.beans.stats.collectors.ConnectorStatsCollectorBean;
import psiprobe.beans.stats.collectors.DatasourceStatsCollectorBean;
import psiprobe.beans.stats.collectors.JvmMemoryStatsCollectorBean;
import psiprobe.beans.stats.collectors.RuntimeStatsCollectorBean;
import psiprobe.beans.stats.listeners.MemoryPoolMailingListener;
import psiprobe.beans.stats.listeners.StatsCollectionListener;
import psiprobe.beans.stats.providers.ConnectorSeriesProvider;
import psiprobe.beans.stats.providers.MultipleSeriesProvider;
import psiprobe.beans.stats.providers.StandardSeriesProvider;
import psiprobe.model.stats.StatsCollection;
import psiprobe.scheduler.jobs.AppStatsJobDetail;
import psiprobe.scheduler.jobs.ClusterStatsJobDetail;
import psiprobe.scheduler.jobs.ConnectorStatsJobDetail;
import psiprobe.scheduler.jobs.DatasourceStatsJobDetail;
import psiprobe.scheduler.jobs.MemoryStatsJobDetail;
import psiprobe.scheduler.jobs.RuntimeStatsJobDetail;
import psiprobe.scheduler.jobs.StatsSerializerJobDetail;
import psiprobe.scheduler.triggers.AppStatsTrigger;
import psiprobe.scheduler.triggers.ClusterStatsTrigger;
import psiprobe.scheduler.triggers.ConnectorStatsTrigger;
import psiprobe.scheduler.triggers.DatasourceStatsTrigger;
import psiprobe.scheduler.triggers.MemoryStatsTrigger;
import psiprobe.scheduler.triggers.RuntimeStatsTrigger;
import psiprobe.scheduler.triggers.StatsSerializerTrigger;
import psiprobe.tools.Mailer;
/**
* The Class ProbeConfig.
*/
@EnableWebMvc
@Configuration
@ComponentScan(basePackages = {"psiprobe"})
public class ProbeConfig implements WebMvcConfigurer {
/** The Constant logger. */
private static final Logger logger = LoggerFactory.getLogger(ProbeConfig.class);
/**
* Gets the container listener bean.
*
* @return the container listener bean
*/
@Bean(name = "containerListener")
public ContainerListenerBean getContainerListenerBean() {
logger.debug("Instantiated containerListener");
return new ContainerListenerBean();
}
/**
* Gets the container wrapper bean.
*
* @return the container wrapper bean
*/
@Bean(name = "containerWrapper")
public ContainerWrapperBean getContainerWrapperBean() {
logger.debug("Instantiated containerWrapper");
return new ContainerWrapperBean();
}
/**
* Gets the cluster wrapper bean.
*
* @return the cluster wrapper bean
*/
@Bean(name = "clusterWrapper")
public ClusterWrapperBean getClusterWrapperBean() {
logger.debug("Instantiated clusterWrapper");
return new ClusterWrapperBean();
}
/**
* Gets the mailer.
*
* @return the mailer
*/
@Bean(name = "mailer")
public Mailer getMailer() {
logger.debug("Instantiated mailer");
return new Mailer();
}
/**
* Gets the default res.
*
* @return the default res
*/
@Bean(name = "datasourceMappers")
public List getDefaultRes() {
logger.debug("Instantiated datasourceMappers");
List list = new ArrayList<>();
list.add("psiprobe.beans.accessors.BoneCpDatasourceAccessor");
list.add("psiprobe.beans.accessors.C3P0DatasourceAccessor");
list.add("psiprobe.beans.accessors.DbcpDatasourceAccessor");
list.add("psiprobe.beans.accessors.Dbcp2DatasourceAccessor");
list.add("psiprobe.beans.accessors.HikariCpDatasourceAccessor");
list.add("psiprobe.beans.accessors.Tomcat7DbcpDatasourceAccessor");
list.add("psiprobe.beans.accessors.Tomcat85DbcpDatasourceAccessor");
list.add("psiprobe.beans.accessors.Tomcat9DbcpDatasourceAccessor");
list.add("psiprobe.beans.accessors.TomcatJdbcPoolDatasourceAccessor");
list.add("psiprobe.beans.accessors.OracleDatasourceAccessor");
list.add("psiprobe.beans.accessors.OracleUcpDatasourceAccessor");
list.add("psiprobe.beans.accessors.OpenEjbManagedDatasourceAccessor");
list.add("psiprobe.beans.accessors.ViburCpDatasourceAccessor");
list.add("psiprobe.beans.accessors.TomEeJdbcPoolDatasourceAccessor");
list.add("psiprobe.beans.accessors.OpenEjbBasicDatasourceAccessor");
return list;
}
/**
* Gets the resource resolver bean.
*
* @return the resource resolver bean
*/
@Bean(name = "default")
public ResourceResolverBean getResourceResolverBean() {
logger.debug("Instantiated default resourceResolverBean");
return new ResourceResolverBean();
}
/**
* Gets the jboss resource resolver bean.
*
* @return the jboss resource resolver bean
*/
@Bean(name = "jboss")
public JBossResourceResolverBean getJBossResourceResolverBean() {
logger.debug("Instantiated jbossResourceResolverBean");
return new JBossResourceResolverBean();
}
/**
* Gets the resource resolvers.
*
* @param jbossResourceResolverBean the jboss resource resolver bean
* @param resourceResolverBean the resource resolver bean
* @return the resource resolvers
*/
@Bean(name = "resourceResolvers")
public Map getResourceResolvers(
@Autowired JBossResourceResolverBean jbossResourceResolverBean,
@Autowired ResourceResolverBean resourceResolverBean) {
logger.debug("Instantiated resourceResolvers");
Map map = new HashMap<>();
map.put("jboss", jbossResourceResolverBean);
map.put("default", resourceResolverBean);
return map;
}
/**
* Gets the adapter classes.
*
* @return the adapter classes
*/
// TODO We should make this configurable
@Bean(name = "adapterClasses")
public List getAdapterClasses() {
logger.debug("Instantiated adapterClasses");
List list = new ArrayList<>();
list.add("psiprobe.Tomcat90ContainerAdapter");
list.add("psiprobe.Tomcat85ContainerAdapter");
list.add("psiprobe.Tomcat70ContainerAdapter");
return list;
}
/**
* Gets the stdout files. Any file added to this list will be displayed.
*
* @return the stdout files
*/
@Bean(name = "stdoutFiles")
public List getStdoutFiles() {
logger.debug("Instantiated stdoutFiles");
List list = new ArrayList<>();
try {
for (Entry