code: private static ActivityContext getActivityContext(ServletContext servletContext, String attrName) {
          Object attr = servletContext.getAttribute(attrName);
          if (attr == null) {
              return null;
          }
          if (!(attr instanceof AspectranWebService)) {
              throw new IllegalStateException("Context attribute [" + attr + "] is not of type [" +
                      AspectranWebService.class.getName() + "]");
          }
          return ((CoreService)attr).getActivityContext();
      }
docs: Find the ActivityContext for this web aspectran service.
  
  @param servletContext ServletContext to find the web aspectran service for
  @param attrName the name of the ServletContext attribute to look for
  @return the ActivityContext for this web aspectran service