In MyInterceptor
, which interface, Ifclocal
or IfcRemote
, invoked the method doStuff
in MyEjb
? It's possible know through which "channel" your bean was called? I need know which dependency injection invoked the method.
@Local
public interface IfcLocal {
void doStuff(String s);
}
@Remote
public interface IfcRemote {
void doStuff(String s);
}
@Stateless
@Interceptors({ MyInterceptor.class })
public class MyEjb implements IfcLocal, IfcRemote {
@Override
public void doStuff(String s) {
System.out.println(s);
}
}
public class MyManagedBean {
@EJB private ifcLocal ifcLocal;
@EJB private IfcRemote ifcRemote;
public void go() {
ifcLocal.doStuff("xxx");
ifcRemote.doStuff("xxx");
}
}
public class MyInterceptor {
@AroundInvoke
public Object intercept(InvocationContext inv) throws Exception {
// ??? who invoked ???
System.out.prinln(inv.getTarget().getClass()); // print MyEjb
}
}
Inject @Resource private SessionContext sessionContext;
in MyInterceptor
. After: Class<?> interfaceReference = sessionContext.getInvokedBusinessInterface()
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.