private static ConstructorSignature getAsConstructorSignature(final Class<?> clazz, final Class<?>[] parameterTypes) throws ReflectiveOperationException { Constructor<?> ctor = clazz.getConstructor(parameterTypes); return getAsSignature(ctor); }
private static Signature getAsSignature(Class<?> clazz, String methodName, Class<?>[] parameterTypes) throws ClassNotFoundException, SecurityException, NoSuchMethodException { Method method = clazz.getMethod(methodName, parameterTypes); return getAsSignature(method); }
private static Signature getAsSignature(final Class<?> clazz, final String methodName, final Class<?>[] parameterTypes) throws ReflectiveOperationException { Method method = clazz.getMethod(methodName, parameterTypes); return getAsSignature(method); }
private static ConstructorSignature getAsConstructorSignature(Class<?> clazz, Class<?>[] parameterTypes) throws ClassNotFoundException, SecurityException, NoSuchMethodException { Constructor<?> ctor = clazz.getConstructor(parameterTypes); return getAsSignature(ctor); }
private void init(final Constructor<?> ctor) { if (ctor.getAnnotation(DontProfileMe.class) != null) { LOG.trace("@DontProfileMe {} is ignored", ctor); return; } Signature sig = SignatureHelper.getAsSignature(ctor); ProfileMonitor mon = getMonitor(sig); LOG.trace("{} initialized", mon); }
private static void init(Method method) { if (method.getAnnotation(DontProfileMe.class) != null) { if (log.isTraceEnabled()) { log.trace("@DontProfileMe " + method + " is ignored"); } return; } Signature sig = SignatureHelper.getAsSignature(method); ProfileMonitor mon = getMonitor(sig); if (log.isTraceEnabled()) { log.trace(mon + " initialized"); } }
private static void init(Constructor<?> ctor) { if (ctor.getAnnotation(DontProfileMe.class) != null) { if (log.isTraceEnabled()) { log.trace("@DontProfileMe " + ctor + " is ignored"); } return; } Signature sig = SignatureHelper.getAsSignature(ctor); ProfileMonitor mon = getMonitor(sig); if (log.isTraceEnabled()) { log.trace(mon + " initialized"); } }
private void init(final Method method) { if (method.getAnnotation(DontProfileMe.class) != null) { if (LOG.isTraceEnabled()) { LOG.trace("@DontProfileMe " + method + " is ignored"); } return; } Signature sig = SignatureHelper.getAsSignature(method); ProfileMonitor mon = getMonitor(sig); if (LOG.isTraceEnabled()) { LOG.trace(mon + " initialized"); } }
/** * Gets the as signature. * * @param label * e.g. "java.lang.String.substring(int)" or "new * java.lang.String() * @return the given label as Signature * @throws ReflectiveOperationException * the reflective operation exception */ public static Signature getAsSignature(final String label) throws ReflectiveOperationException { if (label.startsWith("new ")) { return getAsConstructorSignature(label); } String classDotMethod = StringUtils.substringBefore(label, "("); String className = StringUtils.substringBeforeLast(classDotMethod, "."); String methodName = StringUtils.substringAfterLast(classDotMethod, "."); Class<?>[] params = getParameterTypes(label); return getAsSignature(Class.forName(className), methodName, params); }
/** * Adds the child. * * @param label the label */ public void addChild(String label) { try { Signature sig = SignatureHelper.getAsSignature(label); SimpleProfileMonitor child = new SimpleProfileMonitor(sig, this); addChild(child); } catch (Exception e) { log.debug("can't add " + label, e); } }
/** * Adds the child. * * @param lbl * the label */ public void addChild(final String lbl) { try { Signature sig = SignatureHelper.getAsSignature(lbl); SimpleProfileMonitor child = new SimpleProfileMonitor(sig, this); addChild(child); } catch (ReflectiveOperationException ex) { LOG.info("Cannot add child '{}':", lbl, ex); } }
/** * Gets the as signature. * * @param label e.g. "java.lang.String.substring(int)" or * "new java.lang.String() * * @return the given label as Signature * * @throws ClassNotFoundException the class not found exception * @throws NoSuchMethodException the no such method exception * @throws SecurityException the security exception */ public static Signature getAsSignature(String label) throws ClassNotFoundException, SecurityException, NoSuchMethodException { if (label.startsWith("new ")) { return getAsConstructorSignature(label); } String classDotMethod = StringUtils.substringBefore(label, "("); String className = StringUtils.substringBeforeLast(classDotMethod, "."); String methodName = StringUtils.substringAfterLast(classDotMethod, "."); Class<?>[] params = getParameterTypes(label); return getAsSignature(Class.forName(className), methodName, params); }