use of com.newrelic.agent.util.MethodCache in project newrelic-java-agent by newrelic.
the class CacheServiceTest method getMethodCacheIdentity.
@Test
public void getMethodCacheIdentity() throws Exception {
CacheService cacheService = ServiceFactory.getCacheService();
MethodCache methodCache = cacheService.getMethodCache(TEST1_CLASS_NAME, GETFIELD1_METHOD_NAME, GETFIELD1_METHOD_DESC);
MethodCache methodCache2 = cacheService.getMethodCache(TEST1_CLASS_NAME, GETFIELD1_METHOD_NAME, GETFIELD1_METHOD_DESC);
Assert.assertEquals(methodCache, methodCache2);
}
use of com.newrelic.agent.util.MethodCache in project newrelic-java-agent by newrelic.
the class CacheServiceTest method getMethodCacheBasic.
@Test
public void getMethodCacheBasic() throws Exception {
CacheService cacheService = ServiceFactory.getCacheService();
MethodCache methodCache = cacheService.getMethodCache(TEST1_CLASS_NAME, GETFIELD1_METHOD_NAME, GETFIELD1_METHOD_DESC);
String expectedField = "field1";
Test1 test1 = new Test1(expectedField);
Class<?> clazz = test1.getClass();
Method method = methodCache.getDeclaredMethod(clazz);
String actualField = (String) method.invoke(test1);
Assert.assertEquals(expectedField, actualField);
}
use of com.newrelic.agent.util.MethodCache in project newrelic-java-agent by newrelic.
the class CacheService method getMethodCache.
public MethodCache getMethodCache(String className, String methodName, String methodDesc) {
ClassMethodSignature key = new ClassMethodSignature(className.replace('/', '.'), methodName, methodDesc);
MethodCache methodCache = methodCaches.get(key);
if (methodCache != null) {
return methodCache;
}
methodCache = new MethodCache(methodName);
MethodCache oldMethodCache = methodCaches.putIfAbsent(key, methodCache);
return oldMethodCache == null ? methodCache : oldMethodCache;
}
Aggregations