List of usage examples for org.springframework.oxm.xstream XStreamMarshaller XStreamMarshaller
XStreamMarshaller
From source file:org.oncoblocks.centromere.web.config.WebServicesConfig.java
@Override public void configureMessageConverters(List<HttpMessageConverter<?>> converters) { FilteringJackson2HttpMessageConverter jsonConverter = new FilteringJackson2HttpMessageConverter(); jsonConverter.setSupportedMediaTypes(ApiMediaTypes.getJsonMediaTypes()); converters.add(jsonConverter);//from ww w . ja va2 s . c o m MarshallingHttpMessageConverter xmlConverter = new MarshallingHttpMessageConverter(); xmlConverter.setSupportedMediaTypes(ApiMediaTypes.getXmlMediaTypes()); XStreamMarshaller xStreamMarshaller = new XStreamMarshaller(); xmlConverter.setMarshaller(xStreamMarshaller); xmlConverter.setUnmarshaller(xStreamMarshaller); converters.add(xmlConverter); FilteringTextMessageConverter filteringTextMessageConverter = new FilteringTextMessageConverter( new MediaType("text", "plain", Charset.forName("utf-8"))); filteringTextMessageConverter.setDelimiter("\t"); converters.add(filteringTextMessageConverter); }
From source file:org.springframework.social.soundcloud.api.impl.SoundCloudTemplate.java
@Override protected List<HttpMessageConverter<?>> getMessageConverters() { List<HttpMessageConverter<?>> messageConverters = super.getMessageConverters(); messageConverters.add(new ByteArrayHttpMessageConverter()); XStreamMarshaller marshaller = new XStreamMarshaller(); Map<Class<?>, String> implicitCollections = new HashMap<Class<?>, String>(); implicitCollections.put(TrackArray.class, "tracks"); marshaller.setImplicitCollections(implicitCollections); // marshaller.setConverters(converterMatchers); Map<String, Object> aliases = new HashMap<String, Object>(); aliases.put("playlist", XmlPlaylistUpdate.class.getName()); // aliases.put("playlist", PlaylistUpdate.class.getName()); aliases.put("track", TrackReference.class.getName()); Map<String, Class<?>> useAttributeFor = new HashMap<String, Class<?>>(); useAttributeFor.put("type", String.class); try {/* www . j a v a 2 s . c o m*/ marshaller.setAliases(aliases); marshaller.setUseAttributeFor(useAttributeFor); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } messageConverters.add(new MarshallingHttpMessageConverter(marshaller, marshaller)); return messageConverters; }
From source file:com.acc.xstream.XmlXStreamMarshallerFactory.java
protected XStreamMarshaller createMarshaller() { //final XStream localXStream = getXStream(); final StaxDriver driver = new StaxDriver() { @Override/*from ww w. j a v a 2 s . co m*/ public StaxWriter createStaxWriter(final XMLStreamWriter out) throws XMLStreamException { out.writeStartDocument("UTF-8", "1.0"); return createStaxWriter(out, false); } }; final XStreamMarshaller marshaller = new XStreamMarshaller() { @Override public XStream getXStream() { return XmlXStreamMarshallerFactory.this.getXStream(); } }; marshaller.setStreamDriver(driver); return marshaller; }
From source file:br.com.semanticwot.cd.conf.AppWebConfiguration.java
@Bean public CustomXMLViewResolver getMarshallingXmlViewResolver() { // Resolver para o formato XML //Jaxb2Marshaller marshaller = new Jaxb2Marshaller(); //marshaller.setClassesToBeBound(Product.class); XStreamMarshaller marshaller = new XStreamMarshaller(); HashMap<String, Class<?>> keys = new HashMap<String, Class<?>>(); //keys.put("product", Product.class); //keys.put("price", Price.class); marshaller.setAliases(keys);//from w w w.j a v a 2 s .com return new CustomXMLViewResolver(marshaller); }
From source file:gov.nyc.doitt.gis.geoclient.service.configuration.AppConfig.java
@Bean public XStreamMarshaller marshaller() { XStreamMarshaller marshaller = new XStreamMarshaller(); marshaller.setConverters(new ConverterMatcher[] { new MapConverter() }); Map<String, Class<?>> aliases = new HashMap<String, Class<?>>(); aliases.put("geosupportResponse", Map.class); aliases.put("version", Version.class); aliases.put("fileInfo", FileInfo.class); aliases.put("error", BadRequest.class); aliases.put("chunk", Chunk.class); aliases.put("token", Token.class); marshaller.setAliases(aliases);/*from w ww . j a v a 2 s . c om*/ marshaller.setAutodetectAnnotations(true); return marshaller; }
From source file:org.georchestra.security.Proxy.java
public void init() throws Exception { if (targets != null) { for (String url : targets.values()) { new URL(url); // test that it is a valid URL }//from w ww. j a va 2 s. c om } if (proxyPermissionsFile != null) { Closer closer = Closer.create(); try { final ClassLoader classLoader = Proxy.class.getClassLoader(); InputStream inStream = closer.register(classLoader.getResourceAsStream(proxyPermissionsFile)); Map<String, Class<?>> aliases = Maps.newHashMap(); aliases.put(Permissions.class.getSimpleName().toLowerCase(), Permissions.class); aliases.put(UriMatcher.class.getSimpleName().toLowerCase(), UriMatcher.class); XStreamMarshaller unmarshaller = new XStreamMarshaller(); unmarshaller.setAliasesByType(aliases); setProxyPermissions((Permissions) unmarshaller.unmarshal(new StreamSource(inStream))); } finally { closer.close(); } } // georchestra datadir autoconfiguration // dependency injection / properties setter() are made by Spring before // init() call if ((georchestraConfiguration != null) && (georchestraConfiguration.activated())) { logger.info("geOrchestra configuration detected, reconfiguration in progress ..."); Properties pTargets = georchestraConfiguration.loadCustomPropertiesFile("targets-mapping"); targets.clear(); for (String target : pTargets.stringPropertyNames()) { targets.put(target, pTargets.getProperty(target)); } logger.info("Done."); } }
From source file:org.emonocot.job.sitemap.StaxWriterTest.java
/** * @throws Exception/*from w w w.j av a 2 s .com*/ */ @Before public void setUp() throws Exception { writer = new StaxEventItemWriter(); writer.setResource(new FileSystemResource("target/test-outputs/StaxWriterTest.xml")); writer.setRootTagName("urlset"); XStreamMarshaller marshaller = new XStreamMarshaller(); Map<String, Object> aliases = new HashMap<String, Object>(); aliases.put("url", Url.class); marshaller.setAliases(aliases); writer.setMarshaller(marshaller); Map<String, String> attributes = new HashMap<String, String>(); attributes.put("xmlns", "http://www.sitemaps.org/schemas/sitemap"); writer.setRootElementAttributes(attributes); }