d8918dfaeba7792b00fa3cd4f593a2930c5273cd
[netconf.git] / restconf / restconf-nb-bierman02 / 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.inject.Inject;
14 import javax.inject.Singleton;
15 import javax.ws.rs.core.Application;
16 import org.opendaylight.netconf.md.sal.rest.schema.SchemaExportContentYangBodyWriter;
17 import org.opendaylight.netconf.md.sal.rest.schema.SchemaExportContentYinBodyWriter;
18 import org.opendaylight.netconf.md.sal.rest.schema.SchemaRetrievalServiceImpl;
19 import org.opendaylight.netconf.sal.restconf.impl.ControllerContext;
20 import org.opendaylight.netconf.sal.restconf.impl.StatisticsRestconfServiceWrapper;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
23
24 @Singleton
25 @Deprecated(since = "2.0.12")
26 public class RestconfApplication extends Application {
27     private static final Logger LOG = LoggerFactory.getLogger(RestconfApplication.class);
28
29     private final ControllerContext controllerContext;
30     private final StatisticsRestconfServiceWrapper statsServiceWrapper;
31
32     @Inject
33     public RestconfApplication(final ControllerContext controllerContext,
34             final StatisticsRestconfServiceWrapper statsServiceWrapper) {
35         this.controllerContext = controllerContext;
36         this.statsServiceWrapper = statsServiceWrapper;
37         LOG.warn("Pre-standard version of RESTCONF activated. Please note that this implementation is considered "
38             + "obsoleve and WILL BE REMOVED IN THE NEXT MAJOR RELEASE. Please use the RFC8040-compliant "
39             + "implementation instead.");
40     }
41
42     @Override
43     public Set<Class<?>> getClasses() {
44         return ImmutableSet.<Class<?>>builder()
45                 .add(PatchJsonBodyWriter.class)
46                 .add(PatchXmlBodyWriter.class)
47                 .add(NormalizedNodeJsonBodyWriter.class)
48                 .add(NormalizedNodeXmlBodyWriter.class)
49                 .add(SchemaExportContentYinBodyWriter.class)
50                 .add(SchemaExportContentYangBodyWriter.class)
51                 .build();
52     }
53
54     @Override
55     public Set<Object> getSingletons() {
56         final Set<Object> singletons = new HashSet<>();
57         final SchemaRetrievalServiceImpl schemaRetrieval = new SchemaRetrievalServiceImpl(controllerContext);
58         singletons.add(schemaRetrieval);
59         singletons.add(new RestconfCompositeWrapper(statsServiceWrapper, schemaRetrieval));
60         singletons.add(new RestconfDocumentedExceptionMapper(controllerContext));
61         singletons.add(new XmlNormalizedNodeBodyReader(controllerContext));
62         singletons.add(new JsonNormalizedNodeBodyReader(controllerContext));
63         singletons.add(new XmlToPatchBodyReader(controllerContext));
64         singletons.add(new JsonToPatchBodyReader(controllerContext));
65 //        singletons.add(StructuredDataToXmlProvider.INSTANCE);
66 //        singletons.add(StructuredDataToJsonProvider.INSTANCE);
67 //        singletons.add(JsonToCompositeNodeProvider.INSTANCE);
68 //        singletons.add(XmlToCompositeNodeProvider.INSTANCE);
69         return singletons;
70     }
71
72 }