List of usage examples for javax.management JMException getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:net.community.chest.gitcloud.facade.frontend.git.GitController.java
private void serveRequest(RequestMethod method, HttpServletRequest req, HttpServletResponse rsp) throws IOException, ServletException { if (logger.isDebugEnabled()) { logger.debug("serveRequest(" + method + ")[" + req.getRequestURI() + "][" + req.getQueryString() + "]"); }/*w w w . j a va2 s .c om*/ if ((loopRetryTimeout > 0L) && (!loopDetected)) { long now = System.currentTimeMillis(), diff = now - initTimestamp; if ((diff > 0L) && (diff < loopRetryTimeout)) { try { MBeanInfo mbeanInfo = mbeanServer.getMBeanInfo(new ObjectName( "net.community.chest.gitcloud.facade.backend.git:name=BackendRepositoryResolver")); if (mbeanInfo != null) { logger.info("serveRequest(" + method + ")[" + req.getRequestURI() + "][" + req.getQueryString() + "]" + " detected loop: " + mbeanInfo.getClassName() + "[" + mbeanInfo.getDescription() + "]"); loopDetected = true; } } catch (JMException e) { if (logger.isDebugEnabled()) { logger.debug("serveRequest(" + method + ")[" + req.getRequestURI() + "][" + req.getQueryString() + "]" + " failed " + e.getClass().getSimpleName() + " to detect loop: " + e.getMessage()); } } } } ResolvedRepositoryData repoData = resolveTargetRepository(method, req); if (repoData == null) { throw ExtendedLogUtils.thrownLogging(logger, Level.WARNING, "serveRequest(" + method + ")[" + req.getRequestURI() + "][" + req.getQueryString() + "]", new NoSuchElementException("Failed to resolve repository")); } String username = authenticate(req); // TODO check if the user is allowed to access the repository via the resolve operation (push/pull) if at all (e.g., private repo) logger.info("serveRequest(" + method + ")[" + req.getRequestURI() + "][" + req.getQueryString() + "] user=" + username); /* * NOTE: this feature requires enabling cross-context forwarding. * In Tomcat, the 'crossContext' attribute in 'Context' element of * 'TOMCAT_HOME\conf\context.xml' must be set to true, to enable cross-context */ if (loopDetected) { // TODO see if can find a more efficient way than splitting and re-constructing URI uri = repoData.getRepoLocation(); ServletContext curContext = req.getServletContext(); String urlPath = uri.getPath(), urlQuery = uri.getQuery(); String[] comps = StringUtils.split(urlPath, '/'); String appName = comps[0]; ServletContext loopContext = Validate.notNull(curContext.getContext("/" + appName), "No cross-context for %s", appName); // build the relative path in the re-directed context StringBuilder sb = new StringBuilder( urlPath.length() + 1 + (StringUtils.isEmpty(urlQuery) ? 0 : urlQuery.length())); for (int index = 1; index < comps.length; index++) { sb.append('/').append(comps[index]); } if (!StringUtils.isEmpty(urlQuery)) { sb.append('?').append(urlQuery); } String redirectPath = sb.toString(); RequestDispatcher dispatcher = Validate.notNull(loopContext.getRequestDispatcher(redirectPath), "No dispatcher for %s", redirectPath); dispatcher.forward(req, rsp); if (logger.isDebugEnabled()) { logger.debug("serveRequest(" + method + ")[" + req.getRequestURI() + "][" + req.getQueryString() + "]" + " forwarded to " + loopContext.getContextPath() + "/" + redirectPath); } } else { executeRemoteRequest(method, repoData.getRepoLocation(), req, rsp); } }