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.DOMActionService;
14 import org.opendaylight.mdsal.dom.api.DOMDataBroker;
15 import org.opendaylight.mdsal.dom.api.DOMMountPointService;
16 import org.opendaylight.mdsal.dom.api.DOMNotificationService;
17 import org.opendaylight.mdsal.dom.api.DOMRpcService;
18 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
19 import org.opendaylight.mdsal.dom.api.DOMYangTextSourceProvider;
20 import org.opendaylight.restconf.common.context.NormalizedNodeContext;
21 import org.opendaylight.restconf.common.patch.PatchContext;
22 import org.opendaylight.restconf.common.patch.PatchStatusContext;
23 import org.opendaylight.restconf.common.schema.SchemaExportContext;
24 import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
25 import org.opendaylight.restconf.nb.rfc8040.handlers.TransactionChainHandler;
26 import org.opendaylight.restconf.nb.rfc8040.rests.services.api.RestconfDataService;
27 import org.opendaylight.restconf.nb.rfc8040.rests.services.api.RestconfInvokeOperationsService;
28 import org.opendaylight.restconf.nb.rfc8040.rests.services.api.RestconfOperationsService;
29 import org.opendaylight.restconf.nb.rfc8040.rests.services.api.RestconfSchemaService;
30 import org.opendaylight.restconf.nb.rfc8040.rests.services.api.RestconfService;
31 import org.opendaylight.restconf.nb.rfc8040.rests.services.api.RestconfStreamsSubscriptionService;
32 import org.opendaylight.restconf.nb.rfc8040.rests.services.api.TransactionServicesWrapper;
33 import org.opendaylight.restconf.nb.rfc8040.rests.services.impl.RestconfDataServiceImpl;
34 import org.opendaylight.restconf.nb.rfc8040.rests.services.impl.RestconfImpl;
35 import org.opendaylight.restconf.nb.rfc8040.rests.services.impl.RestconfInvokeOperationsServiceImpl;
36 import org.opendaylight.restconf.nb.rfc8040.rests.services.impl.RestconfOperationsServiceImpl;
37 import org.opendaylight.restconf.nb.rfc8040.rests.services.impl.RestconfSchemaServiceImpl;
38 import org.opendaylight.restconf.nb.rfc8040.rests.services.impl.RestconfStreamsSubscriptionServiceImpl;
39 import org.opendaylight.restconf.nb.rfc8040.services.simple.api.BaseServicesWrapper;
40 import org.opendaylight.restconf.nb.rfc8040.streams.Configuration;
43 * Wrapper for services.
45 * <li>{@link BaseServicesWrapper}
46 * <li>{@link TransactionServicesWrapper}
50 public final class ServicesWrapper implements BaseServicesWrapper, TransactionServicesWrapper {
52 private final RestconfDataService delegRestconfDataService;
53 private final RestconfInvokeOperationsService delegRestconfInvokeOpsService;
54 private final RestconfStreamsSubscriptionService delegRestconfSubscrService;
55 private final RestconfOperationsService delegRestOpsService;
56 private final RestconfSchemaService delegRestSchService;
57 private final RestconfService delegRestService;
59 private ServicesWrapper(final RestconfDataService delegRestconfDataService,
60 final RestconfInvokeOperationsService delegRestconfInvokeOpsService,
61 final RestconfStreamsSubscriptionService delegRestconfSubscrService,
62 final RestconfOperationsService delegRestOpsService, final RestconfSchemaService delegRestSchService,
63 final RestconfService delegRestService) {
64 this.delegRestconfDataService = delegRestconfDataService;
65 this.delegRestconfInvokeOpsService = delegRestconfInvokeOpsService;
66 this.delegRestconfSubscrService = delegRestconfSubscrService;
67 this.delegRestOpsService = delegRestOpsService;
68 this.delegRestSchService = delegRestSchService;
69 this.delegRestService = delegRestService;
72 public static ServicesWrapper newInstance(final SchemaContextHandler schemaCtxHandler,
73 final DOMMountPointService mountPointService,
74 final TransactionChainHandler transactionChainHandler, final DOMDataBroker dataBroker,
75 final DOMRpcService rpcService, final DOMActionService actionService,
76 final DOMNotificationService notificationService, final DOMSchemaService domSchemaService,
77 final Configuration configuration) {
78 RestconfOperationsService restconfOpsService = new RestconfOperationsServiceImpl(schemaCtxHandler,
80 final DOMYangTextSourceProvider yangTextSourceProvider = domSchemaService.getExtensions()
81 .getInstance(DOMYangTextSourceProvider.class);
82 RestconfSchemaService restconfSchemaService = new RestconfSchemaServiceImpl(schemaCtxHandler, mountPointService,
83 yangTextSourceProvider);
84 RestconfStreamsSubscriptionService restconfSubscrService = new RestconfStreamsSubscriptionServiceImpl(
85 dataBroker, notificationService, schemaCtxHandler, transactionChainHandler, configuration);
86 RestconfDataService restconfDataService = new RestconfDataServiceImpl(schemaCtxHandler, dataBroker,
87 mountPointService, restconfSubscrService, actionService, configuration);
88 RestconfInvokeOperationsService restconfInvokeOpsService = new RestconfInvokeOperationsServiceImpl(rpcService,
90 RestconfService restconfService = new RestconfImpl(schemaCtxHandler);
91 return new ServicesWrapper(restconfDataService, restconfInvokeOpsService, restconfSubscrService,
92 restconfOpsService, restconfSchemaService, restconfService);
96 public NormalizedNodeContext getOperations(final UriInfo uriInfo) {
97 return this.delegRestOpsService.getOperations(uriInfo);
101 public NormalizedNodeContext getOperations(final String identifier, final UriInfo uriInfo) {
102 return this.delegRestOpsService.getOperations(identifier, uriInfo);
106 public SchemaExportContext getSchema(final String mountAndModuleId) {
107 return this.delegRestSchService.getSchema(mountAndModuleId);
111 public Response readData(final UriInfo uriInfo) {
112 return this.delegRestconfDataService.readData(uriInfo);
116 public Response readData(final String identifier, final UriInfo uriInfo) {
117 return this.delegRestconfDataService.readData(identifier, uriInfo);
121 public Response putData(final String identifier, final NormalizedNodeContext payload, final UriInfo uriInfo) {
122 return this.delegRestconfDataService.putData(identifier, payload, uriInfo);
126 public Response postData(final String identifier, final NormalizedNodeContext payload, final UriInfo uriInfo) {
127 return this.delegRestconfDataService.postData(identifier, payload, uriInfo);
131 public Response postData(final NormalizedNodeContext payload, final UriInfo uriInfo) {
132 return this.delegRestconfDataService.postData(payload, uriInfo);
136 public Response deleteData(final String identifier) {
137 return this.delegRestconfDataService.deleteData(identifier);
141 public PatchStatusContext patchData(final String identifier, final PatchContext context, final UriInfo uriInfo) {
142 return this.delegRestconfDataService.patchData(identifier, context, uriInfo);
146 public PatchStatusContext patchData(final PatchContext context, final UriInfo uriInfo) {
147 return this.delegRestconfDataService.patchData(context, uriInfo);
151 public Response patchData(final String identifier, final NormalizedNodeContext payload, final UriInfo uriInfo) {
152 return this.delegRestconfDataService.patchData(identifier, payload, uriInfo);
156 public NormalizedNodeContext invokeRpc(final String identifier, final NormalizedNodeContext payload,
157 final UriInfo uriInfo) {
158 return this.delegRestconfInvokeOpsService.invokeRpc(identifier, payload, uriInfo);
162 public NormalizedNodeContext subscribeToStream(final String identifier, final UriInfo uriInfo) {
163 return this.delegRestconfSubscrService.subscribeToStream(identifier, uriInfo);
167 public NormalizedNodeContext getLibraryVersion() {
168 return this.delegRestService.getLibraryVersion();