本文整理汇总了Java中com.thoughtworks.xstream.XStream.setClassLoader方法的典型用法代码示例。如果您正苦于以下问题:Java XStream.setClassLoader方法的具体用法?Java XStream.setClassLoader怎么用?Java XStream.setClassLoader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.thoughtworks.xstream.XStream
的用法示例。
在下文中一共展示了XStream.setClassLoader方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCloner
import com.thoughtworks.xstream.XStream; //导入方法依赖的package包/类
@Override
public <T> Function<T, T> createCloner(ClassLoader classLoader)
{
final XStream xstream = new XStream() {
@Override
protected MapperWrapper wrapMapper(MapperWrapper next) {
return new HibernateMapper(next);
}
};
xstream.setClassLoader(classLoader);
xstream.autodetectAnnotations(true);
xstream.registerConverter(new HibernateProxyConverter());
xstream.registerConverter(new HibernatePersistentCollectionConverter(xstream.getMapper()));
xstream.registerConverter(new HibernatePersistentMapConverter(xstream.getMapper()));
xstream.registerConverter(new HibernatePersistentSortedMapConverter(xstream.getMapper()));
xstream.registerConverter(new HibernatePersistentSortedSetConverter(xstream.getMapper()));
return t -> (T) xstream.fromXML(xstream.toXML(t));
}
示例2: XStreamDataConverter
import com.thoughtworks.xstream.XStream; //导入方法依赖的package包/类
public XStreamDataConverter(Class<?> klass)
{
xstream = new XStream();
ClassLoader cl = xstream.getClassLoader();
// I think they always are
if( cl instanceof CompositeClassLoader )
{
((CompositeClassLoader) cl).add(klass.getClassLoader());
}
else
{
CompositeClassLoader comp = new CompositeClassLoader();
comp.add(cl);
comp.add(klass.getClassLoader());
xstream.setClassLoader(comp);
}
}
示例3: validation
import com.thoughtworks.xstream.XStream; //导入方法依赖的package包/类
@Override
public void validation() throws EditorException
{
List<SummarySectionsConfig> sections = displayNodeList.save();
if( sections == null || sections.size() == 0 )
{
throw new EditorException(
getString("itemsummarytemplatetab.validation.nodisplaynodes"));
}
else
{
for( SummarySectionsConfig section : sections )
{
LanguageBundle bundleTitle = section.getBundleTitle();
if( bundleTitle == null )
{
throw new EditorException(
getString("itemsummarytemplatetab.validation.emptytitle"));
}
if( section.getValue().equals("displayNodes") )
{
xstream = new XStream();
xstream.setClassLoader(getClass().getClassLoader());
Object fromXML = xstream.fromXML(section.getConfiguration());
List<DisplayNode> displayNodes = (List<DisplayNode>) fromXML;
for( DisplayNode displayNode : displayNodes )
{
LanguageBundle titleBundle = displayNode.getTitle();
String node = displayNode.getNode();
String type = displayNode.getType();
boolean notTheCaseTheyAllEmpty = !(titleBundle == null && Check.isEmpty(node) && Check
.isEmpty(type));
boolean incomplete = titleBundle == null || Check.isEmpty(node) || Check.isEmpty(type);
// If everything's empty we ignore it (it may be being
// deleted) but it any of the 3 critical values is
// present we require that they all are
if( notTheCaseTheyAllEmpty && incomplete )
{
throw new EditorException(
CurrentLocale
.get("com.tle.admin.collection.tool.itemsummarytemplatetab.validation.incomplete"));
}
}
}
}
}
}
示例4: DisplayNodesConfig
import com.thoughtworks.xstream.XStream; //导入方法依赖的package包/类
public DisplayNodesConfig()
{
xstream = new XStream();
xstream.setClassLoader(getClass().getClassLoader());
}
示例5: importer
import com.thoughtworks.xstream.XStream; //导入方法依赖的package包/类
private FileWorker importer()
{
return new AbstractFileWorker<Control>(null, "wizard/controlImport") //$NON-NLS-1$
{
@Override
public Control construct() throws Exception
{
final String controlXml = getCollectionService(Driver.instance())
.importControl(Files.toByteArray(file));
final XStream xstream = new XStream();
final Set<String> pluginIds = getPluginIds(controlXml);
final PluginService pluginService = Driver.instance().getPluginService();
final CompositeClassLoader loader = new CompositeClassLoader();
for( String pluginId : pluginIds )
{
loader.add(pluginService.getClassLoader(pluginId));
}
loader.add(WizardTree.class.getClassLoader());
xstream.setClassLoader(loader);
return addExportedControl((ExportedControl) xstream.fromXML(controlXml),
getLastSelectedPathComponent(), true);
}
@Override
public void finished()
{
if( get() != null )
{
Driver.displayInformation(parent, CurrentLocale.get("com.tle.admin.controls.imported")); //$NON-NLS-1$
}
else
{
Driver.displayInformation(parent, CurrentLocale.get("com.tle.admin.controls.notimported")); //$NON-NLS-1$
}
}
};
}