简体   繁体   English

如何在JBoss AS7中获取EJB方法的调用远程客户端的地址

[英]How to get the address of the calling remote client of an EJB method in JBoss AS7

i have a distributed application that consists of one server, the JBoss AS7 on which the frontend and the backend of the application run. 我有一个分布式应用程序,由一个服务器组成,JBoss AS7前端和应用程序的后端运行。 Several clients, running on other machines in a network obtain the JNDI initial context of the JBoss to get certain objects. 在网络中的其他机器上运行的几个客户端获取JBoss的JNDI初始上下文以获取某些对象。 Each client is unique and needs to be identified without doing any configuration on them. 每个客户端都是唯一的,需要在不对其进行任何配置的情况下进行识别。 My approach is to get their address and map the data related to them (pool of stuff, evenly mapped between all connected clients). 我的方法是获取他们的地址并映射与他们相关的数据(东西池,在所有连接的客户端之间均匀映射)。

How can i obtain the IP address of the calling client of an EJB method? 如何获取EJB方法的调用客户端的IP地址?

I already found 'hacks' that describe how to get the information out of the thread name (used for example in JBoss 4.x), but that always returns something like: 我已经发现'hacks'描述了如何从线程名称中获取信息(例如在JBoss 4.x中使用),但总是会返回如下内容:

EJB default - 7 EJB默认 - 7

See How can you get the calling ip address on an ejb call? 请参阅如何在ejb呼叫中获取呼叫IP地址?

If you provide a code snippet or a method call on some context, can you please add the source of it? 如果您在某些上下文中提供代码段或方法调用,是否可以添加它的来源? I was unable to find something by searching for EJB3 , Remoting3 and similar stuff 我无法通过搜索EJB3Remoting3和类似的东西找到一些东西

Just an idea, 只是一个想法,

May be use can expose your ejb through a rest based web service layer. 可以使用可以通过基于休息的Web服务层公开您的ejb。 If you do so it is easy to find remote host name and may also use filter servlet to allow or disallow a request. 如果这样做,很容易找到远程主机名,也可能使用过滤器servlet来允许或禁止请求。

You can use @EJB to inject your bean into rest class assuming you will use JAX-RS. 假设您将使用JAX-RS,您可以使用@EJB将bean注入rest类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM