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.ActionServiceHandler;
20 import org.opendaylight.restconf.nb.rfc8040.handlers.DOMDataBrokerHandler;
21 import org.opendaylight.restconf.nb.rfc8040.handlers.DOMMountPointServiceHandler;
22 import org.opendaylight.restconf.nb.rfc8040.handlers.NotificationServiceHandler;
23 import org.opendaylight.restconf.nb.rfc8040.handlers.RpcServiceHandler;
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.RestconfStreamsSubscriptionService;
29 import org.opendaylight.restconf.nb.rfc8040.rests.services.api.TransactionServicesWrapper;
30 import org.opendaylight.restconf.nb.rfc8040.rests.services.impl.RestconfDataServiceImpl;
31 import org.opendaylight.restconf.nb.rfc8040.rests.services.impl.RestconfInvokeOperationsServiceImpl;
32 import org.opendaylight.restconf.nb.rfc8040.rests.services.impl.RestconfStreamsSubscriptionServiceImpl;
33 import org.opendaylight.restconf.nb.rfc8040.services.simple.api.BaseServicesWrapper;
34 import org.opendaylight.restconf.nb.rfc8040.services.simple.api.RestconfOperationsService;
35 import org.opendaylight.restconf.nb.rfc8040.services.simple.api.RestconfSchemaService;
36 import org.opendaylight.restconf.nb.rfc8040.services.simple.api.RestconfService;
37 import org.opendaylight.restconf.nb.rfc8040.services.simple.impl.RestconfImpl;
38 import org.opendaylight.restconf.nb.rfc8040.services.simple.impl.RestconfOperationsServiceImpl;
39 import org.opendaylight.restconf.nb.rfc8040.services.simple.impl.RestconfSchemaServiceImpl;
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 DOMMountPointServiceHandler domMountPointServiceHandler,
74 final TransactionChainHandler transactionChainHandler, final DOMDataBrokerHandler domDataBrokerHandler,
75 final RpcServiceHandler rpcServiceHandler, final ActionServiceHandler actionServiceHandler,
76 final NotificationServiceHandler notificationServiceHandler, final DOMSchemaService domSchemaService,
77 final Configuration configuration) {
78 RestconfOperationsService restconfOpsService = new RestconfOperationsServiceImpl(schemaCtxHandler,
79 domMountPointServiceHandler);
80 final DOMYangTextSourceProvider yangTextSourceProvider = domSchemaService.getExtensions()
81 .getInstance(DOMYangTextSourceProvider.class);
82 RestconfSchemaService restconfSchemaService = new RestconfSchemaServiceImpl(schemaCtxHandler,
83 domMountPointServiceHandler, yangTextSourceProvider);
84 RestconfStreamsSubscriptionService restconfSubscrService = new RestconfStreamsSubscriptionServiceImpl(
85 domDataBrokerHandler, notificationServiceHandler, schemaCtxHandler, transactionChainHandler,
87 RestconfDataService restconfDataService = new RestconfDataServiceImpl(schemaCtxHandler, transactionChainHandler,
88 domMountPointServiceHandler, restconfSubscrService, actionServiceHandler, configuration);
89 RestconfInvokeOperationsService restconfInvokeOpsService = new RestconfInvokeOperationsServiceImpl(
90 rpcServiceHandler, schemaCtxHandler);
91 RestconfService restconfService = new RestconfImpl(schemaCtxHandler);
92 return new ServicesWrapper(restconfDataService, restconfInvokeOpsService, restconfSubscrService,
93 restconfOpsService, restconfSchemaService, restconfService);
97 public NormalizedNodeContext getOperations(final UriInfo uriInfo) {
98 return this.delegRestOpsService.getOperations(uriInfo);
102 public NormalizedNodeContext getOperations(final String identifier, final UriInfo uriInfo) {
103 return this.delegRestOpsService.getOperations(identifier, uriInfo);
107 public SchemaExportContext getSchema(final String mountAndModuleId) {
108 return this.delegRestSchService.getSchema(mountAndModuleId);
112 public Response readData(final UriInfo uriInfo) {
113 return this.delegRestconfDataService.readData(uriInfo);
117 public Response readData(final String identifier, final UriInfo uriInfo) {
118 return this.delegRestconfDataService.readData(identifier, uriInfo);
122 public Response putData(final String identifier, final NormalizedNodeContext payload, final UriInfo uriInfo) {
123 return this.delegRestconfDataService.putData(identifier, payload, uriInfo);
127 public Response postData(final String identifier, final NormalizedNodeContext payload, final UriInfo uriInfo) {
128 return this.delegRestconfDataService.postData(identifier, payload, uriInfo);
132 public Response postData(final NormalizedNodeContext payload, final UriInfo uriInfo) {
133 return this.delegRestconfDataService.postData(payload, uriInfo);
137 public Response deleteData(final String identifier) {
138 return this.delegRestconfDataService.deleteData(identifier);
142 public PatchStatusContext patchData(final String identifier, final PatchContext context, final UriInfo uriInfo) {
143 return this.delegRestconfDataService.patchData(identifier, context, uriInfo);
147 public PatchStatusContext patchData(final PatchContext context, final UriInfo uriInfo) {
148 return this.delegRestconfDataService.patchData(context, uriInfo);
152 public Response patchData(final String identifier, final NormalizedNodeContext payload, final UriInfo uriInfo) {
153 return this.delegRestconfDataService.patchData(identifier, payload, uriInfo);
157 public NormalizedNodeContext invokeRpc(final String identifier, final NormalizedNodeContext payload,
158 final UriInfo uriInfo) {
159 return this.delegRestconfInvokeOpsService.invokeRpc(identifier, payload, uriInfo);
163 public NormalizedNodeContext subscribeToStream(final String identifier, final UriInfo uriInfo) {
164 return this.delegRestconfSubscrService.subscribeToStream(identifier, uriInfo);
168 public NormalizedNodeContext getLibraryVersion() {
169 return this.delegRestService.getLibraryVersion();