2 * Copyright (c) 2015 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.controller.config.yang.sal.restconf.service;
11 import com.google.common.base.Optional;
12 import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker;
13 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
14 import org.opendaylight.netconf.sal.restconf.api.JSONRestconfService;
15 import org.opendaylight.yangtools.yang.common.OperationFailedException;
16 import org.osgi.framework.BundleContext;
19 public class JSONRestconfServiceModule
20 extends org.opendaylight.controller.config.yang.sal.restconf.service.AbstractJSONRestconfServiceModule {
22 private BundleContext bundleContext;
24 public JSONRestconfServiceModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
25 org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
26 super(identifier, dependencyResolver);
29 public JSONRestconfServiceModule(
30 org.opendaylight.controller.config.api.ModuleIdentifier identifier,
31 org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
32 org.opendaylight.controller.config.yang.sal.restconf.service.JSONRestconfServiceModule oldModule,
33 java.lang.AutoCloseable oldInstance) {
34 super(identifier, dependencyResolver, oldModule, oldInstance);
38 public java.lang.AutoCloseable createInstance() {
39 final WaitingServiceTracker<JSONRestconfService> tracker =
40 WaitingServiceTracker.create(JSONRestconfService.class, bundleContext);
41 final JSONRestconfService service = tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
43 final class AutoCloseableJSONRestconfService implements JSONRestconfService, AutoCloseable {
50 public void delete(String uriPath) throws OperationFailedException {
51 service.delete(uriPath);
56 public void put(String uriPath, String payload) throws OperationFailedException {
57 service.put(uriPath, payload);
61 public void post(String uriPath, String payload) throws OperationFailedException {
62 service.post(uriPath, payload);
66 public Optional<String> get(String uriPath, LogicalDatastoreType datastoreType)
67 throws OperationFailedException {
68 return service.get(uriPath, datastoreType);
72 public Optional<String> invokeRpc(String uriPath, Optional<String> input) throws OperationFailedException {
73 return service.invokeRpc(uriPath, input);
77 return new AutoCloseableJSONRestconfService();
80 public void setBundleContext(final BundleContext bundleContext) {
81 this.bundleContext = bundleContext;