private static synchronized MarshallerBuilder getMarshallerBuilder() { ServiceLoader<MarshallerBuilder> builders = ServiceLoader.load(MarshallerBuilder.class); Iterator<MarshallerBuilder> it = builders.iterator(); if (it.hasNext()) { MarshallerBuilder marshallerBuilder = it.next(); logger.debug("Found custom marshaller builder {} that is going to be used instead of the default", marshallerBuilder); return marshallerBuilder; } return new BaseMarshallerBuilder(); } }
@Override public Marshaller build(Set<Class<?>> classes, MarshallingFormat format, ClassLoader classLoader) { if (format.equals(MarshallingFormat.XSTREAM)) { return new XStreamMarshaller(classes, classLoader) { @Override protected void buildMarshaller(Set<Class<?>> classes, ClassLoader classLoader) { xstream = XStreamUtils.createNonTrustingXStream(new PureJavaReflectionProvider(), new DomDriver("UTF-8", new XmlFriendlyNameCoder("_-", "_"))); xstream.addPermission(new WildcardTypePermission(new String[]{"org.kie.server.api.**"})); String[] voidDeny = {"void.class", "Void.class"}; xstream.denyTypes(voidDeny); } }; } return super.build(classes, format, classLoader); } }