1. /*
  2. * @(#)ClassLoaderWithRepository.java 1.7 03/12/19
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package com.sun.jmx.remote.util;
  8. import javax.management.loading.ClassLoaderRepository;
  9. public class ClassLoaderWithRepository extends ClassLoader {
  10. public ClassLoaderWithRepository(ClassLoaderRepository clr,
  11. ClassLoader cl2) {
  12. if (clr == null) throw new
  13. IllegalArgumentException("Null ClassLoaderRepository object.");
  14. repository = clr;
  15. this.cl2 = cl2;
  16. }
  17. protected Class findClass(String name) throws ClassNotFoundException {
  18. try {
  19. return repository.loadClass(name);
  20. } catch (ClassNotFoundException cne) {
  21. if (cl2 != null) {
  22. return cl2.loadClass(name);
  23. } else {
  24. throw cne;
  25. }
  26. }
  27. }
  28. private ClassLoaderRepository repository;
  29. private ClassLoader cl2;
  30. }