如何在EJB3拦截器中获取客户机ip地址?
问题描述:
通常,出于审计或安全目的,获取进行远程EJB3调用的客户端的IP地址很有用.在EJB3 Bean的上下文中,此信息不容易获得.这是一个可以在JBoss 4.x中实现这一目标的技巧.
Often it's useful for Auditing or security purposes to get the IP Address of the client making a remote EJB3 Call. This information is not readily available in the Context of an EJB3 Bean. Here's a hack to be able to achieve this in JBoss 4.x.
答
此页面上有答案 https://community.jboss.org/wiki/HowToGetTheClientIpAddressInAnEJB3Interceptor?_sscc=t
基本上,它使用线程名来获取IP地址,因为每个调用都是在其自己的线程中启动的...
Basically it uses the thread name to obtain the ip address as each call is launched in its own thread...