2 * Copyright (c) 2016 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
9 package org.opendaylight.mdsal.singleton.dom.impl;
11 import com.google.common.base.Preconditions;
12 import com.google.common.util.concurrent.ListenableFuture;
13 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
14 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
15 import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier;
18 * Package protected help class represent a Delegator for {@link ClusterSingletonService}
19 * instance and {@link ClusterSingletonServiceRegistration} implementation.
20 * Close registration means remove {@link ClusterSingletonService} instance from internal
21 * ClusterSingletonServiceGroup list reference.
24 * Close {@link ClusterSingletonServiceRegistration} is prepared for a possible restart
25 * service or application in osgi container. Any another services from group can not be
28 class ClusterSingletonServiceRegistrationDelegator
29 implements ClusterSingletonServiceRegistration, ClusterSingletonService {
31 private final ClusterSingletonService service;
32 private final ClusterSingletonServiceGroup<?, ?, ?> group;
34 ClusterSingletonServiceRegistrationDelegator(final ClusterSingletonService service,
35 final ClusterSingletonServiceGroup<?, ?, ?> group) {
36 this.service = Preconditions.checkNotNull(service);
37 this.group = Preconditions.checkNotNull(group);
41 public void close() throws Exception {
42 group.unregisterService(this);
46 public void instantiateServiceInstance() {
47 service.instantiateServiceInstance();
51 public ListenableFuture<Void> closeServiceInstance() {
52 return service.closeServiceInstance();
56 public ServiceGroupIdentifier getIdentifier() {
57 return service.getIdentifier();
60 public String getServiceGroupIdentifier() {
61 return service.getIdentifier().getValue();