Created
March 15, 2016 18:48
-
-
Save abhirockzz/bdb0f98fe68c148f97d2 to your computer and use it in GitHub Desktop.
Using custom (user defined) contextual data amongst JAX-RS request filters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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