File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes EJB 3 In Action errata - InvocationContext Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "EJB 3 In Action errata - InvocationContext" Watch "EJB 3 In Action errata - InvocationContext" New topic
Author

EJB 3 In Action errata - InvocationContext

Tyronne Fernando
Ranch Hand

Joined: May 11, 2008
Posts: 50
The following code is from EJB 3 In Action page 212.

public class SecurityInterceptor {
@AroundInvoke
public Object checkUserRole(InvocationContext context)
throws Exception {
if (!context.getEJBContext().isCallerInRole("CSR")) {
throw new SecurityException(
"No permissions to cancel bid");
}
return context.proceed();
}
}

@Stateless
public class BidManagerBean implements BidManager {
@Interceptors(actionbazaar.security.SecurityInterceptor.class)
public void cancelBid(Bid bid, Item item) { ... }
.......

Does anyone can tell me where is the getEJBContext() method is coming from? That method is not specified for InvocationContext (http://java.sun.com/javaee/5/docs/api/javax/interceptor/InvocationContext.html). Also I can't find any correction in the errata (http://www.manning.com/panda/excerpt_errata.html).

Thanks in advance.

Cheers,
Tyronne
Yucca Nel
Ranch Hand

Joined: Nov 20, 2008
Posts: 147

Whenever you see context think to yourself a window: EJB Context = a window to the environment surrounding the EJB, ENC = a window to the environment naming etc. In this case we have a window to the invocation of the interceptor which is the method that the is being intercepted. You now have a window to lookup that methods parameters, class that it is a member of etc. You even can set the parameters of that method.


SCJP 6.0, SCJD (400/400), SCBCD for JEE 5, SCWCD 1.4 I do videos for development at
http://www.youtube.com/user/thejartender?feature=mhee
I am probably the only developer ever to have had an orange sized brain tumor in my brain while learning development!!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: EJB 3 In Action errata - InvocationContext
 
Similar Threads
how many interceptor method in a Bean class ?
@RunAs Application
what us mean mappedBy="item" ?
what is mean mappedBy
@RunAS