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.common.wrapper.services;
10 import javax.ws.rs.Path;
11 import javax.ws.rs.core.Response;
12 import javax.ws.rs.core.UriInfo;
13 import org.opendaylight.netconf.sal.restconf.impl.PatchContext;
14 import org.opendaylight.netconf.sal.restconf.impl.PatchStatusContext;
15 import org.opendaylight.restconf.base.services.api.BaseServicesWrapper;
16 import org.opendaylight.restconf.base.services.api.RestconfOperationsService;
17 import org.opendaylight.restconf.base.services.api.RestconfSchemaService;
18 import org.opendaylight.restconf.base.services.api.RestconfService;
19 import org.opendaylight.restconf.base.services.impl.RestconfImpl;
20 import org.opendaylight.restconf.base.services.impl.RestconfOperationsServiceImpl;
21 import org.opendaylight.restconf.base.services.impl.RestconfSchemaServiceImpl;
22 import org.opendaylight.restconf.common.context.NormalizedNodeContext;
23 import org.opendaylight.restconf.common.schema.SchemaExportContext;
24 import org.opendaylight.restconf.handlers.DOMDataBrokerHandler;
25 import org.opendaylight.restconf.handlers.DOMMountPointServiceHandler;
26 import org.opendaylight.restconf.handlers.NotificationServiceHandler;
27 import org.opendaylight.restconf.handlers.RpcServiceHandler;
28 import org.opendaylight.restconf.handlers.SchemaContextHandler;
29 import org.opendaylight.restconf.handlers.TransactionChainHandler;
30 import org.opendaylight.restconf.restful.services.api.RestconfDataService;
31 import org.opendaylight.restconf.restful.services.api.RestconfInvokeOperationsService;
32 import org.opendaylight.restconf.restful.services.api.RestconfStreamsSubscriptionService;
33 import org.opendaylight.restconf.restful.services.api.TransactionServicesWrapper;
34 import org.opendaylight.restconf.restful.services.impl.RestconfDataServiceImpl;
35 import org.opendaylight.restconf.restful.services.impl.RestconfInvokeOperationsServiceImpl;
36 import org.opendaylight.restconf.restful.services.impl.RestconfStreamsSubscriptionServiceImpl;
39 * Wrapper for services.
41 * <li>{@link BaseServicesWrapper}
42 * <li>{@link TransactionServicesWrapper}
47 public class ServicesWrapperImpl implements BaseServicesWrapper, TransactionServicesWrapper {
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();
138 public void setHandlers(final SchemaContextHandler schemaCtxHandler,
139 final DOMMountPointServiceHandler domMountPointServiceHandler,
140 final TransactionChainHandler transactionChainHandler, final DOMDataBrokerHandler domDataBrokerHandler,
141 final RpcServiceHandler rpcServiceHandler, final NotificationServiceHandler notificationServiceHandler) {
142 this.delegRestOpsService = new RestconfOperationsServiceImpl(schemaCtxHandler, domMountPointServiceHandler);
143 this.delegRestSchService = new RestconfSchemaServiceImpl(schemaCtxHandler, domMountPointServiceHandler);
144 this.delegRestconfSubscrService = new RestconfStreamsSubscriptionServiceImpl(domDataBrokerHandler,
145 notificationServiceHandler, schemaCtxHandler, transactionChainHandler);
146 this.delegRestconfDataService =
147 new RestconfDataServiceImpl(schemaCtxHandler, transactionChainHandler, domMountPointServiceHandler,
148 this.delegRestconfSubscrService);
149 this.delegRestconfInvokeOpsService =
150 new RestconfInvokeOperationsServiceImpl(rpcServiceHandler, schemaCtxHandler);
151 this.delegRestService = new RestconfImpl(schemaCtxHandler);