Java Code Examples for com.thoughtworks.xstream.io.HierarchicalStreamDriver

The following examples show how to use com.thoughtworks.xstream.io.HierarchicalStreamDriver. 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
Source Project: lams   Source File: XStreamer.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Deserialize a self-contained XStream with object from an XML Reader.
 * 
 * @param driver the implementation to use
 * @param xml the {@link Reader} providing the XML data
 * @param permissions the permissions to use (ensure that they include the defaults)
 * @throws IOException if an error occurs reading from the Reader.
 * @throws ClassNotFoundException if a class in the XML stream cannot be found
 * @throws com.thoughtworks.xstream.XStreamException if the object cannot be deserialized
 * @since 1.4.7
 */
public Object fromXML(final HierarchicalStreamDriver driver, final Reader xml, final TypePermission[] permissions)
        throws IOException, ClassNotFoundException {
    final XStream outer = new XStream(driver);
    XStream.setupDefaultSecurity(outer);
    for(int i = 0; i < permissions.length; ++i) {
        outer.addPermission(permissions[i]);
    }
    final HierarchicalStreamReader reader = driver.createReader(xml);
    final ObjectInputStream configIn = outer.createObjectInputStream(reader);
    try {
        final XStream configured = (XStream)configIn.readObject();
        final ObjectInputStream in = configured.createObjectInputStream(reader);
        try {
            return in.readObject();
        } finally {
            in.close();
        }
    } finally {
        configIn.close();
    }
}
 
Example 2
Source Project: lams   Source File: XStream.java    License: GNU General Public License v2.0 5 votes vote down vote up
private XStream(
        ReflectionProvider reflectionProvider, HierarchicalStreamDriver driver, ClassLoaderReference classLoader,
        Mapper mapper, final DefaultConverterLookup defaultConverterLookup) {
    this(reflectionProvider, driver, classLoader, mapper, new ConverterLookup() {
        public Converter lookupConverterForType(Class type) {
            return defaultConverterLookup.lookupConverterForType(type);
        }
    }, new ConverterRegistry() {
        public void registerConverter(Converter converter, int priority) {
            defaultConverterLookup.registerConverter(converter, priority);
        }
    });
}
 
Example 3
Source Project: cuba   Source File: CubaXStream.java    License: Apache License 2.0 5 votes vote down vote up
protected CubaXStream(
        ReflectionProvider reflectionProvider, HierarchicalStreamDriver driver, ClassLoaderReference classLoader,
        Mapper mapper, final CubaXStreamConverterLookup converterLookup) {
    super(reflectionProvider, driver, classLoader, mapper,
            converterLookup::lookupConverterForType,
            converterLookup::registerConverter);
}
 
Example 4
Source Project: saros   Source File: XStreamFactory.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns an <code>XStream</code> object with an set-up security framework. The passed <code>
 * HierarchicalStreamDriver</code> will be used when instantiating the <code>XStream</code> object
 *
 * @return an <code>XStream</code> object with an set-up security framework
 */
public static XStream getSecureXStream(HierarchicalStreamDriver hierarchicalStreamDriver) {
  XStream xStream = new XStream(hierarchicalStreamDriver);

  setUpSecurityFramework(xStream);

  return xStream;
}
 
Example 5
Source Project: vraptor4   Source File: VRaptorXStream.java    License: Apache License 2.0 5 votes vote down vote up
public VRaptorXStream(TypeNameExtractor extractor, HierarchicalStreamDriver hierarchicalStreamDriver, 
		Serializee serializee, ReflectionProvider reflectionProvider) {
	super(new PureJavaReflectionProvider(),hierarchicalStreamDriver);
	this.extractor = extractor;
	this.serializee = serializee;
	this.reflectionProvider = reflectionProvider;
}
 
Example 6
Source Project: spring-analysis-note   Source File: XStreamMarshaller.java    License: MIT License 4 votes vote down vote up
private HierarchicalStreamDriver getDefaultDriver() {
	if (this.defaultDriver == null) {
		this.defaultDriver = new XppDriver();
	}
	return this.defaultDriver;
}
 
Example 7
Source Project: kogito-runtimes   Source File: XStreamUtils.java    License: Apache License 2.0 4 votes vote down vote up
public static XStream createTrustingXStream(HierarchicalStreamDriver hierarchicalStreamDriver) {
    return internalCreateTrustingXStream(new XStream(hierarchicalStreamDriver));
}
 
Example 8
Source Project: kogito-runtimes   Source File: XStreamUtils.java    License: Apache License 2.0 4 votes vote down vote up
public static XStream createTrustingXStream(HierarchicalStreamDriver hierarchicalStreamDriver, ClassLoader classLoader) {
    return internalCreateTrustingXStream(new XStream((ReflectionProvider)null, hierarchicalStreamDriver, new ClassLoaderReference(classLoader)));
}
 
Example 9
Source Project: kogito-runtimes   Source File: XStreamUtils.java    License: Apache License 2.0 4 votes vote down vote up
public static XStream createTrustingXStream(ReflectionProvider reflectionProvider, HierarchicalStreamDriver hierarchicalStreamDriver) {
    return internalCreateTrustingXStream(new XStream(reflectionProvider, hierarchicalStreamDriver));
}
 
Example 10
Source Project: kogito-runtimes   Source File: XStreamUtils.java    License: Apache License 2.0 4 votes vote down vote up
public static XStream createNonTrustingXStream(HierarchicalStreamDriver hierarchicalStreamDriver) {
    return internalCreateNonTrustingXStream(new XStream(hierarchicalStreamDriver));
}
 
Example 11
Source Project: kogito-runtimes   Source File: XStreamUtils.java    License: Apache License 2.0 4 votes vote down vote up
public static XStream createNonTrustingXStream(HierarchicalStreamDriver hierarchicalStreamDriver, ClassLoader classLoader) {
    return internalCreateNonTrustingXStream(new XStream((ReflectionProvider)null, hierarchicalStreamDriver, new ClassLoaderReference(classLoader)));
}
 
Example 12
Source Project: kogito-runtimes   Source File: XStreamUtils.java    License: Apache License 2.0 4 votes vote down vote up
public static XStream createNonTrustingXStream(ReflectionProvider reflectionProvider, HierarchicalStreamDriver hierarchicalStreamDriver) {
    return internalCreateNonTrustingXStream(new XStream(reflectionProvider, hierarchicalStreamDriver));
}
 
Example 13
Source Project: java-technology-stack   Source File: XStreamMarshaller.java    License: MIT License 4 votes vote down vote up
private HierarchicalStreamDriver getDefaultDriver() {
	if (this.defaultDriver == null) {
		this.defaultDriver = new XppDriver();
	}
	return this.defaultDriver;
}
 
Example 14
Source Project: openmrs-module-initializer   Source File: InitializerSerializer.java    License: MIT License 4 votes vote down vote up
public InitializerSerializer(HierarchicalStreamDriver hierarchicalStreamDriver) {
	super(hierarchicalStreamDriver);
}
 
Example 15
Source Project: lams   Source File: XStream.java    License: GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructs an XStream with a special {@link HierarchicalStreamDriver},
 * {@link ReflectionProvider}, a prepared {@link Mapper} chain, the
 * {@link ClassLoaderReference} and an own {@link ConverterLookup} and
 * {@link ConverterRegistry}.
 * <p>
 * The ClassLoaderReference should also be used for the Mapper chain. The ConverterLookup
 * should access the ConverterRegistry if you intent to register {@link Converter} instances
 * with XStream facade or you are using annotations.
 * </p>
 * 
 * @param reflectionProvider the reflection provider to use or <em>null</em> for best
 *            matching Provider
 * @param driver the driver instance
 * @param classLoaderReference the reference to the {@link ClassLoader} to use
 * @param mapper the instance with the {@link Mapper} chain or <em>null</em> for the default
 *            chain
 * @param converterLookup the instance that is used to lookup the converters
 * @param converterRegistry an instance to manage the converter instances or <em>null</em>
 *            to prevent any further registry (including annotations)
 * @throws InitializationException in case of an initialization problem
 * @since 1.4.5
 */
public XStream(
    ReflectionProvider reflectionProvider, HierarchicalStreamDriver driver,
    ClassLoaderReference classLoaderReference, Mapper mapper, ConverterLookup converterLookup,
    ConverterRegistry converterRegistry) {
    if (reflectionProvider == null) {
        reflectionProvider = JVM.newReflectionProvider();
    }
    this.reflectionProvider = reflectionProvider;
    this.hierarchicalStreamDriver = driver;
    this.classLoaderReference = classLoaderReference;
    this.converterLookup = converterLookup;
    this.converterRegistry = converterRegistry;
    this.mapper = mapper == null ? buildMapper() : mapper;

    setupMappers();
    setupSecurity();
    setupAliases();
    setupDefaultImplementations();
    setupConverters();
    setupImmutableTypes();
    setMode(XPATH_RELATIVE_REFERENCES);
}
 
Example 16
Source Project: spring4-understanding   Source File: XStreamMarshaller.java    License: Apache License 2.0 4 votes vote down vote up
private HierarchicalStreamDriver getDefaultDriver() {
	if (this.defaultDriver == null) {
		this.defaultDriver = new XppDriver();
	}
	return this.defaultDriver;
}
 
Example 17
Source Project: lams   Source File: XStream.java    License: GNU General Public License v2.0 3 votes vote down vote up
/**
 * Constructs an XStream with a special {@link HierarchicalStreamDriver},
 * {@link ReflectionProvider}, a prepared {@link Mapper} chain and the {@link ClassLoader}
 * to use.
 * 
 * @param reflectionProvider the reflection provider to use or <em>null</em> for best
 *            matching Provider
 * @param driver the driver instance
 * @param classLoader the {@link ClassLoader} to use
 * @param mapper the instance with the {@link Mapper} chain or <em>null</em> for the default
 *            chain
 * @throws InitializationException in case of an initialization problem
 * @since 1.3
 * @deprecated As of 1.4.5 use
 *             {@link #XStream(ReflectionProvider, HierarchicalStreamDriver, ClassLoaderReference, Mapper)}
 */
public XStream(
    ReflectionProvider reflectionProvider, HierarchicalStreamDriver driver,
    ClassLoader classLoader, Mapper mapper) {
    this(
        reflectionProvider, driver, new ClassLoaderReference(classLoader), mapper, new DefaultConverterLookup());
}
 
Example 18
Source Project: lams   Source File: XStream.java    License: GNU General Public License v2.0 3 votes vote down vote up
/**
 * Constructs an XStream with a special {@link HierarchicalStreamDriver},
 * {@link ReflectionProvider}, a prepared {@link Mapper} chain and the
 * {@link ClassLoaderReference}.
 * <p>
 * The {@link ClassLoaderReference} should also be used for the {@link Mapper} chain.
 * </p>
 * 
 * @param reflectionProvider the reflection provider to use or <em>null</em> for best
 *            matching Provider
 * @param driver the driver instance
 * @param classLoaderReference the reference to the {@link ClassLoader} to use
 * @param mapper the instance with the {@link Mapper} chain or <em>null</em> for the default
 *            chain
 * @throws InitializationException in case of an initialization problem
 * @since 1.4.5
 */
public XStream(
    ReflectionProvider reflectionProvider, HierarchicalStreamDriver driver,
    ClassLoaderReference classLoaderReference, Mapper mapper) {
    this(
        reflectionProvider, driver, classLoaderReference, mapper, new DefaultConverterLookup());
}
 
Example 19
Source Project: lams   Source File: XStream.java    License: GNU General Public License v2.0 3 votes vote down vote up
/**
 * Constructs an XStream with a special {@link HierarchicalStreamDriver},
 * {@link ReflectionProvider}, a prepared {@link Mapper} chain, the
 * {@link ClassLoaderReference} and an own {@link ConverterLookup} and
 * {@link ConverterRegistry}.
 * 
 * @param reflectionProvider the reflection provider to use or <em>null</em> for best
 *            matching Provider
 * @param driver the driver instance
 * @param classLoader the {@link ClassLoader} to use
 * @param mapper the instance with the {@link Mapper} chain or <em>null</em> for the default
 *            chain
 * @param converterLookup the instance that is used to lookup the converters
 * @param converterRegistry an instance to manage the converter instances
 * @throws InitializationException in case of an initialization problem
 * @since 1.3
 * @deprecated As of 1.4.5 use
 *             {@link #XStream(ReflectionProvider, HierarchicalStreamDriver, ClassLoaderReference, Mapper, ConverterLookup, ConverterRegistry)}
 */
public XStream(
    ReflectionProvider reflectionProvider, HierarchicalStreamDriver driver,
    ClassLoader classLoader, Mapper mapper, ConverterLookup converterLookup,
    ConverterRegistry converterRegistry) {
    this(reflectionProvider, driver, new ClassLoaderReference(classLoader), mapper, converterLookup, converterRegistry);
}
 
Example 20
Source Project: spring-analysis-note   Source File: XStreamMarshaller.java    License: MIT License 2 votes vote down vote up
/**
 * Set a XStream {@link HierarchicalStreamDriver} to be used for readers and writers.
 * <p>As of Spring 4.0, this stream driver will also be passed to the {@link XStream}
 * constructor and therefore used by streaming-related native API methods themselves.
 */
public void setStreamDriver(HierarchicalStreamDriver streamDriver) {
	this.streamDriver = streamDriver;
	this.defaultDriver = streamDriver;
}
 
Example 21
Source Project: java-technology-stack   Source File: XStreamMarshaller.java    License: MIT License 2 votes vote down vote up
/**
 * Set a XStream {@link HierarchicalStreamDriver} to be used for readers and writers.
 * <p>As of Spring 4.0, this stream driver will also be passed to the {@link XStream}
 * constructor and therefore used by streaming-related native API methods themselves.
 */
public void setStreamDriver(HierarchicalStreamDriver streamDriver) {
	this.streamDriver = streamDriver;
	this.defaultDriver = streamDriver;
}
 
Example 22
Source Project: lams   Source File: XStream.java    License: GNU General Public License v2.0 2 votes vote down vote up
/**
 * Constructs an XStream with a special {@link HierarchicalStreamDriver}.
 * <p>
 * The instance will tries to determine the best match for the {@link ReflectionProvider} on
 * its own.
 * </p>
 *
 * @param hierarchicalStreamDriver the driver instance
 * @throws InitializationException in case of an initialization problem
 */
public XStream(HierarchicalStreamDriver hierarchicalStreamDriver) {
    this(null, (Mapper)null, hierarchicalStreamDriver);
}
 
Example 23
Source Project: lams   Source File: XStream.java    License: GNU General Public License v2.0 2 votes vote down vote up
/**
 * Constructs an XStream with a special {@link HierarchicalStreamDriver} and
 * {@link ReflectionProvider}.
 * 
 * @param reflectionProvider the reflection provider to use or <em>null</em> for best
 *            matching Provider
 * @param hierarchicalStreamDriver the driver instance
 * @throws InitializationException in case of an initialization problem
 */
public XStream(
    ReflectionProvider reflectionProvider, HierarchicalStreamDriver hierarchicalStreamDriver) {
    this(reflectionProvider, (Mapper)null, hierarchicalStreamDriver);
}
 
Example 24
Source Project: lams   Source File: XStream.java    License: GNU General Public License v2.0 2 votes vote down vote up
/**
 * Constructs an XStream with a special {@link HierarchicalStreamDriver},
 * {@link ReflectionProvider} and a prepared {@link Mapper} chain.
 * 
 * @param reflectionProvider the reflection provider to use or <em>null</em> for best
 *            matching Provider
 * @param mapper the instance with the {@link Mapper} chain or <em>null</em> for the default
 *            chain
 * @param driver the driver instance
 * @throws InitializationException in case of an initialization problem
 * @deprecated As of 1.3, use
 *             {@link #XStream(ReflectionProvider, HierarchicalStreamDriver, ClassLoader, Mapper)}
 *             instead
 */
public XStream(
    ReflectionProvider reflectionProvider, Mapper mapper, HierarchicalStreamDriver driver) {
    this(reflectionProvider, driver, new CompositeClassLoader(), mapper);
}
 
Example 25
Source Project: lams   Source File: XStream.java    License: GNU General Public License v2.0 2 votes vote down vote up
/**
 * Constructs an XStream with a special {@link HierarchicalStreamDriver},
 * {@link ReflectionProvider} and a {@link ClassLoaderReference}.
 * 
 * @param reflectionProvider the reflection provider to use or <em>null</em> for best
 *            matching Provider
 * @param driver the driver instance
 * @param classLoaderReference the reference to the {@link ClassLoader} to use
 * @throws InitializationException in case of an initialization problem
 * @since 1.4.5
 */
public XStream(
    ReflectionProvider reflectionProvider, HierarchicalStreamDriver driver,
    ClassLoaderReference classLoaderReference) {
    this(reflectionProvider, driver, classLoaderReference, null);
}
 
Example 26
Source Project: lams   Source File: XStream.java    License: GNU General Public License v2.0 2 votes vote down vote up
/**
 * Constructs an XStream with a special {@link HierarchicalStreamDriver},
 * {@link ReflectionProvider} and the {@link ClassLoader} to use.
 * 
 * @throws InitializationException in case of an initialization problem
 * @since 1.3
 * @deprecated As of 1.4.5 use
 *             {@link #XStream(ReflectionProvider, HierarchicalStreamDriver, ClassLoaderReference)}
 */
public XStream(
    ReflectionProvider reflectionProvider, HierarchicalStreamDriver driver,
    ClassLoader classLoader) {
    this(reflectionProvider, driver, classLoader, null);
}
 
Example 27
Source Project: lams   Source File: XStreamer.java    License: GNU General Public License v2.0 2 votes vote down vote up
/**
 * Deserialize a self-contained XStream with object from an XML Reader.
 *
 * @param driver the implementation to use
 * @param xml the {@link Reader} providing the XML data
 * @throws IOException if an error occurs reading from the Reader.
 * @throws ClassNotFoundException if a class in the XML stream cannot be found
 * @throws com.thoughtworks.xstream.XStreamException if the object cannot be deserialized
 * @since 1.2
 */
public Object fromXML(final HierarchicalStreamDriver driver, final Reader xml)
        throws IOException, ClassNotFoundException {
    return fromXML(driver, xml, PERMISSIONS);
}
 
Example 28
Source Project: spring4-understanding   Source File: XStreamMarshaller.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Set a XStream {@link HierarchicalStreamDriver} to be used for readers and writers.
 * <p>As of Spring 4.0, this stream driver will also be passed to the {@link XStream}
 * constructor and therefore used by streaming-related native API methods themselves.
 */
public void setStreamDriver(HierarchicalStreamDriver streamDriver) {
	this.streamDriver = streamDriver;
	this.defaultDriver = streamDriver;
}