use of org.apache.camel.ManagementStatisticsLevel in project camel by apache.
the class AbstractCamelContextFactoryBean method initJMXAgent.
protected void initJMXAgent() throws Exception {
CamelJMXAgentDefinition camelJMXAgent = getCamelJMXAgent();
boolean disabled = false;
if (camelJMXAgent != null) {
disabled = camelJMXAgent.getDisabled() != null && CamelContextHelper.parseBoolean(getContext(), camelJMXAgent.getDisabled());
}
if (disabled) {
LOG.info("JMXAgent disabled");
// clear the existing lifecycle strategies define by the DefaultCamelContext constructor
getContext().getLifecycleStrategies().clear();
// no need to add a lifecycle strategy as we do not need one as JMX is disabled
getContext().setManagementStrategy(new DefaultManagementStrategy());
} else if (camelJMXAgent != null) {
LOG.info("JMXAgent enabled: {}", camelJMXAgent);
DefaultManagementAgent agent = new DefaultManagementAgent(getContext());
if (camelJMXAgent.getConnectorPort() != null) {
agent.setConnectorPort(CamelContextHelper.parseInteger(getContext(), camelJMXAgent.getConnectorPort()));
}
if (camelJMXAgent.getCreateConnector() != null) {
agent.setCreateConnector(CamelContextHelper.parseBoolean(getContext(), camelJMXAgent.getCreateConnector()));
}
if (camelJMXAgent.getMbeanObjectDomainName() != null) {
agent.setMBeanObjectDomainName(CamelContextHelper.parseText(getContext(), camelJMXAgent.getMbeanObjectDomainName()));
}
if (camelJMXAgent.getMbeanServerDefaultDomain() != null) {
agent.setMBeanServerDefaultDomain(CamelContextHelper.parseText(getContext(), camelJMXAgent.getMbeanServerDefaultDomain()));
}
if (camelJMXAgent.getRegistryPort() != null) {
agent.setRegistryPort(CamelContextHelper.parseInteger(getContext(), camelJMXAgent.getRegistryPort()));
}
if (camelJMXAgent.getServiceUrlPath() != null) {
agent.setServiceUrlPath(CamelContextHelper.parseText(getContext(), camelJMXAgent.getServiceUrlPath()));
}
if (camelJMXAgent.getUsePlatformMBeanServer() != null) {
agent.setUsePlatformMBeanServer(CamelContextHelper.parseBoolean(getContext(), camelJMXAgent.getUsePlatformMBeanServer()));
}
if (camelJMXAgent.getOnlyRegisterProcessorWithCustomId() != null) {
agent.setOnlyRegisterProcessorWithCustomId(CamelContextHelper.parseBoolean(getContext(), camelJMXAgent.getOnlyRegisterProcessorWithCustomId()));
}
if (camelJMXAgent.getRegisterAlways() != null) {
agent.setRegisterAlways(CamelContextHelper.parseBoolean(getContext(), camelJMXAgent.getRegisterAlways()));
}
if (camelJMXAgent.getRegisterNewRoutes() != null) {
agent.setRegisterNewRoutes(CamelContextHelper.parseBoolean(getContext(), camelJMXAgent.getRegisterNewRoutes()));
}
if (camelJMXAgent.getIncludeHostName() != null) {
agent.setIncludeHostName(CamelContextHelper.parseBoolean(getContext(), camelJMXAgent.getIncludeHostName()));
}
if (camelJMXAgent.getUseHostIPAddress() != null) {
agent.setUseHostIPAddress(CamelContextHelper.parseBoolean(getContext(), camelJMXAgent.getUseHostIPAddress()));
}
if (camelJMXAgent.getMask() != null) {
agent.setMask(CamelContextHelper.parseBoolean(getContext(), camelJMXAgent.getMask()));
}
if (camelJMXAgent.getLoadStatisticsEnabled() != null) {
agent.setLoadStatisticsEnabled(CamelContextHelper.parseBoolean(getContext(), camelJMXAgent.getLoadStatisticsEnabled()));
}
if (camelJMXAgent.getEndpointRuntimeStatisticsEnabled() != null) {
agent.setEndpointRuntimeStatisticsEnabled(CamelContextHelper.parseBoolean(getContext(), camelJMXAgent.getEndpointRuntimeStatisticsEnabled()));
}
if (camelJMXAgent.getStatisticsLevel() != null) {
String level = CamelContextHelper.parseText(getContext(), camelJMXAgent.getStatisticsLevel());
ManagementStatisticsLevel msLevel = getContext().getTypeConverter().mandatoryConvertTo(ManagementStatisticsLevel.class, level);
agent.setStatisticsLevel(msLevel);
}
ManagementStrategy managementStrategy = new ManagedManagementStrategy(getContext(), agent);
getContext().setManagementStrategy(managementStrategy);
// clear the existing lifecycle strategies define by the DefaultCamelContext constructor
getContext().getLifecycleStrategies().clear();
getContext().addLifecycleStrategy(new DefaultManagementLifecycleStrategy(getContext()));
}
}
Aggregations