コード例 #1
0
 public XStreamSavingConverter() throws HibernateException {
   final XStream xstream = new XStream();
   defaultConv = xstream.getConverterLookup();
   this.ignoreFromSaving.add(PropertyDelta.class);
   this.ignoreFromSaving.add(SimplePropertyDelta.class);
   this.ignoreFromSaving.add(AssociationPropertyDelta.class);
   this.ignoreFromSaving.add(CollectionPropertyDelta.class);
 }
コード例 #2
0
 /** @return */
 private XStream initXStream(final Session session, final boolean nullifyPk) {
   final XStream xstream =
       new XStream() {
         @Override
         protected MapperWrapper wrapMapper(final MapperWrapper next) {
           return new HibernateMapper(new HibernateCollectionsMapper(next));
         }
       };
   // Converter für die Hibernate-Collections
   xstream.registerConverter(new HibernateCollectionConverter(xstream.getConverterLookup()));
   xstream.registerConverter(
       new HibernateProxyConverter(
           xstream.getMapper(), new PureJavaReflectionProvider(), xstream.getConverterLookup()),
       XStream.PRIORITY_VERY_HIGH);
   xstream.setMarshallingStrategy(
       new XStreamMarshallingStrategy(XStreamMarshallingStrategy.RELATIVE));
   init(xstream);
   return xstream;
 }
コード例 #3
0
  @Test
  public void testName() throws Exception {
    XStream xStream = new XStream();
    xStream.registerConverter(new ToSingleValue());

    Mapper mapper = xStream.getMapper();
    ReflectionProvider reflectionProvider = xStream.getReflectionProvider();
    ConverterLookup converterLookup = xStream.getConverterLookup();
    String valueField = null;
    ToAttributedValueConverter converter =
        new ToAttributedValueConverter(
            AClass.class, mapper, reflectionProvider, converterLookup, valueField);
    xStream.registerConverter(converter);
    System.out.println(xStream.toXML(new AClass()));
  }
コード例 #4
0
 public void marshal(Object value, HierarchicalStreamWriter writer, MarshallingContext context) {
   Converter converter =
       xstream.getConverterLookup().lookupConverterForType(initializer.getActualClass(value));
   initializer.initialize(value);
   converter.marshal(value, writer, context);
 }