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.nb.rfc8040.services.wrapper;
10 import javax.ws.rs.Path;
11 import javax.ws.rs.core.Response;
12 import javax.ws.rs.core.UriInfo;
13 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
14 import org.opendaylight.mdsal.dom.api.DOMYangTextSourceProvider;
15 import org.opendaylight.restconf.common.context.NormalizedNodeContext;
16 import org.opendaylight.restconf.common.patch.PatchContext;
17 import org.opendaylight.restconf.common.patch.PatchStatusContext;
18 import org.opendaylight.restconf.common.schema.SchemaExportContext;
19 import org.opendaylight.restconf.nb.rfc8040.handlers.DOMDataBrokerHandler;
20 import org.opendaylight.restconf.nb.rfc8040.handlers.DOMMountPointServiceHandler;
21 import org.opendaylight.restconf.nb.rfc8040.handlers.NotificationServiceHandler;
22 import org.opendaylight.restconf.nb.rfc8040.handlers.RpcServiceHandler;
23 import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
24 import org.opendaylight.restconf.nb.rfc8040.handlers.TransactionChainHandler;
25 import org.opendaylight.restconf.nb.rfc8040.rests.services.api.RestconfDataService;
26 import org.opendaylight.restconf.nb.rfc8040.rests.services.api.RestconfInvokeOperationsService;
27 import org.opendaylight.restconf.nb.rfc8040.rests.services.api.RestconfStreamsSubscriptionService;
28 import org.opendaylight.restconf.nb.rfc8040.rests.services.api.TransactionServicesWrapper;
29 import org.opendaylight.restconf.nb.rfc8040.rests.services.impl.RestconfDataServiceImpl;
30 import org.opendaylight.restconf.nb.rfc8040.rests.services.impl.RestconfInvokeOperationsServiceImpl;
31 import org.opendaylight.restconf.nb.rfc8040.rests.services.impl.RestconfStreamsSubscriptionServiceImpl;
32 import org.opendaylight.restconf.nb.rfc8040.services.simple.api.BaseServicesWrapper;
33 import org.opendaylight.restconf.nb.rfc8040.services.simple.api.RestconfOperationsService;
34 import org.opendaylight.restconf.nb.rfc8040.services.simple.api.RestconfSchemaService;
35 import org.opendaylight.restconf.nb.rfc8040.services.simple.api.RestconfService;
36 import org.opendaylight.restconf.nb.rfc8040.services.simple.impl.RestconfImpl;
37 import org.opendaylight.restconf.nb.rfc8040.services.simple.impl.RestconfOperationsServiceImpl;
38 import org.opendaylight.restconf.nb.rfc8040.services.simple.impl.RestconfSchemaServiceImpl;
41 * Wrapper for services.
43 * <li>{@link BaseServicesWrapper}
44 * <li>{@link TransactionServicesWrapper}
49 public final class ServicesWrapperImpl implements BaseServicesWrapper, TransactionServicesWrapper, ServiceWrapper {
51 private RestconfDataService delegRestconfDataService;
52 private RestconfInvokeOperationsService delegRestconfInvokeOpsService;
53 private RestconfStreamsSubscriptionService delegRestconfSubscrService;
54 private RestconfOperationsService delegRestOpsService;
55 private RestconfSchemaService delegRestSchService;
56 private RestconfService delegRestService;
58 private ServicesWrapperImpl() {
61 private static class InstanceHolder {
62 public static final ServicesWrapperImpl INSTANCE = new ServicesWrapperImpl();
65 public static ServicesWrapperImpl getInstance() {
66 return InstanceHolder.INSTANCE;
70 public NormalizedNodeContext getOperations(final UriInfo uriInfo) {
71 return this.delegRestOpsService.getOperations(uriInfo);
75 public NormalizedNodeContext getOperations(final String identifier, final UriInfo uriInfo) {
76 return this.delegRestOpsService.getOperations(identifier, uriInfo);
80 public SchemaExportContext getSchema(final String mountAndModuleId) {
81 return this.delegRestSchService.getSchema(mountAndModuleId);
85 public Response readData(final UriInfo uriInfo) {
86 return this.delegRestconfDataService.readData(uriInfo);
90 public Response readData(final String identifier, final UriInfo uriInfo) {
91 return this.delegRestconfDataService.readData(identifier, uriInfo);
95 public Response putData(final String identifier, final NormalizedNodeContext payload, final UriInfo uriInfo) {
96 return this.delegRestconfDataService.putData(identifier, payload, uriInfo);
100 public Response postData(final String identifier, final NormalizedNodeContext payload, final UriInfo uriInfo) {
101 return this.delegRestconfDataService.postData(identifier, payload, uriInfo);
105 public Response postData(final NormalizedNodeContext payload, final UriInfo uriInfo) {
106 return this.delegRestconfDataService.postData(payload, uriInfo);
110 public Response deleteData(final String identifier) {
111 return this.delegRestconfDataService.deleteData(identifier);
115 public PatchStatusContext patchData(final String identifier, final PatchContext context, final UriInfo uriInfo) {
116 return this.delegRestconfDataService.patchData(identifier, context, uriInfo);
120 public PatchStatusContext patchData(final PatchContext context, final UriInfo uriInfo) {
121 return this.delegRestconfDataService.patchData(context, uriInfo);
125 public NormalizedNodeContext invokeRpc(final String identifier, final NormalizedNodeContext payload,
126 final UriInfo uriInfo) {
127 return this.delegRestconfInvokeOpsService.invokeRpc(identifier, payload, uriInfo);
131 public NormalizedNodeContext subscribeToStream(final String identifier, final UriInfo uriInfo) {
132 return this.delegRestconfSubscrService.subscribeToStream(identifier, uriInfo);
136 public NormalizedNodeContext getLibraryVersion() {
137 return this.delegRestService.getLibraryVersion();
141 public void setHandlers(final SchemaContextHandler schemaCtxHandler,
142 final DOMMountPointServiceHandler domMountPointServiceHandler,
143 final TransactionChainHandler transactionChainHandler, final DOMDataBrokerHandler domDataBrokerHandler,
144 final RpcServiceHandler rpcServiceHandler, final NotificationServiceHandler notificationServiceHandler,
145 final DOMSchemaService domSchemaService) {
146 this.delegRestOpsService = new RestconfOperationsServiceImpl(schemaCtxHandler, domMountPointServiceHandler);
147 final DOMYangTextSourceProvider yangTextSourceProvider =
148 (DOMYangTextSourceProvider) domSchemaService.getSupportedExtensions()
149 .get(DOMYangTextSourceProvider.class);
150 this.delegRestSchService = new RestconfSchemaServiceImpl(schemaCtxHandler, domMountPointServiceHandler,
151 yangTextSourceProvider);
152 this.delegRestconfSubscrService = new RestconfStreamsSubscriptionServiceImpl(domDataBrokerHandler,
153 notificationServiceHandler, schemaCtxHandler, transactionChainHandler);
154 this.delegRestconfDataService =
155 new RestconfDataServiceImpl(schemaCtxHandler, transactionChainHandler, domMountPointServiceHandler,
156 this.delegRestconfSubscrService);
157 this.delegRestconfInvokeOpsService =
158 new RestconfInvokeOperationsServiceImpl(rpcServiceHandler, schemaCtxHandler);
159 this.delegRestService = new RestconfImpl(schemaCtxHandler);