Bug 5527 - Re-implement ControllerContext.toInstanceIdentifier() method
[netconf.git] / restconf / sal-rest-connector / src / main / java / org / opendaylight / restconf / rest / 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.rest;
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.netconf.md.sal.rest.schema.SchemaExportContentYangBodyWriter;
15 import org.opendaylight.netconf.md.sal.rest.schema.SchemaExportContentYinBodyWriter;
16 import org.opendaylight.netconf.sal.rest.impl.NormalizedNodeJsonBodyWriter;
17 import org.opendaylight.netconf.sal.rest.impl.NormalizedNodeXmlBodyWriter;
18 import org.opendaylight.restconf.rest.api.schema.context.SchemaContextHandler;
19 import org.opendaylight.restconf.rest.handlers.api.DOMMountPointServiceHandler;
20 import org.opendaylight.restconf.rest.handlers.impl.DOMMountPointServiceHandlerImpl;
21 import org.opendaylight.restconf.rest.impl.schema.context.SchemaContextHandlerImpl;
22 import org.opendaylight.restconf.rest.impl.services.Draft11ServicesWrapperImpl;
23 import org.osgi.framework.FrameworkUtil;
24
25 public class RestconfApplication extends Application implements RestconfApplicationService {
26
27     private final SchemaContextHandler schemaContextHandler;
28     private final DOMMountPointServiceHandler domMountPointServiceHandler;
29
30     public RestconfApplication() {
31         this.schemaContextHandler = new SchemaContextHandlerImpl();
32         this.domMountPointServiceHandler = new DOMMountPointServiceHandlerImpl();
33         FrameworkUtil.getBundle(getClass()).getBundleContext().registerService(RestconfApplicationService.class.getName(),
34                 this, null);
35     }
36
37     @Override
38     public Set<Class<?>> getClasses() {
39         return ImmutableSet.<Class<?>> builder().add(NormalizedNodeJsonBodyWriter.class)
40                 .add(NormalizedNodeXmlBodyWriter.class).add(SchemaExportContentYinBodyWriter.class)
41                 .add(SchemaExportContentYangBodyWriter.class)
42                 .build();
43     }
44
45     @Override
46     public Set<Object> getSingletons() {
47         final Set<Object> singletons = new HashSet<>();
48         singletons.add(this.schemaContextHandler);
49         singletons.add(new Draft11ServicesWrapperImpl(this.schemaContextHandler, this.domMountPointServiceHandler));
50         return singletons;
51     }
52
53     @Override
54     public SchemaContextHandler getSchemaContextHandler() {
55         return this.schemaContextHandler;
56     }
57
58     @Override
59     public DOMMountPointServiceHandler getDOMMountPointServiceHandler() {
60         return this.domMountPointServiceHandler;
61     }
62 }