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.impl.RestconfOperationsServiceImpl;
21 import org.opendaylight.restconf.base.services.impl.RestconfSchemaServiceImpl;
22 import org.opendaylight.restconf.handlers.DOMDataBrokerHandler;
23 import org.opendaylight.restconf.handlers.DOMMountPointServiceHandler;
24 import org.opendaylight.restconf.handlers.NotificationServiceHandler;
25 import org.opendaylight.restconf.handlers.RpcServiceHandler;
26 import org.opendaylight.restconf.handlers.SchemaContextHandler;
27 import org.opendaylight.restconf.handlers.TransactionChainHandler;
28 import org.opendaylight.restconf.restful.services.api.RestconfDataService;
29 import org.opendaylight.restconf.restful.services.api.RestconfInvokeOperationsService;
30 import org.opendaylight.restconf.restful.services.api.RestconfStreamsSubscriptionService;
31 import org.opendaylight.restconf.restful.services.api.TransactionServicesWrapper;
32 import org.opendaylight.restconf.restful.services.impl.RestconfDataServiceImpl;
33 import org.opendaylight.restconf.restful.services.impl.RestconfInvokeOperationsServiceImpl;
34 import org.opendaylight.restconf.restful.services.impl.RestconfStreamsSubscriptionServiceImpl;
37 * Wrapper for services:
39 * <li>{@link BaseServicesWrapper}
40 * <li>{@link TransactionServicesWrapper}
45 public class ServicesWrapperImpl implements BaseServicesWrapper, TransactionServicesWrapper {
47 private RestconfDataService delegRestconfDataService;
48 private RestconfInvokeOperationsService delegRestconfInvokeOpsService;
49 private RestconfStreamsSubscriptionService delegRestconfSubscrService;
50 private RestconfOperationsService delegRestOpsService;
51 private RestconfSchemaService delegRestSchService;
53 private ServicesWrapperImpl() {
56 private static class InstanceHolder {
57 public static final ServicesWrapperImpl INSTANCE = new ServicesWrapperImpl();
60 public static ServicesWrapperImpl getInstance() {
61 return InstanceHolder.INSTANCE;
65 public NormalizedNodeContext getOperations(final UriInfo uriInfo) {
66 return this.delegRestOpsService.getOperations(uriInfo);
70 public NormalizedNodeContext getOperations(final String identifier, final UriInfo uriInfo) {
71 return this.delegRestOpsService.getOperations(identifier, uriInfo);
75 public SchemaExportContext getSchema(final String mountAndModuleId) {
76 return this.delegRestSchService.getSchema(mountAndModuleId);
80 public Response readData(final UriInfo uriInfo) {
81 return this.delegRestconfDataService.readData(uriInfo);
85 public Response readData(final String identifier, final UriInfo uriInfo) {
86 return this.delegRestconfDataService.readData(identifier, uriInfo);
90 public Response putData(final String identifier, final NormalizedNodeContext payload, final UriInfo uriInfo) {
91 return this.delegRestconfDataService.putData(identifier, payload, uriInfo);
95 public Response postData(final String identifier, final NormalizedNodeContext payload, final UriInfo uriInfo) {
96 return this.delegRestconfDataService.postData(identifier, payload, uriInfo);
100 public Response postData(final NormalizedNodeContext payload, final UriInfo uriInfo) {
101 return this.delegRestconfDataService.postData(payload, uriInfo);
105 public Response deleteData(final String identifier) {
106 return this.delegRestconfDataService.deleteData(identifier);
110 public PATCHStatusContext patchData(final String identifier, final PATCHContext context, final UriInfo uriInfo) {
111 return this.delegRestconfDataService.patchData(identifier, context, uriInfo);
115 public PATCHStatusContext patchData(final PATCHContext context, final UriInfo uriInfo) {
116 return this.delegRestconfDataService.patchData(context, uriInfo);
120 public NormalizedNodeContext invokeRpc(final String identifier, final NormalizedNodeContext payload,
121 final UriInfo uriInfo) {
122 return this.delegRestconfInvokeOpsService.invokeRpc(identifier, payload, uriInfo);
126 public NormalizedNodeContext subscribeToStream(final String identifier, final UriInfo uriInfo) {
127 return this.delegRestconfSubscrService.subscribeToStream(identifier, uriInfo);
130 public void setHandlers(final SchemaContextHandler schemaCtxHandler,
131 final DOMMountPointServiceHandler domMountPointServiceHandler,
132 final TransactionChainHandler transactionChainHandler,
133 final DOMDataBrokerHandler domDataBrokerHandler,
134 final RpcServiceHandler rpcServiceHandler, final NotificationServiceHandler notificationServiceHandler) {
135 this.delegRestOpsService = new RestconfOperationsServiceImpl(schemaCtxHandler, domMountPointServiceHandler);
136 this.delegRestSchService = new RestconfSchemaServiceImpl(schemaCtxHandler, domMountPointServiceHandler);
137 this.delegRestconfDataService = new RestconfDataServiceImpl(schemaCtxHandler, transactionChainHandler,
138 domMountPointServiceHandler);
139 this.delegRestconfInvokeOpsService = new RestconfInvokeOperationsServiceImpl(rpcServiceHandler,
141 this.delegRestconfSubscrService =
142 new RestconfStreamsSubscriptionServiceImpl(domDataBrokerHandler, notificationServiceHandler,
143 schemaCtxHandler, transactionChainHandler);