/core/src/main/java/org/dozer/util/DefaultClassLoader.java

http://github.com/DozerMapper/dozer · Java · 47 lines · 18 code · 7 blank · 22 comment · 0 complexity · 1b94018fe3474715784ca3b5d74eb869 MD5 · raw file

  1. /*
  2. * Copyright 2005-2009 the original author or authors.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package org.dozer.util;
  17. import org.apache.commons.lang3.ClassUtils;
  18. import java.net.URL;
  19. /**
  20. *
  21. *
  22. * @author dmitry.buzdin
  23. * @since 5.1
  24. */
  25. public class DefaultClassLoader implements DozerClassLoader {
  26. private final ResourceLoader resourceLoader = new ResourceLoader();
  27. public Class<?> loadClass(String className) {
  28. Class<?> result = null;
  29. try {
  30. //Class caller = Reflection.getCallerClass(3); TODO OSGi fix - Move to specific implementation
  31. result = ClassUtils.getClass(className);
  32. } catch (ClassNotFoundException e) {
  33. MappingUtils.throwMappingException(e);
  34. }
  35. return result;
  36. }
  37. public URL loadResource(String uri) {
  38. return resourceLoader.getResource(uri);
  39. }
  40. }