This week's giveaway is in the Spring forum.
We're giving away four copies of liveProject: Protecting User Data with Spring Security and OAuth2 and have Laurentiu Spilca on-line!
See this thread for details.
Win a copy of liveProject: Protecting User Data with Spring Security and OAuth2 this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

EJB 3 In Action errata - InvocationContext

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 147
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Hey, I'm supposed to be the guide! Wait up! No fair! You have the tiny ad!
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic