/** * @deprecated As of 1.4.5 use {@link #JavaClassConverter(ClassLoaderReference)} */ public JavaClassConverter(ClassLoader classLoader) { this(new ClassLoaderReference(classLoader)); }
/** * Retrieve the ClassLoader XStream uses to load classes. * * @since 1.1.1 */ public ClassLoader getClassLoader() { return classLoaderReference.getReference(); }
/** * Change the ClassLoader XStream uses to load classes. Creating an XStream instance it will * register for all kind of classes and types of the current JDK, but not for any 3rd party * type. To ensure that all other types are loaded with your class loader, you should call * this method as early as possible - or consider to provide the class loader directly in * the constructor. * * @since 1.1.1 */ public void setClassLoader(ClassLoader classLoader) { classLoaderReference.setReference(classLoader); }
/** * Construct a DefaultMapper. * * @param classLoader the ClassLoader used by the XStream instance. * @deprecated As of 1.4.5 use {@link #DefaultMapper(ClassLoaderReference)} */ public DefaultMapper(ClassLoader classLoader) { this(new ClassLoaderReference(classLoader)); }
protected Class resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException { ClassLoader classLoader = classLoaderReference.getReference(); if (classLoader == null) { return super.resolveClass(desc); } else { return Class.forName(desc.getName(), false, classLoader); } }
public ClassLoaderReference(ClassLoader reference) { setReference(reference); }
/** * @deprecated As of 1.4.5 use {@link #CustomObjectInputStream(StreamCallback, ClassLoaderReference)} */ public CustomObjectInputStream(StreamCallback callback, ClassLoader classLoader) throws IOException, SecurityException { this(callback, new ClassLoaderReference(classLoader)); }
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); setupMappers(); int max = in.readInt(); arguments = new Object[max+2]; for (int i = 0; i < max; i++ ) { arguments[i] = in.readObject(); if (arguments[i] instanceof ClassLoaderReference) { arguments[max+1] = ((ClassLoaderReference)arguments[i]).getReference(); } } arguments[max] = new JVM(); }
/** * Change the ClassLoader XStream uses to load classes. Creating an XStream instance it will * register for all kind of classes and types of the current JDK, but not for any 3rd party * type. To ensure that all other types are loaded with your class loader, you should call * this method as early as possible - or consider to provide the class loader directly in * the constructor. * * @since 1.1.1 */ public void setClassLoader(ClassLoader classLoader) { classLoaderReference.setReference(classLoader); }
/** * @deprecated As of 1.4.5 use {@link #SerializableConverter(Mapper, ReflectionProvider, ClassLoaderReference)} */ public SerializableConverter(Mapper mapper, ReflectionProvider reflectionProvider, ClassLoader classLoader) { this(mapper, reflectionProvider, new ClassLoaderReference(classLoader)); }
private Mapper buildMapperDynamically(String className, Class[] constructorParamTypes, Object[] constructorParamValues) { try { Class type = Class.forName(className, false, classLoaderReference.getReference()); Constructor constructor = type.getConstructor(constructorParamTypes); return (Mapper)constructor.newInstance(constructorParamValues); } catch (Exception e) { throw new com.thoughtworks.xstream.InitializationException( "Could not instantiate mapper : " + className, e); } catch (LinkageError e) { throw new com.thoughtworks.xstream.InitializationException( "Could not instantiate mapper : " + className, e); } }
/** * Change the ClassLoader XStream uses to load classes. Creating an XStream instance it will register for all kind * of classes and types of the current JDK, but not for any 3rd party type. To ensure that all other types are * loaded with your class loader, you should call this method as early as possible - or consider to provide the * class loader directly in the constructor. * * @since 1.1.1 */ public void setClassLoader(final ClassLoader classLoader) { classLoaderReference.setReference(classLoader); }
/** * @deprecated As of 1.4.5 use {@link #JavaMethodConverter(ClassLoaderReference)} */ public JavaMethodConverter(ClassLoader classLoader) { this(new ClassLoaderReference(classLoader)); }
private void registerConverterDynamically(String className, int priority, Class[] constructorParamTypes, Object[] constructorParamValues) { try { Class type = Class.forName(className, false, classLoaderReference.getReference()); Constructor constructor = type.getConstructor(constructorParamTypes); Object instance = constructor.newInstance(constructorParamValues); if (instance instanceof Converter) { registerConverter((Converter)instance, priority); } else if (instance instanceof SingleValueConverter) { registerConverter((SingleValueConverter)instance, priority); } } catch (Exception e) { throw new com.thoughtworks.xstream.InitializationException( "Could not instantiate converter : " + className, e); } catch (LinkageError e) { throw new com.thoughtworks.xstream.InitializationException( "Could not instantiate converter : " + className, e); } }
/** * Change the ClassLoader XStream uses to load classes. Creating an XStream instance it will * register for all kind of classes and types of the current JDK, but not for any 3rd party * type. To ensure that all other types are loaded with your class loader, you should call * this method as early as possible - or consider to provide the class loader directly in * the constructor. * * @since 1.1.1 */ public void setClassLoader(ClassLoader classLoader) { classLoaderReference.setReference(classLoader); }
/** * @deprecated As of 1.4.5 use {@link #ExternalizableConverter(Mapper, ClassLoaderReference)} */ public ExternalizableConverter(Mapper mapper, ClassLoader classLoader) { this(mapper, new ClassLoaderReference(classLoader)); }
public Class realClass(String elementName) { Class resultingClass = Primitives.primitiveType(elementName); if( resultingClass != null ){ return resultingClass; } try { boolean initialize = true; final ClassLoader classLoader; if (elementName.startsWith(XSTREAM_PACKAGE_ROOT)) { classLoader = DefaultMapper.class.getClassLoader(); } else { classLoader = classLoaderReference.getReference(); initialize = elementName.charAt(0) == '['; } return Class.forName(elementName, initialize, classLoader); } catch (ClassNotFoundException e) { throw new CannotResolveClassException(elementName); } }
/** * Change the ClassLoader XStream uses to load classes. Creating an XStream instance it will * register for all kind of classes and types of the current JDK, but not for any 3rd party * type. To ensure that all other types are loaded with your class loader, you should call * this method as early as possible - or consider to provide the class loader directly in * the constructor. * * @since 1.1.1 */ public void setClassLoader(ClassLoader classLoader) { classLoaderReference.setReference(classLoader); }
/** * @deprecated As of 1.4.5 use {@link #DynamicProxyConverter(Mapper, ClassLoaderReference)} */ public DynamicProxyConverter(Mapper mapper, ClassLoader classLoader) { this(mapper,new ClassLoaderReference(classLoader)); }
/** * Construct an AnnotationMapper. * * @param wrapped the next {@link Mapper} in the chain * @since 1.4.5 */ public AnnotationMapper( final Mapper wrapped, final ConverterRegistry converterRegistry, final ConverterLookup converterLookup, final ClassLoaderReference classLoaderReference, final ReflectionProvider reflectionProvider) { super(wrapped); this.converterRegistry = converterRegistry; annotatedTypes.add(Object.class); setupMappers(); locked = true; final ClassLoader classLoader = classLoaderReference.getReference(); arguments = new Object[]{ this, classLoaderReference, reflectionProvider, converterLookup, new JVM(), classLoader != null ? classLoader : new TypedNull(ClassLoader.class)}; }