Merge "Do not override jsr305 version"
[controller.git] / opendaylight / md-sal / messagebus-impl / src / main / java / org / opendaylight / controller / mdsal / Providers.java
1 /**
2  * Copyright (c) 2014 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
9 package org.opendaylight.controller.mdsal;
10
11 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
12 import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
13 import org.opendaylight.controller.sal.core.api.AbstractProvider;
14 import org.opendaylight.controller.sal.core.api.Broker;
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
17
18 public class Providers {
19     private static final Logger LOGGER = LoggerFactory.getLogger(Providers.class);
20
21     public static class BindingAware implements BindingAwareProvider, AutoCloseable {
22         private final InitializationContext initializationContext;
23
24         public BindingAware(InitializationContext ic) {
25             this.initializationContext = ic;
26         }
27
28         @Override
29         public void onSessionInitiated(BindingAwareBroker.ProviderContext session) {
30             initializationContext.set(session);
31
32             LOGGER.info("BindingAwareBroker.ProviderContext initialized");
33         }
34
35         @Override
36         public void close() throws Exception {}
37     }
38
39     public static class BindingIndependent extends AbstractProvider implements AutoCloseable {
40         private final InitializationContext initializationContext;
41
42         public BindingIndependent(InitializationContext ic) {
43             this.initializationContext = ic;
44         }
45
46         @Override
47         public void onSessionInitiated(Broker.ProviderSession session) {
48             initializationContext.set(session);
49
50             LOGGER.info("Broker.ProviderSession initialized");
51         }
52
53         @Override
54         public void close() throws Exception {}
55     }
56
57 }