com.thoughtworks.xstream.XStream.getClassLoader()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(3.8k)|赞(0)|评价(0)|浏览(195)

本文整理了Java中com.thoughtworks.xstream.XStream.getClassLoader()方法的一些代码示例,展示了XStream.getClassLoader()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XStream.getClassLoader()方法的具体详情如下:
包路径:com.thoughtworks.xstream.XStream
类名称:XStream
方法名:getClassLoader

XStream.getClassLoader介绍

[英]Retrieve the ClassLoader XStream uses to load classes.
[中]检索XStream用于加载类的类加载器。

代码示例

代码示例来源:origin: geoserver/geoserver

new DefaultMapper(new ClassLoaderReference(xs.getClassLoader())));

代码示例来源:origin: com.liferay/com.liferay.exportimport.service

@Override
public ClassLoader getClassLoader() {
  return _xStream.getClassLoader();
}

代码示例来源:origin: ovea-deprecated/jetty-session-redis

/**
 * @throws ClassCastException if mapper is not really a deprecated {@link ClassMapper} instance
 * @deprecated As of 1.2, use {@link #getMapper}
 */
public ClassMapper getClassMapper() {
  if (mapper instanceof ClassMapper) {
    return (ClassMapper)mapper;
  } else {
    return (ClassMapper)Proxy.newProxyInstance(getClassLoader(), new Class[]{ClassMapper.class},
        new InvocationHandler() {
          public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
            return method.invoke(mapper, args);
          }
        });
  }
}

代码示例来源:origin: org.jvnet.hudson/xstream

/**
 * @throws ClassCastException if mapper is not really a deprecated {@link ClassMapper} instance
 * @deprecated As of 1.2, use {@link #getMapper}
 */
public ClassMapper getClassMapper() {
  if (mapper instanceof ClassMapper) {
    return (ClassMapper)mapper;
  } else {
    return (ClassMapper)Proxy.newProxyInstance(getClassLoader(), new Class[]{ClassMapper.class},
        new InvocationHandler() {
          public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
            return method.invoke(mapper, args);
          }
        });
  }
}

代码示例来源:origin: com.marvelution.jira.plugins/jenkins-jira-plugin

/**
 * Get an object from the {@link InputStream}
 *
 * @param input the {@link InputStream}
 * @param type the Class type
 * @param <T> the type generic
 * @return the Object
 * @throws IOException in case of read errors
 */
@SuppressWarnings("unchecked")
public static <T> T getEntityFromRequest(InputStream input, Class<T> type) throws IOException {
  ClassLoader loader = null;
  try {
    loader = XSTREAM.getClassLoader();
    XSTREAM.setClassLoader(type.getClassLoader());
    return (T) XSTREAM.fromXML(input);
  } finally {
    if (loader != null) {
      XSTREAM.setClassLoader(loader);
    }
  }
}

代码示例来源:origin: com.atlassian.notifier/notifier-core

private static void addThisClassLoader(final XStream xStream)
{
  final ClassLoader originalClassLoader = xStream.getClassLoader();
  CompositeClassLoader compositeClassLoader;
  if (originalClassLoader instanceof CompositeClassLoader)
  {
    compositeClassLoader = (CompositeClassLoader) originalClassLoader;
  }
  else
  {
    compositeClassLoader = new CompositeClassLoader();
    compositeClassLoader.add(originalClassLoader);
    xStream.setClassLoader(compositeClassLoader);
  }
  compositeClassLoader.add(XStreamUtils.class.getClassLoader());
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

public XmlMementoSerializer(ClassLoader classLoader, Map<String, String> deserializingClassRenames) {
  super(new ClassLoaderFromStackOfBrooklynClassLoadingContext(classLoader), deserializingClassRenames);
  this.delegatingClassLoader = (ClassLoaderFromStackOfBrooklynClassLoadingContext) xstream.getClassLoader();

代码示例来源:origin: com.atlassian.applinks/applinks-core

private static void addThisClassLoader(final XStream xStream)
{
  final ClassLoader originalClassLoader = xStream.getClassLoader();
  CompositeClassLoader compositeClassLoader;
  if (originalClassLoader instanceof CompositeClassLoader)
  {
    compositeClassLoader = (CompositeClassLoader) originalClassLoader;
  }
  else
  {
    compositeClassLoader = new CompositeClassLoader();
    compositeClassLoader.add(originalClassLoader);
    xStream.setClassLoader(compositeClassLoader);
  }
  compositeClassLoader.add(XStreamUtils.class.getClassLoader());
}

代码示例来源:origin: org.apache.camel/camel-xstream

ClassLoader xstreamLoader = xstream.getClassLoader();
if (classLoader != null && xstreamLoader instanceof CompositeClassLoader) {
  ((CompositeClassLoader) xstreamLoader).add(classLoader);

相关文章