1 |
torben |
2517 |
package dk.thoerup.webservice;
|
2 |
|
|
|
3 |
|
|
import java.util.HashMap;
|
4 |
|
|
import java.util.Map;
|
5 |
|
|
|
6 |
|
|
import javax.ws.rs.ext.ContextResolver;
|
7 |
|
|
import javax.ws.rs.ext.Provider;
|
8 |
|
|
|
9 |
|
|
import org.glassfish.jersey.moxy.json.MoxyJsonConfig;
|
10 |
|
|
|
11 |
|
|
|
12 |
|
|
@Provider
|
13 |
|
|
public class JsonMoxyConfigurationContextResolver implements ContextResolver<MoxyJsonConfig> {
|
14 |
|
|
private final MoxyJsonConfig config;
|
15 |
|
|
|
16 |
|
|
public JsonMoxyConfigurationContextResolver() {
|
17 |
|
|
System.out.println("Configuring Moxy");
|
18 |
|
|
|
19 |
|
|
final Map<String, String> namespacePrefixMapper = new HashMap<String, String>();
|
20 |
|
|
namespacePrefixMapper.put("http://www.w3.org/2001/XMLSchema-instance", "xsi");
|
21 |
|
|
|
22 |
|
|
config = new MoxyJsonConfig()
|
23 |
torben |
2522 |
//.setNamespacePrefixMapper(namespacePrefixMapper)
|
24 |
|
|
//.setNamespaceSeparator(':')
|
25 |
torben |
2517 |
// .setAttributePrefix("")
|
26 |
|
|
// .setValueWrapper("value")
|
27 |
|
|
// .property(JAXBContextProperties.JSON_WRAPPER_AS_ARRAY_NAME, true)
|
28 |
torben |
2522 |
.setFormattedOutput(true)
|
29 |
torben |
2517 |
.setIncludeRoot(false)
|
30 |
|
|
.setMarshalEmptyCollections(false);
|
31 |
|
|
}
|
32 |
|
|
|
33 |
|
|
@Override
|
34 |
|
|
public MoxyJsonConfig getContext(Class<?> objectType) {
|
35 |
|
|
return config;
|
36 |
|
|
}
|
37 |
|
|
}
|