2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.restconf.nb.rfc8040;
10 import com.google.common.collect.ImmutableSet;
11 import java.util.HashSet;
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.errors.RestconfDocumentedExceptionMapper;
23 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.patch.JsonToPatchBodyReader;
24 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.patch.PatchJsonBodyWriter;
25 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.patch.PatchXmlBodyWriter;
26 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.patch.XmlToPatchBodyReader;
27 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.schema.SchemaExportContentYangBodyWriter;
28 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.schema.SchemaExportContentYinBodyWriter;
29 import org.opendaylight.restconf.nb.rfc8040.services.wrapper.ServicesWrapper;
32 public class RestconfApplication extends Application {
34 private final SchemaContextHandler schemaContextHandler;
35 private final DOMMountPointServiceHandler mountPointServiceHandler;
36 private final ServicesWrapper servicesWrapper;
39 public RestconfApplication(SchemaContextHandler schemaContextHandler,
40 DOMMountPointServiceHandler mountPointServiceHandler, ServicesWrapper servicesWrapper) {
41 this.schemaContextHandler = schemaContextHandler;
42 this.mountPointServiceHandler = mountPointServiceHandler;
43 this.servicesWrapper = servicesWrapper;
47 public Set<Class<?>> getClasses() {
48 return ImmutableSet.<Class<?>>builder()
49 .add(NormalizedNodeJsonBodyWriter.class).add(NormalizedNodeXmlBodyWriter.class)
50 .add(SchemaExportContentYinBodyWriter.class).add(SchemaExportContentYangBodyWriter.class)
51 .add(PatchJsonBodyWriter.class).add(PatchXmlBodyWriter.class)
56 public Set<Object> getSingletons() {
57 final Set<Object> singletons = new HashSet<>();
58 singletons.add(servicesWrapper);
59 singletons.add(new JsonNormalizedNodeBodyReader(schemaContextHandler, mountPointServiceHandler));
60 singletons.add(new JsonToPatchBodyReader(schemaContextHandler, mountPointServiceHandler));
61 singletons.add(new XmlNormalizedNodeBodyReader(schemaContextHandler, mountPointServiceHandler));
62 singletons.add(new XmlToPatchBodyReader(schemaContextHandler, mountPointServiceHandler));
63 singletons.add(new RestconfDocumentedExceptionMapper(schemaContextHandler));