Java Reference
In-Depth Information
LISTING 8-10 (continued)
//Do some security checks!
.getName()+ "is accessed!");
String user = context.getContextData.get("user");
if (user == null){
user = (String)context.getParameters()[0];
context.getContextData.put("user", user)'
return context.proceed();
public void onStart(){
public void onShutdown(){
Just like the EJB interceptors, the @Interceptor annotation needs to be used to promote the class
i le to an interceptor. The @Secure annotation binds the interceptor. Finally, the @AroundInvoke
annotation marks the method to be executed during intercepted calls.
The next step is to implement the annotation on an advice, as shown in Listing 8‐11.
LISTING 8‐11: Implementing the @Secure on an advice
package com.devchronicles.interceptor;
import javax.interceptor.Interceptors;
public class SomeBusinessBean {
public void startService(){
//Complex business logic
public void startAnotherService(){
//Complex business logic
Logger.getLogger("AppLog").info("done again...");
Search WWH ::

Custom Search