List of usage examples for org.apache.commons.lang3 ClassUtils getAbbreviatedName
public static String getAbbreviatedName(String className, int len)
Gets the abbreviated class name from a String .
The string passed in is assumed to be a class name - it is not checked.
The abbreviation algorithm will shorten the class name, usually without significant loss of meaning.
The abbreviated class name will always include the complete package hierarchy.
From source file:org.commonjava.indy.httprox.handler.ProxyResponseWriter.java
public ProxyResponseWriter(final HttproxConfig config, final StoreDataManager storeManager, final ContentController contentController, final KeycloakProxyAuthenticator proxyAuthenticator, final CacheProvider cacheProvider, final MDCManager mdcManager, final ProxyRepositoryCreator repoCreator, final StreamConnection accepted, final IndyMetricsConfig metricsConfig, final MetricRegistry metricRegistry, final CacheProducer cacheProducer) { this.config = config; this.contentController = contentController; this.storeManager = storeManager; this.proxyAuthenticator = proxyAuthenticator; this.cacheProvider = cacheProvider; this.mdcManager = mdcManager; this.repoCreator = repoCreator; this.peerAddress = accepted.getPeerAddress(); this.sourceChannel = accepted.getSourceChannel(); this.metricsConfig = metricsConfig; this.metricRegistry = metricRegistry; this.cls = ClassUtils.getAbbreviatedName(getClass().getName(), 1); // e.g., foo.bar.ClassA -> f.b.ClassA this.proxyAuthCache = cacheProducer.getCache(HTTP_PROXY_AUTH_CACHE); }
From source file:org.commonjava.indy.metrics.IndyMetricsConstants.java
/** * Get default metric name. Use abbreviated package name, e.g., foo.bar.ClassA.methodB -> f.b.ClassA.methodB */// w w w. j av a2s . com public static String getDefaultName(Class<?> declaringClass, String method) { // minimum len 1 shortens the package name and keeps class name String cls = ClassUtils.getAbbreviatedName(declaringClass.getName(), 1); return name(cls, method); }
From source file:org.commonjava.indy.metrics.IndyMetricsConstants.java
/** * Get default metric name. Use abbreviated package name, e.g., foo.bar.ClassA.methodB -> f.b.ClassA.methodB *//*from w w w . j ava2 s . c o m*/ public static String getDefaultName(String declaringClass, String method) { // minimum len 1 shortens the package name and keeps class name String cls = ClassUtils.getAbbreviatedName(declaringClass, 1); return name(cls, method); }
From source file:org.commonjava.indy.metrics.util.NameUtils.java
public static String getAbbreviatedName(Class cls) { return ClassUtils.getAbbreviatedName(cls, DEFAULT_LEN); }
From source file:org.commonjava.maven.galley.transport.htcli.internal.HttpDownload.java
@Override public DownloadJob call() { if (metricConfig == null || !metricConfig.isEnabled() || metricRegistry == null) { return doCall(); }//from w ww . j a v a 2 s . co m logger.trace("Download metric enabled, location: {}", location); String cls = ClassUtils.getAbbreviatedName(getClass().getName(), 1); // e.g., foo.bar.ClassA -> f.b.ClassA Timer repoTimer = null; String metricName = metricConfig.getMetricUniqueName(location); if (metricName != null) { repoTimer = metricRegistry.timer(name(metricConfig.getNodePrefix(), cls, "call", metricName)); logger.trace("Measure repo metric, metricName: {}", metricName); } final Timer globalTimer = metricRegistry.timer(name(metricConfig.getNodePrefix(), cls, "call")); final Timer.Context globalTimerContext = globalTimer.time(); Timer.Context repoTimerContext = null; if (repoTimer != null) { repoTimerContext = repoTimer.time(); } try { return doCall(); } finally { globalTimerContext.stop(); if (repoTimerContext != null) { repoTimerContext.stop(); } } }