7e2a06be59f668b1109e7ce6e37d7d8dbe9b8e0b
[controller.git] / opendaylight / northbound / networkconfiguration / neutron / src / main / java / org / opendaylight / controller / networkconfig / neutron / northbound / NeutronNorthboundRSApplication.java
1 /*\r
2  * Copyright IBM Corporation, 2013.  All rights reserved.\r
3  *\r
4  * This program and the accompanying materials are made available under the\r
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
6  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
7  */\r
8 \r
9 package org.opendaylight.controller.networkconfig.neutron.northbound;\r
10 \r
11 import java.util.HashMap;\r
12 import java.util.HashSet;\r
13 import java.util.Map;\r
14 import java.util.Set;\r
15 import javax.ws.rs.core.Application;\r
16 import org.eclipse.persistence.jaxb.rs.MOXyJsonProvider;\r
17 \r
18 \r
19 /**\r
20  * This class is an instance of javax.ws.rs.core.Application and is used to return the classes\r
21  * that will be instantiated for JAXRS processing. This is necessary\r
22  * because package scanning in jersey doesn't yet work in OSGi environment.\r
23  *\r
24  */\r
25 public class NeutronNorthboundRSApplication extends Application {\r
26     @Override\r
27     public Set<Class<?>> getClasses() {\r
28         Set<Class<?>> classes = new HashSet<Class<?>>();\r
29 // northbound URIs\r
30         classes.add(NeutronNetworksNorthbound.class);\r
31         classes.add(NeutronSubnetsNorthbound.class);\r
32         classes.add(NeutronPortsNorthbound.class);\r
33         classes.add(NeutronRoutersNorthbound.class);\r
34         classes.add(NeutronFloatingIPsNorthbound.class);\r
35         return classes;\r
36     }\r
37 \r
38     @Override\r
39     public Set<Object> getSingletons() {\r
40         MOXyJsonProvider moxyJsonProvider = new MOXyJsonProvider();\r
41 \r
42         moxyJsonProvider.setAttributePrefix("@");\r
43         moxyJsonProvider.setFormattedOutput(true);\r
44         moxyJsonProvider.setIncludeRoot(false);\r
45         moxyJsonProvider.setMarshalEmptyCollections(true);\r
46         moxyJsonProvider.setValueWrapper("$");\r
47 \r
48         Map<String, String> namespacePrefixMapper = new HashMap<String, String>(1);\r
49         namespacePrefixMapper.put("router", "router");        // FIXME: fill in with XSD\r
50         namespacePrefixMapper.put("provider", "provider");    // FIXME: fill in with XSD\r
51         moxyJsonProvider.setNamespacePrefixMapper(namespacePrefixMapper);\r
52         moxyJsonProvider.setNamespaceSeparator(':');\r
53 \r
54         HashSet<Object> set = new HashSet<Object>(1);\r
55         set.add(moxyJsonProvider);\r
56         return set;\r
57     }\r
58 }\r