All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.infinispan.commons.marshall.jboss.DefaultContextClassResolver Maven / Gradle / Ivy

There is a newer version: 9.1.7.Final
Show newest version
package org.infinispan.commons.marshall.jboss;

import org.jboss.marshalling.ContextClassResolver;

import java.lang.ref.WeakReference;

/**
 * This class refines ContextClassLoader to add a default class loader.
 * The context class loader is only used when the default is null.
 *
 * @author Dan Berindei 
 * @since 4.2
 */
public class DefaultContextClassResolver extends ContextClassResolver {

   private WeakReference defaultClassLoader;

   public DefaultContextClassResolver(ClassLoader defaultClassLoader) {
      this.defaultClassLoader = new WeakReference(defaultClassLoader);
   }

   @Override
   protected ClassLoader getClassLoader() {
      ClassLoader defaultLoader = this.defaultClassLoader.get();
      return defaultLoader != null ? defaultLoader : super.getClassLoader();
   }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy