BUG-1442: integrate XML/JSON Normalized Node writers with Restconf
[controller.git] / opendaylight / md-sal / sal-rest-connector / src / main / java / org / opendaylight / controller / 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.controller.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.controller.sal.restconf.impl.BrokerFacade;
15 import org.opendaylight.controller.sal.restconf.impl.ControllerContext;
16 import org.opendaylight.controller.sal.restconf.impl.RestconfImpl;
17
18 public class RestconfApplication extends Application {
19
20     @Override
21     public Set<Class<?>> getClasses() {
22         return ImmutableSet.<Class<?>> builder()
23                 .add(RestconfDocumentedExceptionMapper.class)
24                 .add(XmlNormalizedNodeBodyReader.class)
25                 .add(JsonNormalizedNodeBodyReader.class)
26                 .add(NormalizedNodeJsonBodyWriter.class)
27                 .add(NormalizedNodeXmlBodyWriter.class)
28                 .build();
29     }
30
31     @Override
32     public Set<Object> getSingletons() {
33         Set<Object> singletons = new HashSet<>();
34         ControllerContext controllerContext = ControllerContext.getInstance();
35         BrokerFacade brokerFacade = BrokerFacade.getInstance();
36         RestconfImpl restconfImpl = RestconfImpl.getInstance();
37         restconfImpl.setBroker(brokerFacade);
38         restconfImpl.setControllerContext(controllerContext);
39         singletons.add(controllerContext);
40         singletons.add(brokerFacade);
41         singletons.add(restconfImpl);
42         singletons.add(StructuredDataToXmlProvider.INSTANCE);
43         singletons.add(StructuredDataToJsonProvider.INSTANCE);
44         singletons.add(JsonToCompositeNodeProvider.INSTANCE);
45         singletons.add(XmlToCompositeNodeProvider.INSTANCE);
46         return singletons;
47     }
48
49 }