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
package com.abhirockzz.wordpress.npesaviors; | |
import java.util.Map; | |
import java.util.Objects; | |
public class UsingObjects { | |
String getValSafe(Map<String, String> aMap, String key) { | |
Map<String, String> safeMap = Objects.requireNonNull(aMap, | |
"Map is null"); |
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
@Path("{k}={v}") | |
@GET | |
public void test(@PathParam("k") String key, @PathParam("v") String val){ | |
System.out.println("Key == "+ key); | |
System.out.println("Val == "+ val); | |
} |
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 MethodInterceptor{ | |
@AroundInvoke | |
public Object interceptorMethod(InvocationContext ictx) throws Exception{ | |
//logic goes here | |
} | |
} | |
@Stateless | |
public class AnEJB{ | |
@Interceptors(MethodInterceptor.class) |
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 ConstructorInterceptor{ | |
@AroundConstruct | |
public Object interceptorMethod(InvocationContext ictx) throws Exception{ | |
//logic goes here | |
} | |
} | |
public class APOJO{ | |
@Interceptors(ConstructorInterceptor.class) | |
public APOJO(){ |
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 PostConstructInterceptor{ | |
@PostConstruct | |
public void interceptorMethod(InvocationContext ictx) throws Exception{ | |
//logic goes here | |
} | |
} | |
@Interceptors(PostConstructInterceptor.class) | |
public class APOJO{ | |
@PostConstruct |
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
@InterceptorBinding | |
@Target({TYPE, METHOD, CONSTRUCTOR}) | |
@Retention(RUNTIME) | |
public @interface @Auditable { | |
} | |
@Auditable | |
@Interceptor | |
public class AuditInterceptor { |
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
@Provider | |
public class LoggingFilter implements ContainerRequestFilter{ | |
public void filter(ContainerRequestContext requestContext){ | |
//logic here - logging etc | |
} | |
} |
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
@Path("info") | |
@GET | |
@Produces("application/json") | |
public Response getTweeterInfo(@QueryParam("tweeter") String tweeterId){ | |
//fetch details for abhi_tweeter | |
} | |
@Path("info/{tweeter}") | |
@GET | |
@Produces("application/json") |
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 ClientRequestBean{ | |
@FormParam("tweeter_id") | |
private String id; | |
@FormParam("tweeter_email") | |
private String email; | |
@HeaderParam("referrer") | |
private String referrer; | |