Search in sources :

Example 1 with DefaultApiDescription

use of com.navercorp.pinpoint.common.util.DefaultApiDescription in project pinpoint by naver.

the class ApiDescriptionParser method parse.

//  org.springframework.web.servlet.FrameworkServlet.doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
// com.mysql.jdbc.ConnectionImpl.setAutoCommit(boolean autoCommitFlag)
//        com.mysql.jdbc.ConnectionImpl.commit()
// org.apache.catalina.core.StandardHostValve.invoke(org.apache.catalina.connector.Request request, org.apache.catalina.connector.Response response):110
public ApiDescription parse(String apiDescriptionString) {
    if (apiDescriptionString == null) {
        throw new NullPointerException("apiDescriptionString must not be null");
    }
    final int methodStart = apiDescriptionString.lastIndexOf(METHOD_PARAM_START);
    if (methodStart == -1) {
        throw new IllegalArgumentException("'(' not found. invalid apiDescriptionString:" + apiDescriptionString);
    }
    final int methodEnd = apiDescriptionString.lastIndexOf(METHOD_PARAM_END);
    if (methodEnd == -1) {
        throw new IllegalArgumentException("')' not found. invalid apiDescriptionString:" + apiDescriptionString);
    }
    final int classIndex = apiDescriptionString.lastIndexOf(DOT, methodStart);
    if (classIndex == -1) {
        throw new IllegalArgumentException("'.' not found. invalid apiDescriptionString:" + apiDescriptionString);
    }
    String className = parseClassName(apiDescriptionString, classIndex);
    ApiDescription api = new DefaultApiDescription();
    api.setClassName(className);
    String methodName = parseMethodName(apiDescriptionString, methodStart, classIndex);
    api.setMethodName(methodName);
    String parameterDescriptor = apiDescriptionString.substring(methodStart + 1, methodEnd);
    String[] parameterList = parseParameter(parameterDescriptor);
    String[] simpleParameterList = parseSimpleParameter(parameterList);
    api.setSimpleParameter(simpleParameterList);
    int lineIndex = apiDescriptionString.lastIndexOf(':');
    // TODO for now, check and display the lineNumber
    if (lineIndex != -1) {
        try {
            int line = Integer.parseInt(apiDescriptionString.substring(lineIndex + 1, apiDescriptionString.length()));
            api.setLine(line);
        } catch (NumberFormatException e) {
            LoggerFactory.getLogger(this.getClass()).warn("line number parse error {}", e);
        }
    }
    return api;
}
Also used : DefaultApiDescription(com.navercorp.pinpoint.common.util.DefaultApiDescription) DefaultApiDescription(com.navercorp.pinpoint.common.util.DefaultApiDescription) ApiDescription(com.navercorp.pinpoint.common.util.ApiDescription)

Aggregations

ApiDescription (com.navercorp.pinpoint.common.util.ApiDescription)1 DefaultApiDescription (com.navercorp.pinpoint.common.util.DefaultApiDescription)1