我写了以下EJB:
@Singleton
@LocalBean
@Startup
public class Starter {
private static final Logger logger = Logger.getLogger("lab");
@PostConstruct
public void init() throws Exception {
for (final Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements(); ) {
final NetworkInterface iface = en.nextElement();
if (iface.isUp()) {
logger.info(iface);
}
}
}
}
在部署此日志时,例如:
name:lo (Software Loopback Interface 1)
name:net0 (WAN Miniport (SSTP))
name:net1 (WAN Miniport (L2TP))
name:net2 (WAN Miniport (PPTP))
name:ppp0 (WAN Miniport (PPPOE))
name:eth0 (WAN Miniport (IPv6))
name:eth1 (WAN Miniport (Network Monitor))
name:eth2 (WAN Miniport (IP))
name:net5 (Intel(R) Wireless WiFi Link 4965AGN)
name:eth7 (Intel(R) Wireless WiFi Link 4965AGN - VirtualBox Bridged Networking Driver Miniport)
name:eth8 (VirtualBox Host-Only Ethernet Adapter)
name:net20 (Intel(R) Wireless WiFi Link 4965AGN-Netmon Lightweight Filter Driver-0000)
name:eth10 (VirtualBox Host-Only Ethernet Adapter-Netmon Lightweight Filter Driver-0000)
name:eth11 (VirtualBox Host-Only Ethernet Adapter-QoS Packet Scheduler-0000)
name:eth12 (VirtualBox Host-Only Ethernet Adapter-WFP LightWeight Filter-0000)
name:eth13 (WAN Miniport (IPv6)-QoS Packet Scheduler-0000)
name:eth14 (WAN Miniport (IP)-QoS Packet Scheduler-0000)
name:eth15 (WAN Miniport (Network Monitor)-Netmon Lightweight Filter Driver-0000)
name:eth16 (WAN Miniport (Network Monitor)-QoS Packet Scheduler-0000)
name:net21 (Intel(R) Wireless WiFi Link 4965AGN-Native WiFi Filter Driver-0000)
name:eth20 (Intel(R) Wireless WiFi Link 4965AGN - VirtualBox Bridged Networking Driver Miniport-Netmon Lightweight Filter Driver-0000)
name:eth21 (Intel(R) Wireless WiFi Link 4965AGN - VirtualBox Bridged Networking Driver Miniport-QoS Packet Scheduler-0000)
name:eth22 (Intel(R) Wireless WiFi Link 4965AGN - VirtualBox Bridged Networking Driver Miniport-WFP LightWeight Filter-0000)
这是无效的。在 J2SE 运行时运行的同一循环的输出如下所示:
name:lo (Software Loopback Interface 1)
name:net5 (Intel(R) Wireless WiFi Link 4965AGN)
name:eth8 (VirtualBox Host-Only Ethernet Adapter)
这是应用程序服务器问题吗?我正在使用 JBoss EAP 6.1.0 GA(基于 AS 7 构建)。如何在不打开每个连接的情况下获得有效的 NetworkInterfaces 列表?除此之外,我想知道哪一个支持多播,但总是true
如此。
回购
我已经在 github 上使用 Idea 的项目创建了 repo,为jboss和纯jdk 的运行编译了 ear和日志。它还包含使用的配置文件和动态加载的库列表。