java如何从EJB计时器更改callerPrincipal?
我的EJB计时器总是与UNAUTHENTICATED
用户一起运行。我试图把@RunAs
放进去,但没用。我试图用反射更改值,但没有成功,我需要从中调用一个远程EJB,我需要一个有权限的用户
@Resource
private SessionContext context;
@Schedule(second= "*/5", minute = "*", hour = "*", persistent = false)
public void executa(){
Principal callerPrincipal = context.getCallerPrincipal();
final Field field = getField(callerPrincipal.getClass(), "name");
field.setAccessible(true);
try {
field.set(callerPrincipal,"MYUSER");
} catch (IllegalAccessException e) {
e.printStackTrace();
}
this.iMyRemoteEjb.doWork()
}
共 (0) 个答案