2 * Copyright (c) 2018 Inocybe Technologies 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.controller.cluster.datastore;
10 import com.google.common.annotations.VisibleForTesting;
11 import org.eclipse.jdt.annotation.NonNull;
12 import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
13 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.distributed.datastore.provider.rev140612.DataStorePropertiesContainer;
15 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
16 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
18 abstract class AbstractDatastoreContextIntrospectorFactory implements DatastoreContextIntrospectorFactory {
20 public final DatastoreContextIntrospector newInstance(final LogicalDatastoreType datastoreType) {
21 return newInstance(DatastoreContext.newBuilder()
22 .logicalStoreType(datastoreType)
23 .tempFileDirectory("./data")
28 final @NonNull DatastoreContextIntrospector newInstance(final DatastoreContext context) {
29 final DataStorePropertiesContainer defaultPropsContainer = (DataStorePropertiesContainer)
30 serializer().fromNormalizedNode(YangInstanceIdentifier.of(DataStorePropertiesContainer.QNAME),
31 ImmutableNodes.containerNode(DataStorePropertiesContainer.QNAME)).getValue();
33 return new DatastoreContextIntrospector(context, defaultPropsContainer);
36 abstract BindingNormalizedNodeSerializer serializer();