Endpoint ep = ex.getEndpoint();
BundleContext context = b
.getExtension(BundleContext.class);
EventFeature eventFeature = null;
if (context != null) {
// OSGi
ServiceReference sref = context
.getServiceReference(EventFeature.class
.getName());
eventFeature = (EventFeature) context
.getService(sref);
} else {
// non-OSGi
if (springContext == null) {
throw springContextException;
}
eventFeature = (EventFeature) springContext.getBean("eventFeature");
}
if (MessageUtils.isRequestor(message)) {
if (MessageUtils.isOutbound(message)) { // REQ_OUT
if ((appliesToType == AppliesToType.consumer || appliesToType == AppliesToType.always)) {
Client cli = ex.get(Client.class);
if (!cli.getOutInterceptors().contains(
WireTapOut.class)) {
eventFeature.initialize(cli, b);
List<Interceptor<? extends Message>> outInterceptors = cli
.getOutInterceptors();
message.getInterceptorChain().add(
outInterceptors);
outInterceptors.getClass();
}
}
} else { // RESP_IN
if ((appliesToType == AppliesToType.consumer || appliesToType == AppliesToType.always)) {
Client cli = ex.get(Client.class);
eventFeature.initialize(cli, b);
}
}
} else {
ServerRegistry registry = b
.getExtension(ServerRegistry.class);
List<Server> servers = registry.getServers();
if (MessageUtils.isOutbound(message)) { // RESP_OUT
if ((appliesToType == AppliesToType.provider || appliesToType == AppliesToType.always)) {
for (Server sr : servers) {
EndpointInfo ei = sr.getEndpoint()
.getEndpointInfo();
if (null != ei
&& ei.getAddress().equals(
ep.getEndpointInfo()
.getAddress())) {
eventFeature.initialize(sr, b);
}
}
}
} else { // REQ_IN
if ((appliesToType == AppliesToType.provider || appliesToType == AppliesToType.always)) {
for (Server sr : servers) {
EndpointInfo ei = sr.getEndpoint()
.getEndpointInfo();
if (null != ei
&& ei.getAddress().equals(
ep.getEndpointInfo()
.getAddress())
&& (!sr.getEndpoint()
.getInInterceptors()
.contains(
WireTapIn.class))) {
eventFeature.initialize(sr, b);
List<Interceptor<? extends Message>> inInterceptors = sr
.getEndpoint()
.getInInterceptors();
message.getInterceptorChain().add(
inInterceptors);