/*
  * Resolves the source label. This is where the request originated from. This can be a link,
  * direct page access, checkbox etc. The source label is then setup upon the given cycle in the
  * for of: PageClassName.componentId.
  */
 private void resolveSourceLabel(
     IRequestTarget requestTarget, JamonMonitoredWebRequestCycle cycle) {
   if (requestTarget instanceof IBookmarkablePageRequestTarget) {
     IBookmarkablePageRequestTarget target = (IBookmarkablePageRequestTarget) requestTarget;
     cycle.comesFromPage(target.getPageClass());
     cycle.setSource(target.getPageClass().getSimpleName());
   } else if (requestTarget instanceof IListenerInterfaceRequestTarget) {
     IListenerInterfaceRequestTarget target = (IListenerInterfaceRequestTarget) requestTarget;
     Class<? extends Page> pageClass = target.getPage().getClass();
     cycle.comesFromPage(pageClass);
     String source =
         addComponentNameToLabelIfNotRedirectPageRequestTarget(target, pageClass.getSimpleName());
     cycle.setSource(source);
   } else {
     doResolveSourceLabel(requestTarget, cycle);
   }
 }
  /*
   * returns the relative path with a max of 3. This to prevent extremely long names. My guess is
   * that three is sufficient for determining which link was clicked.
   */
  private String getRelativePath(IListenerInterfaceRequestTarget target) {

    String relativePath = target.getTarget().getPageRelativePath();
    String[] parts = relativePath.split(DELIMETER);
    if (parts.length > 3) {
      relativePath =
          new StringBuilder(parts[parts.length - 3])
              .append(DELIMETER)
              .append(parts[parts.length - 2])
              .append(DELIMETER)
              .append(parts[parts.length - 1])
              .toString();
    }
    return relativePath;
  }