开发者

JRuby Rack - How to add a servlet filter?

I'm trying (with no success) to pass the response of a JRuby Rack - Rails application to a filter in order to get it processed. Basically I want to use the Orbeon XForm Engine to enhance the XHTML output coming from my Rails application. If I use a simple Java servlet instead on JRuby Rack everything works smoothly.

Here's the web.xml file:

<!DOCTYPE web-app PUBLIC
  "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
  "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>

  <context-param>
    <param-name>public.root</param-name>
    <param-value>/</param-value>
  </context-param>

  <context-param>
    <param-name>rails.env</param-name>
    <param-value>production</param-value>
  </context-param>

  <context-param>
    <param-name>jruby.min.runtimes</param-name>
    <param-value>2</param-value>
  </context-param>

  <context-param>
    <param-name>jruby.max.runtimes</param-name>
    <param-value>4</param-value>
  </context-param>


  <filter>
    <filter-name>orbeon-xforms-filter</filter-name>
    <filter-class>org.orbeon.oxf.servlet.OrbeonXFormsFilter</filter-class>
    <init-param>
      <param-name>oxf.xforms.renderer.context</param-name>
      <param-value>/orbeon</param-value>
    </init-param>
  </filter>

  <!-- This is necessary so that XForms engine resources can be served appropriately -->
  <filter-mapping>
    <filter-name>orbeon-xforms-filter</filter-name>
    <url-pattern>/orbeon/*</url-pattern>
    <dispatcher>REQUEST</dispatch开发者_如何转开发er>
    <dispatcher>FORWARD</dispatcher>
  </filter-mapping>

  <!-- Any web resource under /xforms-jsp is processed by the XForms engine -->
  <filter-mapping>
    <filter-name>orbeon-xforms-filter</filter-name>
    <url-pattern>/page/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
  </filter-mapping>

  <filter>
    <filter-name>RackFilter</filter-name>
    <filter-class>org.jruby.rack.RackFilter</filter-class>
  </filter>

  <filter-mapping>
    <filter-name>RackFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>


  <listener>
    <listener-class>org.jruby.rack.rails.RailsServletContextListener</listener-class>
  </listener>


</web-app>

Thanks in advance

Sandro.


I'm not familiar with Orbeon XForms, so I'm not positive about what your problem is. But according to the above web.xml, the Orbeon filters are only applied to /orbeon/* and /page/* URLs, while the Rack filter gets applied to everything.

If the servlet approach works, why not stick with that?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜