Reputation: 31
is there any mechanism to use a intercepting behavior in MFP 8 server side components for all requests where we can add some business logic check , or like a validator at first level for an adapter call.
So based on the comments i created a jaxrs interceptor example which works fine in a normal java ee context but not in the mfp . below example Example Interceptor
@Interceptor
public class LoggerInterceptor {
@AroundInvoke
public Object loggerMethod(InvocationContext context) throws Exception{
String className = context.getMethod().getDeclaringClass().getName();
String methodName = context.getMethod().getName();
System.out.println(String.format("[Logger]ENTRY POINT: %s.%s", className, methodName));
return context.proceed();
} }
Also the mapping on the adapter resource
@GET
@Path("/getDetails")
@OAuthSecurity(enabled = false)
@Interceptors(LoggerInterceptor.class)
public JSONObject getDetails(@Context HttpServletRequest request, @Context HttpServletResponse response)
Upvotes: 0
Views: 195
Reputation: 700
ofcourse, as with all JAX RS standard interceptors, you can also write post-adapter validation...(i.e: modify the response)
Upvotes: 1
Reputation: 181
MFP8 has full support for JAX-RS 2.0 features, therefore you can use JAX-RS filters and interceptors (such as ContainerRequestFilter for example) in an adapter. This can be used to implement validation logic before the actual adapter code is executed.
Note however that that since adapters are individually sandboxed there is no way to implement such logic for many adapters without adding it to every adapter.
Upvotes: 1