private void sendEvent(EventEndpoint endpoint, ApplicationEventNFVO event) { EventSender sender = (EventSender) context.getBean(endpoint.getType().toString().toLowerCase() + "EventSender"); log.trace("Sender is: " + sender.getClass().getSimpleName()); try { sender.send(endpoint, event); } catch (IOException e) { e.printStackTrace(); log.error("Error while dispatching event " + event); } }
@Override public void dispatchEvent(EventNFVO event) { log.debug("dispatching event to the world!!!"); log.debug("event is: " + event); Iterable<EventEndpoint> endpoints = eventEndpointRepository.findAll(); for (EventEndpoint endpoint : endpoints) { log.debug("Checking endpoint: " + endpoint); if (endpoint.getEvent().ordinal() == event.getEventNFVO().getAction().ordinal()) { if (endpoint.getVirtualNetworkFunctionId() != null) { if (event.getEventNFVO().getPayload() instanceof VirtualNetworkFunctionRecord) { if (((VirtualNetworkFunctionRecord) event.getEventNFVO().getPayload()) .getId() .equals(endpoint.getVirtualNetworkFunctionId())) { log.debug("dispatching event to: " + endpoint); sendEvent(endpoint, event.getEventNFVO()); } } } else if (endpoint.getNetworkServiceId() != null) { if (event.getEventNFVO().getPayload() instanceof NetworkServiceRecord) { if (((NetworkServiceRecord) event.getEventNFVO().getPayload()) .getId() .equals(endpoint.getNetworkServiceId())) { log.debug("dispatching event to: " + endpoint); sendEvent(endpoint, event.getEventNFVO()); } } } else { log.debug("dispatching event to: " + endpoint); sendEvent(endpoint, event.getEventNFVO()); } } } }