/** * @param response * @throws IOException */ private void sendIndex(SlingHttpServletResponse response) throws IOException { PrintWriter writer = response.getWriter(); writer.append(DocumentationConstants.HTML_HEADER); writer.append("<h1>List of Services</h1>"); writer.append("<ul>"); Map<String, ServletDocumentation> m = servletTracker.getServletDocumentation(); List<ServletDocumentation> o = new ArrayList<ServletDocumentation>(m.values()); Collections.sort(o); for (ServletDocumentation k : o) { String key = k.getKey(); if (key != null) { writer.append("<li><a href=\""); writer.append(DocumentationConstants.PREFIX + "/servlet"); writer.append("?p="); writer.append(k.getKey()); writer.append("\">"); writer.append(k.getName()); writer.append("</a><p>"); writer.append(k.getShortDescription()); writer.append("</p></li>"); } } writer.append("</ul>"); writer.append(DocumentationConstants.HTML_FOOTER); }
/** * {@inheritDoc} * * @see * org.apache.sling.api.servlets.SlingSafeMethodsServlet#doGet(org.apache.sling.api.SlingHttpServletRequest, * org.apache.sling.api.SlingHttpServletResponse) */ @Override protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException { RequestParameter p = request.getRequestParameter("p"); if (p == null) { sendIndex(response); } else { ServletDocumentation doc = servletTracker.getServletDocumentation().get(p.getString()); if (doc == null) { response.setBufferSize(404); return; } send(request, response, doc); } return; }
public void deactivate() { if (servletTracker != null) { servletTracker.close(); servletTracker = null; } }
public void activate(ComponentContext context) { BundleContext bundleContext = context.getBundleContext(); servletTracker = new ServletDocumentationTracker(bundleContext); servletTracker.open(); }