2 * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.vpnservice.natservice.internal;
11 import java.util.concurrent.BlockingQueue;
12 import org.slf4j.Logger;
13 import org.slf4j.LoggerFactory;
15 public class EventDispatcher implements Runnable {
16 private BlockingQueue<NAPTEntryEvent> eventQueue;
17 private NaptEventHandler naptEventHandler;
18 private static final Logger LOG = LoggerFactory.getLogger(NaptManager.class);
20 EventDispatcher(BlockingQueue<NAPTEntryEvent> eventQueue, NaptEventHandler naptEventHandler){
21 this.eventQueue = eventQueue;
22 this.naptEventHandler = naptEventHandler;
25 public void addNaptEvent(NAPTEntryEvent naptEntryEvent){
26 this.eventQueue.add(naptEntryEvent);
32 NAPTEntryEvent event = eventQueue.take();
33 naptEventHandler.handleEvent(event);
34 } catch (InterruptedException e) {
35 LOG.error("EventDispatcher : Error in handling the event queue : ", e.getMessage());