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.pcep.spi.pojo;
10 import static com.google.common.base.Preconditions.checkState;
11 import static java.util.Objects.requireNonNull;
13 import java.util.List;
14 import org.checkerframework.checker.lock.qual.GuardedBy;
15 import org.checkerframework.checker.lock.qual.Holding;
16 import org.opendaylight.protocol.pcep.spi.PCEPExtensionProviderActivator;
17 import org.opendaylight.protocol.pcep.spi.PCEPExtensionProviderContext;
18 import org.opendaylight.yangtools.concepts.Registration;
20 public abstract class AbstractPCEPExtensionProviderActivator implements AutoCloseable, PCEPExtensionProviderActivator {
22 private List<? extends Registration> registrations;
25 protected abstract List<? extends Registration> startImpl(PCEPExtensionProviderContext context);
28 public final synchronized void start(final PCEPExtensionProviderContext context) {
29 checkState(this.registrations == null);
31 this.registrations = requireNonNull(startImpl(context));
35 public final synchronized void stop() {
36 if (this.registrations == null) {
40 this.registrations.forEach(Registration::close);
41 this.registrations = null;
45 public final void close() {