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
8 package org.opendaylight.mdsal.singleton.dom.impl;
10 import org.opendaylight.mdsal.eos.common.api.GenericEntityOwnershipService;
11 import org.opendaylight.mdsal.eos.dom.api.DOMEntity;
12 import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipChange;
13 import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListener;
14 import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListenerRegistration;
15 import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipService;
16 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
17 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
20 * Binding version of {@link AbstractClusterSingletonServiceProviderImpl}.
22 public final class DOMClusterSingletonServiceProviderImpl extends
23 AbstractClusterSingletonServiceProviderImpl<YangInstanceIdentifier, DOMEntity,
24 DOMEntityOwnershipChange,
25 DOMEntityOwnershipListener,
26 DOMEntityOwnershipService,
27 DOMEntityOwnershipListenerRegistration>
28 implements DOMEntityOwnershipListener {
31 * Initialization all needed class internal property for {@link DOMClusterSingletonServiceProviderImpl}.
33 * @param entityOwnershipService - we need only {@link GenericEntityOwnershipService}
35 public DOMClusterSingletonServiceProviderImpl(final DOMEntityOwnershipService entityOwnershipService) {
36 super(entityOwnershipService);
40 protected DOMEntity createEntity(final String type, final String ident) {
41 return new DOMEntity(type, ident);
45 protected DOMEntityOwnershipListenerRegistration registerListener(final String type,
46 final DOMEntityOwnershipService eos) {
47 return eos.registerListener(type, this);
51 protected String getServiceIdentifierFromEntity(final DOMEntity entity) {
52 final YangInstanceIdentifier yii = entity.getIdentifier();
53 final NodeIdentifierWithPredicates niiwp = (NodeIdentifierWithPredicates) yii.getLastPathArgument();
54 return niiwp.values().iterator().next().toString();