當前位置: 首頁>>代碼示例>>Java>>正文


Java XStream.setClassLoader方法代碼示例

本文整理匯總了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));
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:19,代碼來源:InitialiserServiceImpl.java

示例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);
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:18,代碼來源:XStreamDataConverter.java

示例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"));
					}
				}
			}
		}
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:52,代碼來源:ItemSummaryTemplateTab.java

示例4: DisplayNodesConfig

import com.thoughtworks.xstream.XStream; //導入方法依賴的package包/類
public DisplayNodesConfig()
{
	xstream = new XStream();
	xstream.setClassLoader(getClass().getClassLoader());
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:6,代碼來源:DisplayNodesConfig.java

示例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$
			}
		}
	};
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:42,代碼來源:WizardTree.java


注:本文中的com.thoughtworks.xstream.XStream.setClassLoader方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。