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.restconf.common.context.NormalizedNodeContext;
14 import org.opendaylight.restconf.common.patch.PatchContext;
15 import org.opendaylight.restconf.common.patch.PatchStatusContext;
16 import org.opendaylight.restconf.common.schema.SchemaExportContext;
17 import org.opendaylight.restconf.nb.rfc8040.handlers.DOMDataBrokerHandler;
18 import org.opendaylight.restconf.nb.rfc8040.handlers.DOMMountPointServiceHandler;
19 import org.opendaylight.restconf.nb.rfc8040.handlers.NotificationServiceHandler;
20 import org.opendaylight.restconf.nb.rfc8040.handlers.RpcServiceHandler;
21 import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
22 import org.opendaylight.restconf.nb.rfc8040.handlers.TransactionChainHandler;
23 import org.opendaylight.restconf.nb.rfc8040.rests.services.api.RestconfDataService;
24 import org.opendaylight.restconf.nb.rfc8040.rests.services.api.RestconfInvokeOperationsService;
25 import org.opendaylight.restconf.nb.rfc8040.rests.services.api.RestconfStreamsSubscriptionService;
26 import org.opendaylight.restconf.nb.rfc8040.rests.services.api.TransactionServicesWrapper;
27 import org.opendaylight.restconf.nb.rfc8040.rests.services.impl.RestconfDataServiceImpl;
28 import org.opendaylight.restconf.nb.rfc8040.rests.services.impl.RestconfInvokeOperationsServiceImpl;
29 import org.opendaylight.restconf.nb.rfc8040.rests.services.impl.RestconfStreamsSubscriptionServiceImpl;
30 import org.opendaylight.restconf.nb.rfc8040.services.simple.api.BaseServicesWrapper;
31 import org.opendaylight.restconf.nb.rfc8040.services.simple.api.RestconfOperationsService;
32 import org.opendaylight.restconf.nb.rfc8040.services.simple.api.RestconfSchemaService;
33 import org.opendaylight.restconf.nb.rfc8040.services.simple.api.RestconfService;
34 import org.opendaylight.restconf.nb.rfc8040.services.simple.impl.RestconfImpl;
35 import org.opendaylight.restconf.nb.rfc8040.services.simple.impl.RestconfOperationsServiceImpl;
36 import org.opendaylight.restconf.nb.rfc8040.services.simple.impl.RestconfSchemaServiceImpl;
39 * Wrapper for services.
41 * <li>{@link BaseServicesWrapper}
42 * <li>{@link TransactionServicesWrapper}
47 public class ServicesWrapperImpl implements BaseServicesWrapper, TransactionServicesWrapper, ServiceWrapper {
49 private RestconfDataService delegRestconfDataService;
50 private RestconfInvokeOperationsService delegRestconfInvokeOpsService;
51 private RestconfStreamsSubscriptionService delegRestconfSubscrService;
52 private RestconfOperationsService delegRestOpsService;
53 private RestconfSchemaService delegRestSchService;
54 private RestconfService delegRestService;
56 private ServicesWrapperImpl() {
59 private static class InstanceHolder {
60 public static final ServicesWrapperImpl INSTANCE = new ServicesWrapperImpl();
63 public static ServicesWrapperImpl getInstance() {
64 return InstanceHolder.INSTANCE;
68 public NormalizedNodeContext getOperations(final UriInfo uriInfo) {
69 return this.delegRestOpsService.getOperations(uriInfo);
73 public NormalizedNodeContext getOperations(final String identifier, final UriInfo uriInfo) {
74 return this.delegRestOpsService.getOperations(identifier, uriInfo);
78 public SchemaExportContext getSchema(final String mountAndModuleId) {
79 return this.delegRestSchService.getSchema(mountAndModuleId);
83 public Response readData(final UriInfo uriInfo) {
84 return this.delegRestconfDataService.readData(uriInfo);
88 public Response readData(final String identifier, final UriInfo uriInfo) {
89 return this.delegRestconfDataService.readData(identifier, uriInfo);
93 public Response putData(final String identifier, final NormalizedNodeContext payload, final UriInfo uriInfo) {
94 return this.delegRestconfDataService.putData(identifier, payload, uriInfo);
98 public Response postData(final String identifier, final NormalizedNodeContext payload, final UriInfo uriInfo) {
99 return this.delegRestconfDataService.postData(identifier, payload, uriInfo);
103 public Response postData(final NormalizedNodeContext payload, final UriInfo uriInfo) {
104 return this.delegRestconfDataService.postData(payload, uriInfo);
108 public Response deleteData(final String identifier) {
109 return this.delegRestconfDataService.deleteData(identifier);
113 public PatchStatusContext patchData(final String identifier, final PatchContext context, final UriInfo uriInfo) {
114 return this.delegRestconfDataService.patchData(identifier, context, uriInfo);
118 public PatchStatusContext patchData(final PatchContext context, final UriInfo uriInfo) {
119 return this.delegRestconfDataService.patchData(context, uriInfo);
123 public NormalizedNodeContext invokeRpc(final String identifier, final NormalizedNodeContext payload,
124 final UriInfo uriInfo) {
125 return this.delegRestconfInvokeOpsService.invokeRpc(identifier, payload, uriInfo);
129 public NormalizedNodeContext subscribeToStream(final String identifier, final UriInfo uriInfo) {
130 return this.delegRestconfSubscrService.subscribeToStream(identifier, uriInfo);
134 public NormalizedNodeContext getLibraryVersion() {
135 return this.delegRestService.getLibraryVersion();
139 public void setHandlers(final SchemaContextHandler schemaCtxHandler,
140 final DOMMountPointServiceHandler domMountPointServiceHandler,
141 final TransactionChainHandler transactionChainHandler, final DOMDataBrokerHandler domDataBrokerHandler,
142 final RpcServiceHandler rpcServiceHandler, final NotificationServiceHandler notificationServiceHandler) {
143 this.delegRestOpsService = new RestconfOperationsServiceImpl(schemaCtxHandler, domMountPointServiceHandler);
144 this.delegRestSchService = new RestconfSchemaServiceImpl(schemaCtxHandler, domMountPointServiceHandler);
145 this.delegRestconfSubscrService = new RestconfStreamsSubscriptionServiceImpl(domDataBrokerHandler,
146 notificationServiceHandler, schemaCtxHandler, transactionChainHandler);
147 this.delegRestconfDataService =
148 new RestconfDataServiceImpl(schemaCtxHandler, transactionChainHandler, domMountPointServiceHandler,
149 this.delegRestconfSubscrService);
150 this.delegRestconfInvokeOpsService =
151 new RestconfInvokeOperationsServiceImpl(rpcServiceHandler, schemaCtxHandler);
152 this.delegRestService = new RestconfImpl(schemaCtxHandler);