Remove mdsal-singleton-dom-api
[mdsal.git] / singleton-service / mdsal-singleton-dom-impl / src / main / java / org / opendaylight / mdsal / singleton / dom / impl / DOMClusterSingletonServiceProviderImpl.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.mdsal.singleton.dom.impl;
10
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;
19
20 /**
21  * Binding version of {@link AbstractClusterSingletonServiceProviderImpl}
22  */
23 public final class DOMClusterSingletonServiceProviderImpl extends
24         AbstractClusterSingletonServiceProviderImpl<YangInstanceIdentifier, DOMEntity,
25                                                     DOMEntityOwnershipChange,
26                                                     DOMEntityOwnershipListener,
27                                                     DOMEntityOwnershipService,
28                                                     DOMEntityOwnershipListenerRegistration>
29         implements DOMEntityOwnershipListener {
30
31     /**
32      * Initialization all needed class internal property for {@link DOMClusterSingletonServiceProviderImpl}
33      *
34      * @param entityOwnershipService - we need only {@link GenericEntityOwnershipService}
35      */
36     public DOMClusterSingletonServiceProviderImpl(final DOMEntityOwnershipService entityOwnershipService) {
37         super(entityOwnershipService);
38     }
39
40     @Override
41     protected final DOMEntity createEntity(final String type, final String ident) {
42         return new DOMEntity(type, ident);
43     }
44
45     @Override
46     protected final DOMEntityOwnershipListenerRegistration registerListener(final String type,
47             final DOMEntityOwnershipService eos) {
48         return eos.registerListener(type, this);
49     }
50
51     @Override
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();
56     }
57 }