introduce Rfc8040RestConfWiring for standalone (simple) environments
[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.inject.Inject;
14 import javax.inject.Singleton;
15 import javax.ws.rs.core.Application;
16 import org.opendaylight.restconf.nb.rfc8040.handlers.DOMMountPointServiceHandler;
17 import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
18 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.JsonNormalizedNodeBodyReader;
19 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.NormalizedNodeJsonBodyWriter;
20 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.NormalizedNodeXmlBodyWriter;
21 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.XmlNormalizedNodeBodyReader;
22 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.patch.JsonToPatchBodyReader;
23 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.patch.PatchJsonBodyWriter;
24 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.patch.PatchXmlBodyWriter;
25 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.patch.XmlToPatchBodyReader;
26 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.schema.SchemaExportContentYangBodyWriter;
27 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.schema.SchemaExportContentYinBodyWriter;
28 import org.opendaylight.restconf.nb.rfc8040.services.wrapper.ServicesWrapper;
29
30 @Singleton
31 public class RestconfApplication extends Application {
32
33     private final SchemaContextHandler schemaContextHandler;
34     private final DOMMountPointServiceHandler mountPointServiceHandler;
35     private final ServicesWrapper servicesWrapper;
36
37     @Inject
38     public RestconfApplication(SchemaContextHandler schemaContextHandler,
39             DOMMountPointServiceHandler mountPointServiceHandler, ServicesWrapper servicesWrapper) {
40         this.schemaContextHandler = schemaContextHandler;
41         this.mountPointServiceHandler = mountPointServiceHandler;
42         this.servicesWrapper = servicesWrapper;
43     }
44
45     @Override
46     public Set<Class<?>> getClasses() {
47         return ImmutableSet.<Class<?>>builder()
48                 .add(NormalizedNodeJsonBodyWriter.class).add(NormalizedNodeXmlBodyWriter.class)
49                 .add(SchemaExportContentYinBodyWriter.class).add(SchemaExportContentYangBodyWriter.class)
50                 .add(PatchJsonBodyWriter.class).add(PatchXmlBodyWriter.class)
51                 .build();
52     }
53
54     @Override
55     public Set<Object> getSingletons() {
56         final Set<Object> singletons = new HashSet<>();
57         singletons.add(servicesWrapper);
58         singletons.add(new JsonNormalizedNodeBodyReader(schemaContextHandler, mountPointServiceHandler));
59         singletons.add(new JsonToPatchBodyReader(schemaContextHandler, mountPointServiceHandler));
60         singletons.add(new XmlNormalizedNodeBodyReader(schemaContextHandler, mountPointServiceHandler));
61         singletons.add(new XmlToPatchBodyReader(schemaContextHandler, mountPointServiceHandler));
62         return singletons;
63     }
64 }