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
8 package org.opendaylight.restconf.common.wrapper.services;
10 import javax.ws.rs.Path;
11 import javax.ws.rs.core.Response;
12 import javax.ws.rs.core.UriInfo;
13 import org.opendaylight.netconf.md.sal.rest.schema.SchemaExportContext;
14 import org.opendaylight.netconf.sal.restconf.impl.NormalizedNodeContext;
15 import org.opendaylight.netconf.sal.restconf.impl.PATCHContext;
16 import org.opendaylight.netconf.sal.restconf.impl.PATCHStatusContext;
17 import org.opendaylight.restconf.base.services.api.BaseServicesWrapper;
18 import org.opendaylight.restconf.base.services.api.RestconfOperationsService;
19 import org.opendaylight.restconf.base.services.api.RestconfSchemaService;
20 import org.opendaylight.restconf.base.services.api.RestconfStreamsService;
21 import org.opendaylight.restconf.base.services.impl.RestconfOperationsServiceImpl;
22 import org.opendaylight.restconf.base.services.impl.RestconfSchemaServiceImpl;
23 import org.opendaylight.restconf.base.services.impl.RestconfStreamsServiceImpl;
24 import org.opendaylight.restconf.handlers.DOMDataBrokerHandler;
25 import org.opendaylight.restconf.handlers.DOMMountPointServiceHandler;
26 import org.opendaylight.restconf.handlers.NotificationServiceHandler;
27 import org.opendaylight.restconf.handlers.RpcServiceHandler;
28 import org.opendaylight.restconf.handlers.SchemaContextHandler;
29 import org.opendaylight.restconf.handlers.TransactionChainHandler;
30 import org.opendaylight.restconf.restful.services.api.RestconfDataService;
31 import org.opendaylight.restconf.restful.services.api.RestconfInvokeOperationsService;
32 import org.opendaylight.restconf.restful.services.api.RestconfStreamsSubscriptionService;
33 import org.opendaylight.restconf.restful.services.api.TransactionServicesWrapper;
34 import org.opendaylight.restconf.restful.services.impl.RestconfDataServiceImpl;
35 import org.opendaylight.restconf.restful.services.impl.RestconfInvokeOperationsServiceImpl;
36 import org.opendaylight.restconf.restful.services.impl.RestconfStreamsSubscriptionServiceImpl;
39 * Wrapper for services:
41 * <li>{@link BaseServicesWrapper}
42 * <li>{@link TransactionServicesWrapper}
47 public class ServicesWrapperImpl implements BaseServicesWrapper, TransactionServicesWrapper {
49 private RestconfDataService delegRestconfDataService;
50 private RestconfInvokeOperationsService delegRestconfInvokeOpsService;
51 private RestconfStreamsSubscriptionService delegRestconfSubscrService;
52 private RestconfOperationsService delegRestOpsService;
53 private RestconfStreamsService delegRestStrsService;
54 private RestconfSchemaService delegRestSchService;
56 private ServicesWrapperImpl() {
59 private static class InstanceHolder {
60 public static final ServicesWrapperImpl INSTANCE = new ServicesWrapperImpl();
63 public static ServicesWrapperImpl getInstance() {
64 return InstanceHolder.INSTANCE;
68 public NormalizedNodeContext getOperations(final UriInfo uriInfo) {
69 return this.delegRestOpsService.getOperations(uriInfo);
73 public NormalizedNodeContext getOperations(final String identifier, final UriInfo uriInfo) {
74 return this.delegRestOpsService.getOperations(identifier, uriInfo);
78 public NormalizedNodeContext getAvailableStreams(final UriInfo uriInfo) {
79 return this.delegRestStrsService.getAvailableStreams(uriInfo);
83 public SchemaExportContext getSchema(final String mountAndModuleId) {
84 return this.delegRestSchService.getSchema(mountAndModuleId);
88 public Response readData(final UriInfo uriInfo) {
89 return this.delegRestconfDataService.readData(uriInfo);
93 public Response readData(final String identifier, final UriInfo uriInfo) {
94 return this.delegRestconfDataService.readData(identifier, uriInfo);
98 public Response putData(final String identifier, final NormalizedNodeContext payload, final UriInfo uriInfo) {
99 return this.delegRestconfDataService.putData(identifier, payload, uriInfo);
103 public Response postData(final String identifier, final NormalizedNodeContext payload, final UriInfo uriInfo) {
104 return this.delegRestconfDataService.postData(identifier, payload, uriInfo);
108 public Response postData(final NormalizedNodeContext payload, final UriInfo uriInfo) {
109 return this.delegRestconfDataService.postData(payload, uriInfo);
113 public Response deleteData(final String identifier) {
114 return this.delegRestconfDataService.deleteData(identifier);
118 public PATCHStatusContext patchData(final String identifier, final PATCHContext context, final UriInfo uriInfo) {
119 return this.delegRestconfDataService.patchData(identifier, context, uriInfo);
123 public PATCHStatusContext patchData(final PATCHContext context, final UriInfo uriInfo) {
124 return this.delegRestconfDataService.patchData(context, uriInfo);
128 public NormalizedNodeContext invokeRpc(final String identifier, final NormalizedNodeContext payload,
129 final UriInfo uriInfo) {
130 return this.delegRestconfInvokeOpsService.invokeRpc(identifier, payload, uriInfo);
134 public NormalizedNodeContext subscribeToStream(final String identifier, final UriInfo uriInfo) {
135 return this.delegRestconfSubscrService.subscribeToStream(identifier, uriInfo);
138 public void setHandlers(final SchemaContextHandler schemaCtxHandler,
139 final DOMMountPointServiceHandler domMountPointServiceHandler,
140 final TransactionChainHandler transactionChainHandler,
141 final DOMDataBrokerHandler domDataBrokerHandler,
142 final RpcServiceHandler rpcServiceHandler, final NotificationServiceHandler notificationServiceHandler) {
143 this.delegRestOpsService = new RestconfOperationsServiceImpl(schemaCtxHandler, domMountPointServiceHandler);
144 this.delegRestSchService = new RestconfSchemaServiceImpl(schemaCtxHandler, domMountPointServiceHandler);
145 this.delegRestStrsService = new RestconfStreamsServiceImpl(schemaCtxHandler);
146 this.delegRestconfDataService = new RestconfDataServiceImpl(schemaCtxHandler, transactionChainHandler,
147 domMountPointServiceHandler);
148 this.delegRestconfInvokeOpsService = new RestconfInvokeOperationsServiceImpl(rpcServiceHandler,
150 this.delegRestconfSubscrService =
151 new RestconfStreamsSubscriptionServiceImpl(domDataBrokerHandler, notificationServiceHandler,