Java Code Examples for com.thoughtworks.xstream.XStream#addDefaultImplementation()

The following examples show how to use com.thoughtworks.xstream.XStream#addDefaultImplementation() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
public SerializerServiceBase() {
    serializationStates = new ThreadLocal<SerializationState>();
    evaluators = new ThreadLocal<PropertySerializabilityEvaluator>();

    xstream = new XStream(new ProxyAndStateAwareJavaReflectionProvider());
    xstream.registerConverter(new ProxyConverter(xstream.getMapper(), xstream.getReflectionProvider() ));
    try {
    	Class<?> objListProxyClass = Class.forName("org.apache.ojb.broker.core.proxy.ListProxyDefaultImpl");
        xstream.addDefaultImplementation(ArrayList.class, objListProxyClass);
        xstream.addDefaultImplementation(AutoPopulatingList.class, objListProxyClass);
    } catch ( Exception ex ) {
    	// Do nothing - this will blow if the OJB class does not exist, which it won't in some installs
    }
    xstream.registerConverter(new AutoPopulatingListConverter(xstream.getMapper()));
    xstream.registerConverter(new DateTimeConverter());
}
 
Example 2
public XmlObjectSerializerIgnoreMissingFieldsServiceImpl() {

        xstream = new XStream(new ProxyAwareJavaReflectionProvider()) {
            @Override
            protected MapperWrapper wrapMapper(MapperWrapper next) {
                return new MapperWrapper(next) {
                    @Override
                    public boolean shouldSerializeMember(Class definedIn,
                            String fieldName) {
                        if (definedIn == Object.class) {
                            return false;
                        }
                      return super.shouldSerializeMember(definedIn, fieldName);
                   }
               };
           }
       };

		xstream.registerConverter(new ProxyConverter(xstream.getMapper(), xstream.getReflectionProvider() ));
        try {
        	Class<?> objListProxyClass = Class.forName("org.apache.ojb.broker.core.proxy.ListProxyDefaultImpl");
            xstream.addDefaultImplementation(ArrayList.class, objListProxyClass);
        } catch ( Exception ex ) {
        	// Do nothing - this will blow if the OJB class does not exist, which it won't in some installs
        }
        xstream.registerConverter(new DateTimeConverter());
	}
 
Example 3
public XmlObjectSerializerServiceImpl() {
		xstream = new XStream(new ProxyAwareJavaReflectionProvider());

        // See http://xstream.codehaus.org/faq.html#Serialization_CGLIB
        // To use a newer version of XStream we may need to do something like this:
//        xstream = new XStream() {
//
//            @Override
//            public ReflectionProvider getReflectionProvider() {
//                return new ProxyAwareJavaReflectionProvider();
//            }
//
//            protected MapperWrapper wrapMapper(MapperWrapper next) {
//                return new CGLIBMapper(next);
//            }
//        };
//        xstream.registerConverter(new CGLIBEnhancedConverter(xstream.getMapper(), xstream.getReflectionProvider()));

		xstream.registerConverter(new ProxyConverter(xstream.getMapper(), xstream.getReflectionProvider() ));
        try {
        	Class<?> objListProxyClass = Class.forName("org.apache.ojb.broker.core.proxy.ListProxyDefaultImpl");
            xstream.addDefaultImplementation(ArrayList.class, objListProxyClass);
        } catch ( Exception ex ) {
        	// Do nothing - this will blow if the OJB class does not exist, which it won't in some installs
        }
        xstream.registerConverter(new DateTimeConverter());
	}
 
Example 4
private XStream prepareXStream(Class<? extends ApiResult> resultClass) {
	XmlApiReflectionProvider reflectionProvider = new XmlApiReflectionProvider(resultClass);
	XStream xStream = xStreamFactory.createXStream(reflectionProvider);
	
	xStream.processAnnotations(XmlApiResponseEnvelope.class);		
	xStream.addDefaultImplementation(resultClass, ApiResponse.class);
	xStream.processAnnotations(resultClass);

	return xStream;
}