2 * Copyright (c) 2013 Cisco Systems, Inc. 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
8 package org.opendaylight.protocol.bgp.parser.spi;
10 import static com.google.common.base.Preconditions.checkState;
11 import static java.util.Objects.requireNonNull;
13 import java.util.List;
14 import javax.annotation.concurrent.GuardedBy;
15 import org.opendaylight.yangtools.concepts.Registration;
17 public abstract class AbstractBGPExtensionProviderActivator implements AutoCloseable, BGPExtensionProviderActivator {
19 private List<? extends Registration> registrations;
22 protected abstract List<? extends Registration> startImpl(BGPExtensionProviderContext context);
25 public final synchronized void start(final BGPExtensionProviderContext context) {
26 checkState(this.registrations == null);
27 this.registrations = requireNonNull(startImpl(context));
31 public final synchronized void stop() {
32 if (this.registrations == null) {
36 this.registrations.forEach(Registration::close);
37 this.registrations = null;
41 public final void close() {