Initial push of Neutron interface
[controller.git] / opendaylight / northbound / networkconfiguration / neutron / src / main / java / org / opendaylight / controller / networkconfig / neutron / northbound / NeutronNorthboundRSApplication.java
diff --git a/opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronNorthboundRSApplication.java b/opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronNorthboundRSApplication.java
new file mode 100644 (file)
index 0000000..020104f
--- /dev/null
@@ -0,0 +1,63 @@
+/*\r
+ * Copyright IBM Corporation, 2013.  All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.controller.networkconfig.neutron.northbound;\r
+\r
+import java.util.HashMap;\r
+import java.util.HashSet;\r
+import java.util.Map;\r
+import java.util.Set;\r
+import javax.ws.rs.core.Application;\r
+import org.eclipse.persistence.jaxb.rs.MOXyJsonProvider;\r
+import org.opendaylight.controller.networkconfig.neutron.northbound.NeutronFloatingIPsNorthbound;\r
+import org.opendaylight.controller.networkconfig.neutron.northbound.NeutronNetworksNorthbound;\r
+import org.opendaylight.controller.networkconfig.neutron.northbound.NeutronPortsNorthbound;\r
+import org.opendaylight.controller.networkconfig.neutron.northbound.NeutronRoutersNorthbound;\r
+import org.opendaylight.controller.networkconfig.neutron.northbound.NeutronSubnetsNorthbound;\r
+\r
+\r
+/**\r
+ * This class is an instance of javax.ws.rs.core.Application and is used to return the classes\r
+ * that will be instantiated for JAXRS processing. This is necessary\r
+ * because package scanning in jersey doesn't yet work in OSGi environment.\r
+ *\r
+ */\r
+public class NeutronNorthboundRSApplication extends Application {\r
+    @Override\r
+    public Set<Class<?>> getClasses() {\r
+        Set<Class<?>> classes = new HashSet<Class<?>>();\r
+// northbound URIs\r
+        classes.add(NeutronNetworksNorthbound.class);\r
+        classes.add(NeutronSubnetsNorthbound.class);\r
+        classes.add(NeutronPortsNorthbound.class);\r
+        classes.add(NeutronRoutersNorthbound.class);\r
+        classes.add(NeutronFloatingIPsNorthbound.class);\r
+        return classes;\r
+    }\r
+\r
+    @Override\r
+    public Set<Object> getSingletons() {\r
+        MOXyJsonProvider moxyJsonProvider = new MOXyJsonProvider();\r
+\r
+        moxyJsonProvider.setAttributePrefix("@");\r
+        moxyJsonProvider.setFormattedOutput(true);\r
+        moxyJsonProvider.setIncludeRoot(false);\r
+        moxyJsonProvider.setMarshalEmptyCollections(true);\r
+        moxyJsonProvider.setValueWrapper("$");\r
+\r
+        Map<String, String> namespacePrefixMapper = new HashMap<String, String>(1);\r
+        namespacePrefixMapper.put("router", "router");        // FIXME: fill in with XSD\r
+        namespacePrefixMapper.put("provider", "provider");    // FIXME: fill in with XSD\r
+        moxyJsonProvider.setNamespacePrefixMapper(namespacePrefixMapper);\r
+        moxyJsonProvider.setNamespaceSeparator(':');\r
+\r
+        HashSet<Object> set = new HashSet<Object>(1);\r
+        set.add(moxyJsonProvider);\r
+        return set;\r
+    }\r
+}\r