Reduce the use of AttrBuilders
[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.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.ControllerContext;
18 import org.opendaylight.netconf.sal.restconf.impl.StatisticsRestconfServiceWrapper;
19
20 public class RestconfApplication extends Application {
21     private final ControllerContext controllerContext;
22     private final StatisticsRestconfServiceWrapper statsServiceWrapper;
23
24     public RestconfApplication(ControllerContext controllerContext,
25             StatisticsRestconfServiceWrapper statsServiceWrapper) {
26         this.controllerContext = controllerContext;
27         this.statsServiceWrapper = statsServiceWrapper;
28     }
29
30     @Override
31     public Set<Class<?>> getClasses() {
32         return ImmutableSet.<Class<?>>builder()
33                 .add(PatchJsonBodyWriter.class)
34                 .add(PatchXmlBodyWriter.class)
35                 .add(NormalizedNodeJsonBodyWriter.class)
36                 .add(NormalizedNodeXmlBodyWriter.class)
37                 .add(SchemaExportContentYinBodyWriter.class)
38                 .add(SchemaExportContentYangBodyWriter.class)
39                 .build();
40     }
41
42     @Override
43     public Set<Object> getSingletons() {
44         final Set<Object> singletons = new HashSet<>();
45         final SchemaRetrievalServiceImpl schemaRetrieval = new SchemaRetrievalServiceImpl(controllerContext);
46         singletons.add(schemaRetrieval);
47         singletons.add(new RestconfCompositeWrapper(statsServiceWrapper, schemaRetrieval));
48         singletons.add(new RestconfDocumentedExceptionMapper(controllerContext));
49         singletons.add(new XmlNormalizedNodeBodyReader(controllerContext));
50         singletons.add(new JsonNormalizedNodeBodyReader(controllerContext));
51         singletons.add(new XmlToPatchBodyReader(controllerContext));
52         singletons.add(new JsonToPatchBodyReader(controllerContext));
53 //        singletons.add(StructuredDataToXmlProvider.INSTANCE);
54 //        singletons.add(StructuredDataToJsonProvider.INSTANCE);
55 //        singletons.add(JsonToCompositeNodeProvider.INSTANCE);
56 //        singletons.add(XmlToCompositeNodeProvider.INSTANCE);
57         return singletons;
58     }
59
60 }