2 * Copyright (c) 2013 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.controller.config.yang.store.impl;
10 import static org.junit.Assert.assertNotNull;
12 import java.io.ByteArrayInputStream;
13 import java.io.IOException;
14 import java.io.InputStream;
15 import java.util.ArrayList;
16 import java.util.Collection;
18 import org.apache.commons.io.IOUtils;
19 import org.opendaylight.controller.config.yang.store.api.YangStoreException;
20 import org.opendaylight.controller.config.yang.store.api.YangStoreListenerRegistration;
21 import org.opendaylight.controller.config.yang.store.api.YangStoreService;
22 import org.opendaylight.controller.config.yang.store.api.YangStoreSnapshot;
23 import org.opendaylight.controller.config.yang.store.spi.YangStoreListener;
25 public class HardcodedYangStoreService implements YangStoreService {
27 private final Collection<ByteArrayInputStream> byteArrayInputStreams;
29 public HardcodedYangStoreService(
30 Collection<? extends InputStream> inputStreams)
31 throws YangStoreException, IOException {
32 byteArrayInputStreams = new ArrayList<>();
33 for (InputStream inputStream : inputStreams) {
34 assertNotNull(inputStream);
35 byte[] content = IOUtils.toByteArray(inputStream);
36 ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
38 byteArrayInputStreams.add(byteArrayInputStream);
43 public YangStoreSnapshot getYangStoreSnapshot() throws YangStoreException {
44 for (InputStream inputStream : byteArrayInputStreams) {
47 } catch (IOException e) {
48 throw new RuntimeException(e);
51 return new MbeParser().parseYangFiles(byteArrayInputStreams);
55 public YangStoreListenerRegistration registerListener(YangStoreListener listener){
56 throw new UnsupportedOperationException("Cannot register for changes on this service");