use of org.apache.camel.spi.Registry in project camel by apache.
the class MetricsMessageHistoryService method doStart.
@Override
protected void doStart() throws Exception {
if (metricsRegistry == null) {
Registry camelRegistry = getCamelContext().getRegistry();
metricsRegistry = camelRegistry.lookupByNameAndType(MetricsComponent.METRIC_REGISTRY_NAME, MetricRegistry.class);
// create a new metricsRegistry by default
if (metricsRegistry == null) {
metricsRegistry = new MetricRegistry();
}
}
if (useJmx) {
ManagementAgent agent = getCamelContext().getManagementStrategy().getManagementAgent();
if (agent != null) {
MBeanServer server = agent.getMBeanServer();
if (server != null) {
reporter = JmxReporter.forRegistry(metricsRegistry).registerWith(server).inDomain(jmxDomain).build();
reporter.start();
}
} else {
throw new IllegalStateException("CamelContext has not enabled JMX");
}
}
// json mapper
this.mapper = new ObjectMapper().registerModule(new MetricsModule(getRateUnit(), getDurationUnit(), false));
if (getRateUnit() == TimeUnit.SECONDS && getDurationUnit() == TimeUnit.SECONDS) {
// they both use same units so reuse
this.secondsMapper = this.mapper;
} else {
this.secondsMapper = new ObjectMapper().registerModule(new MetricsModule(TimeUnit.SECONDS, TimeUnit.SECONDS, false));
}
}
use of org.apache.camel.spi.Registry in project camel by apache.
the class SpringLdapComponent method createEndpoint.
/**
* creates a Spring LDAP endpoint
* @param remaining name of the Spring LDAP template bean to be used for the LDAP operation
* @param parameters key-value pairs to be set on @see org.apache.camel.component.springldap.SpringLdapEndpoint.
* Currently supported keys are operation and scope.
* 'operation' is defined in org.apache.camel.component.springldap.LdapOperation.
* 'scope' must be one of "object", "onelevel", or "subtree".
*/
@Override
protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
CamelContext camelContext = getCamelContext();
Registry registry = camelContext.getRegistry();
LdapTemplate ldapTemplate = registry.lookupByNameAndType(remaining, LdapTemplate.class);
Endpoint endpoint = new SpringLdapEndpoint(remaining, ldapTemplate);
setProperties(endpoint, parameters);
return endpoint;
}
use of org.apache.camel.spi.Registry in project camel by apache.
the class CamelContextFactoryBean method initCustomRegistry.
protected void initCustomRegistry(SpringCamelContext context) {
Registry registry = getBeanForType(Registry.class);
if (registry != null) {
LOG.info("Using custom Registry: " + registry);
context.setRegistry(registry);
}
}
use of org.apache.camel.spi.Registry in project camel by apache.
the class MetricsComponent method createEndpoint.
@Override
protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
if (metricRegistry == null) {
Registry camelRegistry = getCamelContext().getRegistry();
metricRegistry = getOrCreateMetricRegistry(camelRegistry, METRIC_REGISTRY_NAME);
}
String metricsName = getMetricsName(remaining);
MetricsType metricsType = getMetricsType(remaining);
LOG.debug("Metrics type: {}; name: {}", metricsType, metricsName);
Endpoint endpoint = new MetricsEndpoint(uri, this, metricRegistry, metricsType, metricsName);
setProperties(endpoint, parameters);
return endpoint;
}
use of org.apache.camel.spi.Registry in project camel by apache.
the class MetricsRegistryService method doStart.
@Override
protected void doStart() throws Exception {
if (metricsRegistry == null) {
Registry camelRegistry = getCamelContext().getRegistry();
metricsRegistry = camelRegistry.lookupByNameAndType(MetricsComponent.METRIC_REGISTRY_NAME, MetricRegistry.class);
// create a new metricsRegistry by default
if (metricsRegistry == null) {
metricsRegistry = new MetricRegistry();
}
}
if (useJmx) {
ManagementAgent agent = getCamelContext().getManagementStrategy().getManagementAgent();
if (agent != null) {
MBeanServer server = agent.getMBeanServer();
if (server != null) {
reporter = JmxReporter.forRegistry(metricsRegistry).registerWith(server).inDomain(jmxDomain).build();
reporter.start();
}
} else {
throw new IllegalStateException("CamelContext has not enabled JMX");
}
}
// json mapper
this.mapper = new ObjectMapper().registerModule(new MetricsModule(getRateUnit(), getDurationUnit(), false));
if (getRateUnit() == TimeUnit.SECONDS && getDurationUnit() == TimeUnit.SECONDS) {
// they both use same units so reuse
this.secondsMapper = this.mapper;
} else {
this.secondsMapper = new ObjectMapper().registerModule(new MetricsModule(TimeUnit.SECONDS, TimeUnit.SECONDS, false));
}
}
Aggregations