How it works...

In this scenario, the appropriate advice that will retrieve all the request headers of the incoming request for /login_emps.html is the @Before advice. The aspect class LoginProxyAspect intercepts the incoming request to retrieve the user-agent header in order to prohibit all transactions from running on Internet Explorer. After detecting the type of browser, the browserCheck() advice creates a request attribute, browserNo, for the /login_emps.html to know what browser typed was used.

Another highlight of this recipe is the use of the @Pointcut annotation. @Pointcut is used when creating an independent rule for join points to be applied anywhere within the aspect class. Usually, when the Pointcut expression gets complicated, we use the @Pointcut annotation to simplify and break down the expression to simple terms. For the annotation to run correctly, it must be defined by a void method without any implementation at all, such as the loginPointcut() and classPointcut() of LoginProxyAspect.

The interception process is configured by the join point rules of loginPointcut() and classPointcut(). The former includes all the login() methods in LoginController with any local parameter values and return values, while the latter monitors all the @Controller class transactions. @Pointcut can limit the concerns to controllers just by invoking the @ symbol together with the package of the @Controller annotation interface. In usual cases, the within command tells advices to include all methods inside a package (for example, within(org.packt.aop.transaction.controller)) or sub-packages (for example, within(org.packt.aop.transaction..*)). The interception will not be complete without the @annotation, which limits our concerns to only the request hander defined by @RequestMapping.

This recipe has browserCheck() advice that intercepts the @Controller request handler method, named login, without any restriction on the local parameters and return value.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.128.198.59