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}
48 public final class ServicesWrapper implements BaseServicesWrapper, TransactionServicesWrapper {
50 private final RestconfDataService delegRestconfDataService;
51 private final RestconfInvokeOperationsService delegRestconfInvokeOpsService;
52 private final RestconfStreamsSubscriptionService delegRestconfSubscrService;
53 private final RestconfOperationsService delegRestOpsService;
54 private final RestconfSchemaService delegRestSchService;
55 private final RestconfService delegRestService;
57 private ServicesWrapper(RestconfDataService delegRestconfDataService,
58 RestconfInvokeOperationsService delegRestconfInvokeOpsService,
59 RestconfStreamsSubscriptionService delegRestconfSubscrService,
60 RestconfOperationsService delegRestOpsService, RestconfSchemaService delegRestSchService,
61 RestconfService delegRestService) {
62 this.delegRestconfDataService = delegRestconfDataService;
63 this.delegRestconfInvokeOpsService = delegRestconfInvokeOpsService;
64 this.delegRestconfSubscrService = delegRestconfSubscrService;
65 this.delegRestOpsService = delegRestOpsService;
66 this.delegRestSchService = delegRestSchService;
67 this.delegRestService = delegRestService;
70 public static ServicesWrapper newInstance(final SchemaContextHandler schemaCtxHandler,
71 final DOMMountPointServiceHandler domMountPointServiceHandler,
72 final TransactionChainHandler transactionChainHandler, final DOMDataBrokerHandler domDataBrokerHandler,
73 final RpcServiceHandler rpcServiceHandler, final NotificationServiceHandler notificationServiceHandler,
74 final DOMSchemaService domSchemaService) {
75 RestconfOperationsService restconfOpsService =
76 new RestconfOperationsServiceImpl(schemaCtxHandler, domMountPointServiceHandler);
77 final DOMYangTextSourceProvider yangTextSourceProvider = domSchemaService.getExtensions()
78 .getInstance(DOMYangTextSourceProvider.class);
79 RestconfSchemaService restconfSchemaService =
80 new RestconfSchemaServiceImpl(schemaCtxHandler, domMountPointServiceHandler,
81 yangTextSourceProvider);
82 RestconfStreamsSubscriptionService restconfSubscrService =
83 new RestconfStreamsSubscriptionServiceImpl(domDataBrokerHandler,
84 notificationServiceHandler, schemaCtxHandler, transactionChainHandler);
85 RestconfDataService restconfDataService =
86 new RestconfDataServiceImpl(schemaCtxHandler, transactionChainHandler, domMountPointServiceHandler,
87 restconfSubscrService);
88 RestconfInvokeOperationsService restconfInvokeOpsService =
89 new RestconfInvokeOperationsServiceImpl(rpcServiceHandler, schemaCtxHandler);
90 RestconfService restconfService = new RestconfImpl(schemaCtxHandler);
91 return new ServicesWrapper(restconfDataService, restconfInvokeOpsService,
92 restconfSubscrService, 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 NormalizedNodeContext invokeRpc(final String identifier, final NormalizedNodeContext payload,
152 final UriInfo uriInfo) {
153 return this.delegRestconfInvokeOpsService.invokeRpc(identifier, payload, uriInfo);
157 public NormalizedNodeContext subscribeToStream(final String identifier, final UriInfo uriInfo) {
158 return this.delegRestconfSubscrService.subscribeToStream(identifier, uriInfo);
162 public NormalizedNodeContext getLibraryVersion() {
163 return this.delegRestService.getLibraryVersion();