Bug 7686 - Make notifications defined by yangs automatic loaded
[netconf.git] / restconf / sal-rest-connector / src / main / java / org / opendaylight / restconf / common / wrapper / services / ServicesWrapperImpl.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.restconf.common.wrapper.services;
9
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.md.sal.rest.schema.SchemaExportContext;
14 import org.opendaylight.netconf.sal.restconf.impl.NormalizedNodeContext;
15 import org.opendaylight.netconf.sal.restconf.impl.PATCHContext;
16 import org.opendaylight.netconf.sal.restconf.impl.PATCHStatusContext;
17 import org.opendaylight.restconf.base.services.api.BaseServicesWrapper;
18 import org.opendaylight.restconf.base.services.api.RestconfOperationsService;
19 import org.opendaylight.restconf.base.services.api.RestconfSchemaService;
20 import org.opendaylight.restconf.base.services.api.RestconfService;
21 import org.opendaylight.restconf.base.services.impl.RestconfImpl;
22 import org.opendaylight.restconf.base.services.impl.RestconfOperationsServiceImpl;
23 import org.opendaylight.restconf.base.services.impl.RestconfSchemaServiceImpl;
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;
37
38 /**
39  * Wrapper for services:
40  * <ul>
41  * <li>{@link BaseServicesWrapper}
42  * <li>{@link TransactionServicesWrapper}
43  * </ul>
44  *
45  */
46 @Path("/")
47 public class ServicesWrapperImpl implements BaseServicesWrapper, TransactionServicesWrapper {
48
49     private RestconfDataService delegRestconfDataService;
50     private RestconfInvokeOperationsService delegRestconfInvokeOpsService;
51     private RestconfStreamsSubscriptionService delegRestconfSubscrService;
52     private RestconfOperationsService delegRestOpsService;
53     private RestconfSchemaService delegRestSchService;
54     private RestconfService delegRestService;
55
56     private ServicesWrapperImpl() {
57     }
58
59     private static class InstanceHolder {
60         public static final ServicesWrapperImpl INSTANCE = new ServicesWrapperImpl();
61     }
62
63     public static ServicesWrapperImpl getInstance() {
64         return InstanceHolder.INSTANCE;
65     }
66
67     @Override
68     public NormalizedNodeContext getOperations(final UriInfo uriInfo) {
69         return this.delegRestOpsService.getOperations(uriInfo);
70     }
71
72     @Override
73     public NormalizedNodeContext getOperations(final String identifier, final UriInfo uriInfo) {
74         return this.delegRestOpsService.getOperations(identifier, uriInfo);
75     }
76
77     @Override
78     public SchemaExportContext getSchema(final String mountAndModuleId) {
79         return this.delegRestSchService.getSchema(mountAndModuleId);
80     }
81
82     @Override
83     public Response readData(final UriInfo uriInfo) {
84         return this.delegRestconfDataService.readData(uriInfo);
85     }
86
87     @Override
88     public Response readData(final String identifier, final UriInfo uriInfo) {
89         return this.delegRestconfDataService.readData(identifier, uriInfo);
90     }
91
92     @Override
93     public Response putData(final String identifier, final NormalizedNodeContext payload, final UriInfo uriInfo) {
94         return this.delegRestconfDataService.putData(identifier, payload, uriInfo);
95     }
96
97     @Override
98     public Response postData(final String identifier, final NormalizedNodeContext payload, final UriInfo uriInfo) {
99         return this.delegRestconfDataService.postData(identifier, payload, uriInfo);
100     }
101
102     @Override
103     public Response postData(final NormalizedNodeContext payload, final UriInfo uriInfo) {
104         return this.delegRestconfDataService.postData(payload, uriInfo);
105     }
106
107     @Override
108     public Response deleteData(final String identifier) {
109         return this.delegRestconfDataService.deleteData(identifier);
110     }
111
112     @Override
113     public PATCHStatusContext patchData(final String identifier, final PATCHContext context, final UriInfo uriInfo) {
114         return this.delegRestconfDataService.patchData(identifier, context, uriInfo);
115     }
116
117     @Override
118     public PATCHStatusContext patchData(final PATCHContext context, final UriInfo uriInfo) {
119         return this.delegRestconfDataService.patchData(context, uriInfo);
120     }
121
122     @Override
123     public NormalizedNodeContext invokeRpc(final String identifier, final NormalizedNodeContext payload,
124             final UriInfo uriInfo) {
125         return this.delegRestconfInvokeOpsService.invokeRpc(identifier, payload, uriInfo);
126     }
127
128     @Override
129     public NormalizedNodeContext subscribeToStream(final String identifier, final UriInfo uriInfo) {
130         return this.delegRestconfSubscrService.subscribeToStream(identifier, uriInfo);
131     }
132
133     @Override
134     public NormalizedNodeContext getLibraryVersion() {
135         return this.delegRestService.getLibraryVersion();
136     }
137
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);
152     }
153 }