3c386490a4d3681974d93093f32e2bfa14354791
[netconf.git] / restconf / restconf-nb-rfc8040 / 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 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.restconf.nb.rfc8040.handlers.SchemaContextHandler;
15 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.JsonNormalizedNodeBodyReader;
16 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.NormalizedNodeJsonBodyWriter;
17 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.NormalizedNodeXmlBodyWriter;
18 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.XmlNormalizedNodeBodyReader;
19 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.patch.JsonToPatchBodyReader;
20 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.patch.PatchJsonBodyWriter;
21 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.patch.PatchXmlBodyWriter;
22 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.patch.XmlToPatchBodyReader;
23 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.schema.SchemaExportContentYangBodyWriter;
24 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.schema.SchemaExportContentYinBodyWriter;
25 import org.opendaylight.restconf.nb.rfc8040.services.wrapper.ServicesWrapperImpl;
26
27 public class RestconfApplication extends Application {
28     private final SchemaContextHandler schemaContextHandler = SchemaContextHandler.instance();
29
30     @Override
31     public Set<Class<?>> getClasses() {
32         return ImmutableSet.<Class<?>>builder()
33                 .add(NormalizedNodeJsonBodyWriter.class).add(NormalizedNodeXmlBodyWriter.class)
34                 .add(SchemaExportContentYinBodyWriter.class).add(SchemaExportContentYangBodyWriter.class)
35                 .add(PatchJsonBodyWriter.class).add(PatchXmlBodyWriter.class)
36                 .build();
37     }
38
39     @Override
40     public Set<Object> getSingletons() {
41         final Set<Object> singletons = new HashSet<>();
42         singletons.add(ServicesWrapperImpl.getInstance());
43         singletons.add(new JsonNormalizedNodeBodyReader(schemaContextHandler));
44         singletons.add(new JsonToPatchBodyReader(schemaContextHandler));
45         singletons.add(new XmlNormalizedNodeBodyReader(schemaContextHandler));
46         singletons.add(new XmlToPatchBodyReader(schemaContextHandler));
47         return singletons;
48     }
49 }