Merge changes I7c36c88e,I7c5d97c7
[controller.git] / opendaylight / northbound / networkconfiguration / neutron / src / main / java / org / opendaylight / controller / networkconfig / neutron / northbound / NeutronNorthboundRSApplication.java
1 /*
2  * Copyright IBM Corporation, 2013.  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
9 package org.opendaylight.controller.networkconfig.neutron.northbound;
10
11 import java.util.HashMap;
12 import java.util.HashSet;
13 import java.util.Map;
14 import java.util.Set;
15 import javax.ws.rs.core.Application;
16 import org.eclipse.persistence.jaxb.rs.MOXyJsonProvider;
17
18
19 /**
20  * This class is an instance of javax.ws.rs.core.Application and is used to return the classes
21  * that will be instantiated for JAXRS processing. This is necessary
22  * because package scanning in jersey doesn't yet work in OSGi environment.
23  *
24  */
25 public class NeutronNorthboundRSApplication extends Application {
26     @Override
27     public Set<Class<?>> getClasses() {
28         Set<Class<?>> classes = new HashSet<Class<?>>();
29 // northbound URIs
30         classes.add(NeutronNetworksNorthbound.class);
31         classes.add(NeutronSubnetsNorthbound.class);
32         classes.add(NeutronPortsNorthbound.class);
33         classes.add(NeutronRoutersNorthbound.class);
34         classes.add(NeutronFloatingIPsNorthbound.class);
35         classes.add(NeutronSecurityGroupsNorthbound.class);
36         classes.add(NeutronSecurityRulesNorthbound.class);
37         return classes;
38     }
39
40     @Override
41     public Set<Object> getSingletons() {
42         MOXyJsonProvider moxyJsonProvider = new MOXyJsonProvider();
43
44         moxyJsonProvider.setAttributePrefix("@");
45         moxyJsonProvider.setFormattedOutput(true);
46         moxyJsonProvider.setIncludeRoot(false);
47         moxyJsonProvider.setMarshalEmptyCollections(true);
48         moxyJsonProvider.setValueWrapper("$");
49
50         Map<String, String> namespacePrefixMapper = new HashMap<String, String>(1);
51         namespacePrefixMapper.put("router", "router");        // FIXME: fill in with XSD
52         namespacePrefixMapper.put("provider", "provider");    // FIXME: fill in with XSD
53         moxyJsonProvider.setNamespacePrefixMapper(namespacePrefixMapper);
54         moxyJsonProvider.setNamespaceSeparator(':');
55
56         HashSet<Object> set = new HashSet<Object>(1);
57         set.add(moxyJsonProvider);
58         return set;
59     }
60 }