Skip to content

Commit

Permalink
Add jettison provider
Browse files Browse the repository at this point in the history
  • Loading branch information
jimma authored and asoldano committed Nov 20, 2017
1 parent ecba9dc commit a327907
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
8 changes: 8 additions & 0 deletions modules/server/pom.xml
Expand Up @@ -72,6 +72,14 @@
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-json-basic</artifactId>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-extension-providers</artifactId>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-management</artifactId>
Expand Down
Expand Up @@ -32,11 +32,13 @@

import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
import org.apache.cxf.endpoint.Server;
import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
import org.apache.cxf.jaxrs.impl.RuntimeDelegateImpl;
import org.apache.cxf.jaxrs.model.ApplicationInfo;
import org.apache.cxf.jaxrs.model.ProviderInfo;
import org.apache.cxf.jaxrs.provider.ProviderFactory;
import org.apache.cxf.jaxrs.provider.json.JSONProvider;
import org.apache.cxf.jaxrs.utils.ResourceUtils;
import org.apache.cxf.transport.http.HttpDestinationFactory;
import org.apache.cxf.transport.servlet.ServletDestinationFactory;
Expand Down Expand Up @@ -66,7 +68,7 @@ public void start(final Deployment dep)
//(i.e. no server side integration contribution in it)
//TODO!!! think about this... is it still fine for the default bus to be created like this?
JBossWSBusFactory.getDefaultBus(Provider.provider().getClass().getClassLoader());
}
}
startDeploymentBus(dep);
}

Expand Down Expand Up @@ -94,6 +96,8 @@ private void startDeploymentBus(final Deployment dep)
Bus bus = JBossWSBusFactory.getClassLoaderDefaultBus(dep.getClassLoader());
//Force servlet transport to prevent CXF from using Jetty / http server or other transports
bus.setExtension(new ServletDestinationFactory(), HttpDestinationFactory.class);
//Don't add the default cxf JSONProvider
bus.setProperty("skip.default.json.provider.registration", true);
JAXRSDeploymentMetadata md = dep.getAttachment(JAXRSDeploymentMetadata.class);

List<Class<?>> applications = md.getScannedApplicationClasses();
Expand Down Expand Up @@ -139,8 +143,15 @@ private void startDeploymentBus(final Deployment dep)
}
bean.setProviders(providers);
}

//Add default Jettison provider
@SuppressWarnings("rawtypes")
JSONProvider jsonProvider = new JSONProvider();
jsonProvider.setDropRootElement(true);
bean.setProvider(jsonProvider);
//TODO: Add jackson provider
bean.create();


}

dep.addAttachment(Bus.class, bus);
Expand Down

0 comments on commit a327907

Please sign in to comment.