Last updated May 14, 2009 06:06, by Igor Minar

Setting Up grizzly-sendfile

Starting with version 0.3 grizzly-sendfile is compatible with grizzly 1.9.15+ and GlassFish v3b48+. For instructions on how to configure version 0.2 with Glassfish v2 look here.

Using grizzly-sendfile with grizzly

Grab the latest core distribution from the download page (more information on distributions).

Then in your code, just add grizzly-sendfile's SendfileFilter to GrizzlyServer:

 import com.igorminar.grizzlysendfile.SendfileFilter;
 import com.sun.grizzly.http.embed.GrizzlyWebServer; 
 GrizzlyWebServer ws = new GrizzlyWebServer(port);
 ws.addAsyncFilter(new SendfileFilter());

You can configure grizzly-sendfile via JVM parameters passed in via command line (-D..) or by setting them via System.setProperty(SendfileConfig.<config key>, value); before the SendfileFilter class is loaded. A proper pragmatic configuration is on the way.

Using grizzly-sendfile with GlassFish v3

Supposing that you have your GlassFish v3 installed and set up, grab the latest osgi bundle from the download page (more information on distributions)

Then install it in GlassFish v3:

 bin/asadmin deploy --type osgi --force=true path/to/grizzly-sendfile-osgi-0.3.jar
 bin/asadmin create-jvm-options -Dcom.sun.grizzly.asyncHandlerClass=com.sun.grizzly.arp.DefaultAsyncHandler
 bin/asadmin create-jvm-options -Dcom.sun.grizzly.asyncHandler.ports=8080  # or other port if not using the default
 bin/asadmin create-jvm-options -Dcom.sun.grizzly.asyncFilters=com.igorminar.grizzlysendfile.SendfileFilter
 bin/asadmin create-jvm-options -Dcom.igorminar.grizzlysendfile.AllowedPaths=/absolute/path/to/files/*
 bin/asadmin restart-domain domain1  # or different name if not using the default

If you are interested in using the AutoSendfile Feature you can add these two options and restart:

 bin/asadmin create-jvm-options -Dcom.igorminar.grizzlysendfile.AutoSendfileUriPrefix=/sendfile/
 bin/asadmin create-jvm-options -Dcom.igorminar.grizzlysendfile.AutoSendfileFileDir=/absolute/path/to/dir/with/files/to/serve/

Advanced Configuration

For more configuration options and explanation of all options mentioned on this page, please check out the Advanced Configuration page.

  • Mysql
  • Glassfish
  • Jruby
  • Rails
  • Nblogo
Terms of Use; Privacy Policy;
© 2014, Oracle Corporation and/or its affiliates
(revision 20160708.bf2ac18)
Please Confirm