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