Skip to content

Instantly share code, notes, and snippets.

@MarkMenard
Last active Dec 18, 2015
Embed
What would you like to do?
This Servelet listener is to work around https://github.com/jruby/jruby/issues/788 Written by bbrowning.
// Add this as a listener in your web.xml file prior to loading jruby-rack.
//
//
// <listener>
// <listener-class>lib.JnrConstantHackListener</listener-class>
// </listener>
// <listener>
// <listener-class>org.jruby.rack.rails.RailsServletContextListener</listener-class>
// </listener>
package lib;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import jnr.constants.ConstantSet;
public class JnrConstantHackListener implements ServletContextListener {
public void contextInitialized(final ServletContextEvent event) {
ConstantSet.getConstantSet( "AddressFamily" );
ConstantSet.getConstantSet( "Errno" );
ConstantSet.getConstantSet( "Fcntl" );
ConstantSet.getConstantSet( "INAddr" );
ConstantSet.getConstantSet( "IPProto" );
ConstantSet.getConstantSet( "NameInfo" );
ConstantSet.getConstantSet( "OpenFlags" );
ConstantSet.getConstantSet( "PRIO" );
ConstantSet.getConstantSet( "ProtocolFamily" );
ConstantSet.getConstantSet( "RLIM" );
ConstantSet.getConstantSet( "RLIMIT" );
ConstantSet.getConstantSet( "Shutdown" );
ConstantSet.getConstantSet( "Signal" );
ConstantSet.getConstantSet( "Sock" );
ConstantSet.getConstantSet( "SocketLevel" );
ConstantSet.getConstantSet( "SocketOption" );
ConstantSet.getConstantSet( "Sysconf" );
ConstantSet.getConstantSet( "TCP" );
ConstantSet.getConstantSet( "WaitFlags" );
}
public void contextDestroyed(final ServletContextEvent event) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment