Bug 3866: Support for Restconf HTTP Patch
[netconf.git] / opendaylight / restconf / sal-rest-connector / src / main / java / org / opendaylight / netconf / sal / rest / impl / RestconfApplication.java
1 /*
2  * Copyright (c) 2014 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.netconf.sal.rest.impl;
9
10 import com.google.common.collect.ImmutableSet;
11 import java.util.HashSet;
12 import java.util.Set;
13 import javax.ws.rs.core.Application;
14 import org.opendaylight.netconf.md.sal.rest.schema.SchemaExportContentYangBodyWriter;
15 import org.opendaylight.netconf.md.sal.rest.schema.SchemaExportContentYinBodyWriter;
16 import org.opendaylight.netconf.md.sal.rest.schema.SchemaRetrievalServiceImpl;
17 import org.opendaylight.netconf.sal.restconf.impl.BrokerFacade;
18 import org.opendaylight.netconf.sal.restconf.impl.ControllerContext;
19 import org.opendaylight.netconf.sal.restconf.impl.RestconfImpl;
20 import org.opendaylight.netconf.sal.restconf.impl.StatisticsRestconfServiceWrapper;
21
22 public class RestconfApplication extends Application {
23
24     @Override
25     public Set<Class<?>> getClasses() {
26         return ImmutableSet.<Class<?>> builder()
27                 .add(RestconfDocumentedExceptionMapper.class)
28                 .add(XmlNormalizedNodeBodyReader.class)
29                 .add(JsonNormalizedNodeBodyReader.class)
30                 .add(JsonToPATCHBodyReader.class)
31                 .add(XmlToPATCHBodyReader.class)
32                 .add(PATCHJsonBodyWriter.class)
33                 .add(PATCHXmlBodyWriter.class)
34                 .add(NormalizedNodeJsonBodyWriter.class)
35                 .add(NormalizedNodeXmlBodyWriter.class)
36                 .add(SchemaExportContentYinBodyWriter.class)
37                 .add(SchemaExportContentYangBodyWriter.class)
38                 .build();
39     }
40
41     @Override
42     public Set<Object> getSingletons() {
43         final Set<Object> singletons = new HashSet<>();
44         final ControllerContext controllerContext = ControllerContext.getInstance();
45         final BrokerFacade brokerFacade = BrokerFacade.getInstance();
46         final RestconfImpl restconfImpl = RestconfImpl.getInstance();
47         final SchemaRetrievalServiceImpl schemaRetrieval = new SchemaRetrievalServiceImpl(controllerContext);
48         restconfImpl.setBroker(brokerFacade);
49         restconfImpl.setControllerContext(controllerContext);
50         singletons.add(controllerContext);
51         singletons.add(brokerFacade);
52         singletons.add(schemaRetrieval);
53         singletons.add(new RestconfCompositeWrapper(StatisticsRestconfServiceWrapper.getInstance(), schemaRetrieval));
54 //        singletons.add(StructuredDataToXmlProvider.INSTANCE);
55 //        singletons.add(StructuredDataToJsonProvider.INSTANCE);
56 //        singletons.add(JsonToCompositeNodeProvider.INSTANCE);
57 //        singletons.add(XmlToCompositeNodeProvider.INSTANCE);
58         return singletons;
59     }
60
61 }