/** * 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); }
/** * Instantiates a new simple profile monitor. * * @param label * the label * @param parent * the parent */ public SimpleProfileMonitor(final Signature label, final SimpleProfileMonitor parent) { this(SignatureHelper.getAsString(label), parent); }
private static ConstructorSignature getAsConstructorSignature(final String label) throws ReflectiveOperationException { String ctor = StringUtils.substringAfterLast(label, " ").trim(); String className = StringUtils.substringBefore(ctor, "("); Class<?>[] params = getParameterTypes(label); return getAsConstructorSignature(Class.forName(className), params); }
private static ConstructorSignature getAsConstructorSignature(final Class<?> clazz, final Class<?>[] parameterTypes) throws ReflectiveOperationException { Constructor<?> ctor = clazz.getConstructor(parameterTypes); return getAsSignature(ctor); }
/** * Gets the return value for the given joinpoint. The return values are * returned in the same order as the were recorded. I.e. if for the same * joinpoint first the value "1" and then the value "2" is recorded you'll * get first "1", then "2" as the return value. * * @param joinPoint * the join point * @return the return value */ public Object getReturnValue(final JoinPoint joinPoint) { String statement = JoinPointHelper.getAsLongString(joinPoint); if (SignatureHelper.hasReturnType(joinPoint.getSignature())) { return getReturnValue(statement); } LOG.debug("REPLAY: {}", statement); return null; }
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 ConstructorSignature getAsConstructorSignature(String label) throws ClassNotFoundException, SecurityException, NoSuchMethodException { String ctor = StringUtils.substringAfterLast(label, " ").trim(); String className = StringUtils.substringBefore(ctor, "("); Class<?>[] params = getParameterTypes(label); return getAsConstructorSignature(Class.forName(className), params); }
public void log(final JoinPoint joinPoint, final Object returnValue) { String statement = JoinPointHelper.getAsLongString(joinPoint); if ((returnValue != null) && (SignatureHelper.hasReturnType(joinPoint.getSignature()))) { try { saveLazy(statement, returnValue);
/** * 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); }
/** * @see patterntesting.runtime.monitor.ProfileMonitor#getLabel() */ public String getLabel() { if (this.label == null) { return "root"; } else { return SignatureHelper.getAsString(label); } }
private static Signature getAsSignature(final Class<?> clazz, final String methodName, final Class<?>[] parameterTypes) throws ReflectiveOperationException { Method method = clazz.getMethod(methodName, parameterTypes); return getAsSignature(method); }
/** * We use now the signature without the return value. That's enough. * * @param sig the sig * * @return the monitor for sig */ public SimpleProfileMonitor getMonitor(Signature sig) { String label = SignatureHelper.getAsString(sig); for (SimpleProfileMonitor mon : childs) { String monLabel = SignatureHelper.getAsString(mon.label); if (label.equals(monLabel)) { return mon; } } return null; }
private static ConstructorSignature getAsConstructorSignature(Class<?> clazz, Class<?>[] parameterTypes) throws ClassNotFoundException, SecurityException, NoSuchMethodException { Constructor<?> ctor = clazz.getConstructor(parameterTypes); return getAsSignature(ctor); }
/** * The difference to Signature.toString() is that in case of a methode * or constructor the return type is not part of result. * * @param sig the sig * * @return signature as string * * @deprecated Use {@link SignatureHelper#getAsString(Signature)} instead */ @Deprecated public static String getAsString(Signature sig) { return SignatureHelper.getAsString(sig); }
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); }
/** * We use now the signature without the return value. That's enough. * * @param sig * the sig * * @return the monitor for sig */ public SimpleProfileMonitor getMonitor(final Signature sig) { String lbl = SignatureHelper.getAsString(sig); return getMonitor(lbl); }
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"); } }
/** * Gets the monitor. * * @param sig the signature * * @return the monitor */ public static ProfileMonitor getMonitor(Signature sig) { String label = SignatureHelper.getAsString(sig); ProfileMonitor mon = JamonMonitorFactory.start(label); return mon; }
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"); } }
/** * Start profile monitor for the given signature. * * @param sig * the signature * @return the profile monitor */ public ProfileMonitor startProfileMonitorFor(final Signature sig) { return this.startProfileMonitorFor(SignatureHelper.getAsString(sig)); }