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.ws.rs.core.Application;
14 import org.opendaylight.restconf.nb.rfc8040.handlers.DOMMountPointServiceHandler;
15 import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
16 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.JsonNormalizedNodeBodyReader;
17 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.NormalizedNodeJsonBodyWriter;
18 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.NormalizedNodeXmlBodyWriter;
19 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.XmlNormalizedNodeBodyReader;
20 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.patch.JsonToPatchBodyReader;
21 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.patch.PatchJsonBodyWriter;
22 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.patch.PatchXmlBodyWriter;
23 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.patch.XmlToPatchBodyReader;
24 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.schema.SchemaExportContentYangBodyWriter;
25 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.schema.SchemaExportContentYinBodyWriter;
26 import org.opendaylight.restconf.nb.rfc8040.services.wrapper.ServicesWrapper;
28 public class RestconfApplication extends Application {
29 private final SchemaContextHandler schemaContextHandler;
30 private final DOMMountPointServiceHandler mountPointServiceHandler;
31 private final ServicesWrapper servicesWrapper;
33 public RestconfApplication(SchemaContextHandler schemaContextHandler,
34 DOMMountPointServiceHandler mountPointServiceHandler, ServicesWrapper servicesWrapper) {
35 this.schemaContextHandler = schemaContextHandler;
36 this.mountPointServiceHandler = mountPointServiceHandler;
37 this.servicesWrapper = servicesWrapper;
41 public Set<Class<?>> getClasses() {
42 return ImmutableSet.<Class<?>>builder()
43 .add(NormalizedNodeJsonBodyWriter.class).add(NormalizedNodeXmlBodyWriter.class)
44 .add(SchemaExportContentYinBodyWriter.class).add(SchemaExportContentYangBodyWriter.class)
45 .add(PatchJsonBodyWriter.class).add(PatchXmlBodyWriter.class)
50 public Set<Object> getSingletons() {
51 final Set<Object> singletons = new HashSet<>();
52 singletons.add(servicesWrapper);
53 singletons.add(new JsonNormalizedNodeBodyReader(schemaContextHandler, mountPointServiceHandler));
54 singletons.add(new JsonToPatchBodyReader(schemaContextHandler, mountPointServiceHandler));
55 singletons.add(new XmlNormalizedNodeBodyReader(schemaContextHandler, mountPointServiceHandler));
56 singletons.add(new XmlToPatchBodyReader(schemaContextHandler, mountPointServiceHandler));