Fix mdsal-dom-spi dependencies
[mdsal.git] / replicate / mdsal-replicate-netty / src / main / java / org / opendaylight / mdsal / replicate / netty / OSGiBootstrapSupportProvider.java
1 /*
2  * Copyright (c) 2020 PANTHEON.tech, s.r.o. 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.mdsal.replicate.netty;
9
10 import io.netty.bootstrap.Bootstrap;
11 import io.netty.bootstrap.ServerBootstrap;
12 import java.util.Map;
13 import org.eclipse.jdt.annotation.NonNull;
14 import org.osgi.service.component.annotations.Activate;
15 import org.osgi.service.component.annotations.Component;
16 import org.osgi.service.component.annotations.Deactivate;
17
18 @Component(immediate = true, service = BootstrapSupport.class)
19 public class OSGiBootstrapSupportProvider implements BootstrapSupport {
20     private AbstractBootstrapSupport delegate = null;
21
22     @Activate
23     void activate(final Map<String, Object> properties) {
24         delegate = AbstractBootstrapSupport.create();
25     }
26
27     @Deactivate
28     void deactivate() throws InterruptedException {
29         delegate.close();
30         delegate = null;
31     }
32
33     @Override
34     public @NonNull Bootstrap newBootstrap() {
35         return delegate.newBootstrap();
36     }
37
38     @Override
39     public @NonNull ServerBootstrap newServerBootstrap() {
40         return delegate.newServerBootstrap();
41     }
42 }