import javax.xml.bind.JAXBException;
import javax.xml.bind.annotation.XmlRootElement;
-import org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider;
-import org.codehaus.jackson.map.DeserializationConfig;
import org.opendaylight.controller.northbound.bundlescanner.IBundleScanService;
+import org.opendaylight.controller.northbound.commons.exception.GenericExceptionMapper;
+import org.opendaylight.controller.northbound.commons.query.QueryContextProvider;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
+
/**
* Instance of javax.ws.rs.core.Application used to return the classes
* that will be instantiated for JAXRS processing. This hooks onto the
* bundle scanner service to provide JAXB classes to JAX-RS for prorcessing.
*/
-@SuppressWarnings("unchecked")
public class NorthboundApplication extends Application {
public static final String JAXRS_RESOURCES_MANIFEST_NAME = "Jaxrs-Resources";
public static final String JAXRS_EXCLUDES_MANIFEST_NAME = "Jaxrs-Exclude-Types";
public NorthboundApplication() {
_singletons = new HashSet<Object>();
_singletons.add(new ContextResolver<JAXBContext>() {
- JAXBContext jaxbContext = newJAXBContext();
+ JAXBContext jaxbContext;
@Override
- public JAXBContext getContext(Class<?> type) {
+ public synchronized JAXBContext getContext(Class<?> type) {
+ if (jaxbContext == null) {
+ jaxbContext = newJAXBContext();
+ }
return jaxbContext;
}
} );
_singletons.add(getJsonProvider());
_singletons.add(new JacksonJsonProcessingExceptionMapper());
+ _singletons.add(new QueryContextProvider());
+ _singletons.add(new GenericExceptionMapper());
}
////////////////////////////////////////////////////////////////
private static final JacksonJaxbJsonProvider getJsonProvider() {
JacksonJaxbJsonProvider jsonProvider = new JacksonJaxbJsonProvider();
- jsonProvider.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES,
+ jsonProvider.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,
false);
return jsonProvider;
}
}
private static final IBundleScanService lookupBundleScanner(BundleContext ctx) {
- ServiceReference svcRef = ctx.getServiceReference(IBundleScanService.class);
+ ServiceReference<?> svcRef = ctx.getServiceReference(IBundleScanService.class);
if (svcRef == null) {
throw new ServiceException("Unable to lookup IBundleScanService");
}