Вот совершенно не сервлетный пример:
Предполагая, что вы создали свой фильтр запросов и / или ответов, вы можете добавить их в свой код запуска следующим образом:
(Обратите внимание, что класс ApiInterceptor в этом примере является и фильтром запроса, и ответом)
final URI BASE_URI = UriBuilder.fromUri("http://localhost/").port(9999).build();
System.out.println("Investigating Api services...");
ResourceConfig rc = new PackagesResourceConfig(
"path.to.your.resource.objects");
System.out.println("Registering interceptors...");
rc.getProperties().put(ResourceConfig.PROPERTY_CONTAINER_REQUEST_FILTERS, ApiInterceptor.class.getName());
rc.getProperties().put(ResourceConfig.PROPERTY_CONTAINER_RESPONSE_FILTERS, ApiInterceptor.class.getName());
Debug.print("Starting grizzly...");
GrizzlyServerFactory.createHttpServer(BASE_URI, rc);
Debug.print("The app started @", BASE_URI.toString());
Debug.print("Enjoy!");
System.in.read();