070ac1305d93dea99acf8ce01dab02a42a76d9b2
[netconf.git] / restconf / restconf-nb / src / main / java / org / opendaylight / restconf / nb / rfc8040 / 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.restconf.nb.rfc8040;
9
10 import java.util.Set;
11 import javax.ws.rs.core.Application;
12 import org.opendaylight.mdsal.dom.api.DOMMountPointService;
13 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
14 import org.opendaylight.restconf.nb.rfc8040.databind.DatabindProvider;
15 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.JsonNormalizedNodeBodyWriter;
16 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.JsonPatchStatusBodyWriter;
17 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.XmlNormalizedNodeBodyWriter;
18 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.XmlPatchStatusBodyWriter;
19 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.YangSchemaExportBodyWriter;
20 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.YinSchemaExportBodyWriter;
21 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.errors.RestconfDocumentedExceptionMapper;
22 import org.opendaylight.restconf.nb.rfc8040.rests.services.impl.MdsalRestconfServer;
23 import org.opendaylight.restconf.nb.rfc8040.rests.services.impl.RestconfDataServiceImpl;
24 import org.opendaylight.restconf.nb.rfc8040.rests.services.impl.RestconfImpl;
25 import org.opendaylight.restconf.nb.rfc8040.rests.services.impl.RestconfSchemaServiceImpl;
26
27 final class RestconfApplication extends Application {
28     private final Set<Object> singletons;
29
30     RestconfApplication(final DatabindProvider databindProvider, final MdsalRestconfServer server,
31             final DOMMountPointService mountPointService, final DOMSchemaService domSchemaService) {
32         singletons = Set.of(
33             new RestconfDocumentedExceptionMapper(databindProvider),
34             new RestconfDataServiceImpl(databindProvider, server),
35             new RestconfImpl(server),
36             new RestconfSchemaServiceImpl(domSchemaService, mountPointService));
37     }
38
39     @Override
40     public Set<Class<?>> getClasses() {
41         return Set.of(
42             JsonNormalizedNodeBodyWriter.class, XmlNormalizedNodeBodyWriter.class,
43             YinSchemaExportBodyWriter.class, YangSchemaExportBodyWriter.class,
44             JsonPatchStatusBodyWriter.class, XmlPatchStatusBodyWriter.class);
45     }
46
47     @Override
48     public Set<Object> getSingletons() {
49         return singletons;
50     }
51 }