{"action":"created","issue":{"url":"https://api.github.com/repos/apache/wicket/issues/127","labels_url":"https://api.github.com/repos/apache/wicket/issues/127/labels{/name}","comments_url":"https://api.github.com/repos/apache/wicket/issues/127/comments","events_url":"https://api.github.com/repos/apache/wicket/issues/127/events","html_url":"https://github.com/apache/wicket/pull/127","id":88652183,"number":127,"title":"Added constructor to Websocket filters ","user":{"login":"pulse00","id":185278,"avatar_url":"https://avatars.githubusercontent.com/u/185278?v=3","gravatar_id":"","url":"https://api.github.com/users/pulse00","html_url":"https://github.com/pulse00","followers_url":"https://api.github.com/users/pulse00/followers","following_url":"https://api.github.com/users/pulse00/following{/other_user}","gists_url":"https://api.github.com/users/pulse00/gists{/gist_id}","starred_url":"https://api.github.com/users/pulse00/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pulse00/subscriptions","organizations_url":"https://api.github.com/users/pulse00/orgs","repos_url":"https://api.github.com/users/pulse00/repos","events_url":"https://api.github.com/users/pulse00/events{/privacy}","received_events_url":"https://api.github.com/users/pulse00/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-06-16T08:10:01Z","updated_at":"2015-06-16T08:21:50Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/apache/wicket/pulls/127","html_url":"https://github.com/apache/wicket/pull/127","diff_url":"https://github.com/apache/wicket/pull/127.diff","patch_url":"https://github.com/apache/wicket/pull/127.patch"},"body":"Currently it's not possible to use the Websocket filters in pure java-based servlet 3.0 configurations without subclassing the Filter and  overriding the `getApplicationFactory` method. \r\n\r\nThis PR adds the `WicketFilter(Webapplication application)` constructor to all websocket filters.\r\n"},"comment":{"url":"https://api.github.com/repos/apache/wicket/issues/comments/112330107","html_url":"https://github.com/apache/wicket/pull/127#issuecomment-112330107","issue_url":"https://api.github.com/repos/apache/wicket/issues/127","id":112330107,"user":{"login":"pulse00","id":185278,"avatar_url":"https://avatars.githubusercontent.com/u/185278?v=3","gravatar_id":"","url":"https://api.github.com/users/pulse00","html_url":"https://github.com/pulse00","followers_url":"https://api.github.com/users/pulse00/followers","following_url":"https://api.github.com/users/pulse00/following{/other_user}","gists_url":"https://api.github.com/users/pulse00/gists{/gist_id}","starred_url":"https://api.github.com/users/pulse00/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pulse00/subscriptions","organizations_url":"https://api.github.com/users/pulse00/orgs","repos_url":"https://api.github.com/users/pulse00/repos","events_url":"https://api.github.com/users/pulse00/events{/privacy}","received_events_url":"https://api.github.com/users/pulse00/received_events","type":"User","site_admin":false},"created_at":"2015-06-16T08:21:50Z","updated_at":"2015-06-16T08:21:50Z","body":"In our application, we setup the servlet context purely in java, without any `web.xml`. This looks something like this:\r\n\r\n```java\r\nConstructor<? extends CustomWebApplication> constructor = applicationClass.getConstructor(StageType.class);\r\nCustomWebApplication CustomWebApplication = constructor.newInstance(activeStateType);\r\nCustomWebApplication.setApplicationContext(rootContext);\r\n\r\nWicketFilter wicketFilter = new WicketFilter(CustomWebApplication) {\r\n\r\n  @Override\r\n  public void init(boolean isServlet, FilterConfig filterConfig) throws ServletException {\r\n    setFilterPath(\"\");\r\n    super.init(isServlet, filterConfig);\r\n  }\r\n};\r\n\r\nservletContext.addFilter(\"hstsFilter\", HSTSFilter.class).addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), false, \"/*\");\r\n\r\nFilterRegistration.Dynamic wicketFilterRegistration = servletContext.addFilter(\"wicketFilter\", wicketFilter);\r\nwicketFilterRegistration.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, \"/*\");\r\n```\r\n\r\nNow if we want to add websocket support by adding using a `WebsocketFilter`, we need to create a custom subclass because the constructor with the `Webapplication` argument is not public in the subclasses of `WicketFilter`: \r\n\r\n```java\r\nprivate class CustomWebsocketFilter extends Tomcat7WebSocketFilter {\r\n\r\n  private WebApplication application;\r\n\r\n  public CustomWebsocketFilter(WebApplication application) {\r\n    this.application = application;\r\n  }\r\n\r\n  @Override\r\n  protected IWebApplicationFactory getApplicationFactory() {\r\n    return new IWebApplicationFactory() {\r\n      @Override\r\n      public WebApplication createApplication(WicketFilter filter) {\r\n        return application;\r\n      }\r\n\r\n      @Override\r\n      public void destroy(WicketFilter filter) {\r\n        if (application != null)\r\n        {\r\n          try\r\n          {\r\n            ThreadContext.setApplication(application);\r\n            application.internalDestroy();\r\n          }\r\n          finally\r\n          {\r\n            ThreadContext.detach();\r\n            application = null;\r\n          }\r\n        }\r\n      }\r\n    };\r\n  }\r\n}\r\n```\r\nAt least that's how i understood the [documentation](https://github.com/pulse00/wicket/blob/master/wicket-core/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java#L109) of this specific constructor.\r\n\r\n"}}