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 javax.annotation.concurrent.GuardedBy;
15 import org.opendaylight.protocol.pcep.spi.PCEPExtensionProviderActivator;
16 import org.opendaylight.protocol.pcep.spi.PCEPExtensionProviderContext;
17 import org.opendaylight.yangtools.concepts.Registration;
19 public abstract class AbstractPCEPExtensionProviderActivator implements AutoCloseable, PCEPExtensionProviderActivator {
21 private List<? extends Registration> registrations;
24 protected abstract List<? extends Registration> startImpl(PCEPExtensionProviderContext context);
27 public final synchronized void start(final PCEPExtensionProviderContext context) {
28 checkState(this.registrations == null);
30 this.registrations = requireNonNull(startImpl(context));
34 public final synchronized void stop() {
35 if (this.registrations == null) {
39 this.registrations.forEach(Registration::close);
40 this.registrations = null;
44 public final void close() {