String address = AddressProvider.provideAddress(event);
if (address != null) {
return address;
}
ProtocolMetaData pmd = protocolMetaDataInstance.get();
if (pmd == null) {
// PMD is only available per-method level testing
return null;
}
address = AddressProvider.extractAddress(event, pmd);
if (address != null) {
return address;
}
HTTPContext httpContext = pmd.getContext(HTTPContext.class);
if (httpContext != null) {
return httpContext.getHost();
}
RMIContext rmiContext = pmd.getContext(RMIContext.class);
if (rmiContext != null) {
return rmiContext.getIp();
}
JMXContext jmxContext = pmd.getContext(JMXContext.class);
if (jmxContext != null) {
try {
Field hostField = JMXContext.class.getDeclaredField("host");
hostField.setAccessible(true);
return (String) hostField.get(jmxContext);