Bug 1764 - moved Session related interfaces to openflowplugin-api
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / openflowplugin / openflow / md / queue / MessageSourcePollRegistration.java
1 /**
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  * 
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
7  */
8 package org.opendaylight.openflowplugin.openflow.md.queue;
9
10
11 import org.opendaylight.openflowplugin.api.openflow.md.queue.MessageSourcePollRegistrator;
12
13 /**
14  * closable registration for {@link org.opendaylight.openflowplugin.api.openflow.md.queue.MessageSourcePollRegistrator}
15  * @param <IN> queue input message type
16  */
17 public class MessageSourcePollRegistration<IN> implements AutoCloseable {
18     
19     private MessageSourcePollRegistrator<IN> messageSourceRegistry;
20     private IN messageSource;
21     
22     /**
23      * @param messageSourceRegistry
24      * @param messageSource 
25      */
26     public MessageSourcePollRegistration(MessageSourcePollRegistrator<IN> messageSourceRegistry,
27             IN messageSource) {
28         this.messageSourceRegistry = messageSourceRegistry;
29         this.messageSource = messageSource;
30     }
31
32     @Override
33     public void close() throws Exception {
34         messageSourceRegistry.unregisterMessageSource(messageSource);
35     }
36 }