Skip to content

Instantly share code, notes, and snippets.

@abhirockzz
Created March 15, 2016 18:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abhirockzz/bdb0f98fe68c148f97d2 to your computer and use it in GitHub Desktop.
Save abhirockzz/bdb0f98fe68c148f97d2 to your computer and use it in GitHub Desktop.
Using custom (user defined) contextual data amongst JAX-RS request filters
public class ReqFilter_1 implements ContainerRequestFilter {
@Override
public void filter(ContainerRequestContext cReqCtx) throws IOException {
cReqCtx.setProperty("prop1", "value1");
}
}
public class ReqFilter_2 implements ContainerRequestFilter {
@Override
public void filter(ContainerRequestContext cReqCtx) throws IOException {
String val1 = (String) cReqCtx.getProperty("prop1");
cReqCtx.setProperty("prop1", "value1");
cReqCtx.setProperty("prop2", "value2");
}
}
public class ReqFilter_3 implements ContainerRequestFilter {
@Override
public void filter(ContainerRequestContext cReqCtx) throws IOException {
String val1 = (String) cReqCtx.getProperty("prop1");
String val2 = (String) cReqCtx.getProperty("prop2");
Collection<String> customProperties = cReqCtx.getPropertyNames();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment