Пример #1
0
  /**
   * Invokes the filter with the context.
   *
   * @param context The proxy context.
   */
  public void invoke(ProxyContext context) {
    try {
      if (next != null) {
        next.invoke(context);
      }
    } catch (MessageException ex) {
      throw ex;
    } catch (Throwable ex) {
      throw new MessageException(ex);
    } finally {
      try {
        if (context.getHttpMethod() != null) {

          // we don't want to keep the connection open if authentication info was sent
          if (context.hasAuthorization()) {
            if (context.getHttpMethod() instanceof FlexGetMethod) {
              ((FlexGetMethod) context.getHttpMethod()).setConnectionForced(true);
            } else if (context.getHttpMethod() instanceof FlexPostMethod) {
              ((FlexPostMethod) context.getHttpMethod()).setConnectionForced(true);
            } else {
              Assert.testAssertion(
                  false, "Should have custom Flex method: " + context.getHttpMethod().getClass());
            }
          }
          context.getHttpMethod().releaseConnection();
        }
      } catch (Exception e) {
        if (Trace.error) e.printStackTrace();
      }
    }
  }
 // Added in Servlet 2.5
 public String getContextPath() {
   try {
     Method getContextPathMethod =
         servletContext.getClass().getMethod("getContextPath", (Class<?>[]) null); // $NON-NLS-1$
     return (String) getContextPathMethod.invoke(servletContext, (Object[]) null)
         + proxyContext.getServletPath();
   } catch (Exception e) {
     // ignore
   }
   return null;
 }
 public void removeAttribute(String attributeName) {
   Dictionary<String, Object> attributes = proxyContext.getContextAttributes(httpContext);
   attributes.remove(attributeName);
 }
 public void setAttribute(String attributeName, Object attributeValue) {
   Dictionary<String, Object> attributes = proxyContext.getContextAttributes(httpContext);
   attributes.put(attributeName, attributeValue);
 }
 public Enumeration<String> getAttributeNames() {
   Dictionary<String, Object> attributes = proxyContext.getContextAttributes(httpContext);
   return attributes.keys();
 }
 public Object getAttribute(String attributeName) {
   Dictionary<String, Object> attributes = proxyContext.getContextAttributes(httpContext);
   return attributes.get(attributeName);
 }
 public RequestDispatcher getRequestDispatcher(String arg0) {
   return new RequestDispatcherAdaptor(
       servletContext.getRequestDispatcher(proxyContext.getServletPath() + arg0));
 }