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.handlers.DOMDataBrokerHandler;
18 import org.opendaylight.restconf.handlers.DOMMountPointServiceHandler;
19 import org.opendaylight.restconf.handlers.NotificationServiceHandler;
20 import org.opendaylight.restconf.handlers.RpcServiceHandler;
21 import org.opendaylight.restconf.handlers.SchemaContextHandler;
22 import org.opendaylight.restconf.handlers.TransactionChainHandler;
23 import org.opendaylight.restconf.rest.services.api.BaseServicesWrapper;
24 import org.opendaylight.restconf.rest.services.api.RestconfModulesService;
25 import org.opendaylight.restconf.rest.services.api.RestconfOperationsService;
26 import org.opendaylight.restconf.rest.services.api.RestconfSchemaService;
27 import org.opendaylight.restconf.rest.services.api.RestconfStreamsService;
28 import org.opendaylight.restconf.rest.services.impl.RestconfModulesServiceImpl;
29 import org.opendaylight.restconf.rest.services.impl.RestconfOperationsServiceImpl;
30 import org.opendaylight.restconf.rest.services.impl.RestconfSchemaServiceImpl;
31 import org.opendaylight.restconf.rest.services.impl.RestconfStreamsServiceImpl;
32 import org.opendaylight.restconf.restful.services.api.RestconfDataService;
33 import org.opendaylight.restconf.restful.services.api.RestconfInvokeOperationsService;
34 import org.opendaylight.restconf.restful.services.api.RestconfStreamsSubscriptionService;
35 import org.opendaylight.restconf.restful.services.api.TransactionServicesWrapper;
36 import org.opendaylight.restconf.restful.services.impl.RestconfDataServiceImpl;
37 import org.opendaylight.restconf.restful.services.impl.RestconfInvokeOperationsServiceImpl;
38 import org.opendaylight.restconf.restful.services.impl.RestconfStreamsSubscriptionServiceImpl;
41 * Wrapper for services:
43 * <li>{@link BaseServicesWrapper}
44 * <li>{@link TransactionServicesWrapper}
49 public class ServicesWrapperImpl implements BaseServicesWrapper, TransactionServicesWrapper {
51 private RestconfDataService delegRestconfDataService;
52 private RestconfInvokeOperationsService delegRestconfInvokeOpsService;
53 private RestconfStreamsSubscriptionService delegRestconfSubscrService;
54 private RestconfModulesService delegRestModService;
55 private RestconfOperationsService delegRestOpsService;
56 private RestconfStreamsService delegRestStrsService;
57 private RestconfSchemaService delegRestSchService;
59 private ServicesWrapperImpl() {
62 private static class InstanceHolder {
63 public static final ServicesWrapperImpl INSTANCE = new ServicesWrapperImpl();
66 public static ServicesWrapperImpl getInstance() {
67 return InstanceHolder.INSTANCE;
71 public NormalizedNodeContext getModules(final UriInfo uriInfo) {
72 return this.delegRestModService.getModules(uriInfo);
76 public NormalizedNodeContext getModules(final String identifier, final UriInfo uriInfo) {
77 return this.delegRestModService.getModules(identifier, uriInfo);
81 public NormalizedNodeContext getModule(final String identifier, final UriInfo uriInfo) {
82 return this.delegRestModService.getModule(identifier, uriInfo);
86 public NormalizedNodeContext getOperations(final UriInfo uriInfo) {
87 return this.delegRestOpsService.getOperations(uriInfo);
91 public NormalizedNodeContext getOperations(final String identifier, final UriInfo uriInfo) {
92 return this.delegRestOpsService.getOperations(identifier, uriInfo);
96 public NormalizedNodeContext getAvailableStreams(final UriInfo uriInfo) {
97 return this.delegRestStrsService.getAvailableStreams(uriInfo);
101 public SchemaExportContext getSchema(final String mountAndModuleId) {
102 return this.delegRestSchService.getSchema(mountAndModuleId);
106 public Response readData(final UriInfo uriInfo) {
107 return this.delegRestconfDataService.readData(uriInfo);
111 public Response readData(final String identifier, final UriInfo uriInfo) {
112 return this.delegRestconfDataService.readData(identifier, uriInfo);
116 public Response putData(final String identifier, final NormalizedNodeContext payload) {
117 return this.delegRestconfDataService.putData(identifier, payload);
121 public Response postData(final String identifier, final NormalizedNodeContext payload, final UriInfo uriInfo) {
122 return this.delegRestconfDataService.postData(identifier, payload, uriInfo);
126 public Response postData(final NormalizedNodeContext payload, final UriInfo uriInfo) {
127 return this.delegRestconfDataService.postData(payload, uriInfo);
131 public Response deleteData(final String identifier) {
132 return this.delegRestconfDataService.deleteData(identifier);
136 public PATCHStatusContext patchData(final String identifier, final PATCHContext context, final UriInfo uriInfo) {
137 return this.delegRestconfDataService.patchData(identifier, context, uriInfo);
141 public PATCHStatusContext patchData(final PATCHContext context, final UriInfo uriInfo) {
142 return this.delegRestconfDataService.patchData(context, uriInfo);
146 public NormalizedNodeContext invokeRpc(final String identifier, final NormalizedNodeContext payload,
147 final UriInfo uriInfo) {
148 return this.delegRestconfInvokeOpsService.invokeRpc(identifier, payload, uriInfo);
152 public NormalizedNodeContext subscribeToStream(final String identifier, final UriInfo uriInfo) {
153 return this.delegRestconfSubscrService.subscribeToStream(identifier, uriInfo);
156 public void setHandlers(final SchemaContextHandler schemaCtxHandler,
157 final DOMMountPointServiceHandler domMountPointServiceHandler,
158 final TransactionChainHandler transactionChainHandler,
159 final DOMDataBrokerHandler domDataBrokerHandler,
160 final RpcServiceHandler rpcServiceHandler, final NotificationServiceHandler notificationServiceHandler) {
161 this.delegRestModService = new RestconfModulesServiceImpl(schemaCtxHandler, domMountPointServiceHandler);
162 this.delegRestOpsService = new RestconfOperationsServiceImpl(schemaCtxHandler, domMountPointServiceHandler);
163 this.delegRestSchService = new RestconfSchemaServiceImpl(schemaCtxHandler, domMountPointServiceHandler);
164 this.delegRestStrsService = new RestconfStreamsServiceImpl(schemaCtxHandler);
165 this.delegRestconfDataService = new RestconfDataServiceImpl(schemaCtxHandler, transactionChainHandler,
166 domMountPointServiceHandler);
167 this.delegRestconfInvokeOpsService = new RestconfInvokeOperationsServiceImpl(rpcServiceHandler,
169 this.delegRestconfSubscrService =
170 new RestconfStreamsSubscriptionServiceImpl(domDataBrokerHandler, notificationServiceHandler,