コード例 #1
0
 /**
  * @see javax.servlet.ServletContext#getResourcePaths(java.lang.String)
  *     <p>This method was added in the Servlet 2.3 API however the OSGi HttpService currently does
  *     not provide support for this method in the HttpContext interface. To support
  *     "getResourcePaths(...) this implementation uses reflection to check for and then call the
  *     associated HttpContext.getResourcePaths(...) method opportunistically. Null is returned if
  *     the method is not present or fails.
  */
 @SuppressWarnings("unchecked")
 public Set<String> getResourcePaths(String name) {
   if (name == null || !name.startsWith("/")) // $NON-NLS-1$
   return null;
   try {
     Method getResourcePathsMethod =
         httpContext
             .getClass()
             .getMethod("getResourcePaths", new Class[] {String.class}); // $NON-NLS-1$
     if (!getResourcePathsMethod.isAccessible()) getResourcePathsMethod.setAccessible(true);
     return (Set<String>) getResourcePathsMethod.invoke(httpContext, new Object[] {name});
   } catch (Exception e) {
     // ignore
   }
   return null;
 }
コード例 #2
0
 public String getMimeType(String name) {
   String mimeType = httpContext.getMimeType(name);
   return (mimeType != null) ? mimeType : servletContext.getMimeType(name);
 }