You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DefaultWeavingContext.java 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*******************************************************************************
  2. * Copyright (c) 2005 Contributors.
  3. * All rights reserved.
  4. * This program and the accompanying materials are made available
  5. * under the terms of the Eclipse Public License v1.0
  6. * which accompanies this distribution and is available at
  7. * http://eclipse.org/legal/epl-v10.html
  8. *
  9. * Contributors:
  10. * David Knibb initial implementation
  11. *******************************************************************************/
  12. package org.aspectj.weaver.loadtime;
  13. import java.io.IOException;
  14. import java.net.URL;
  15. import java.util.Enumeration;
  16. /**
  17. * Use in non-OSGi environment
  18. *
  19. * @author David Knibb
  20. */
  21. public class DefaultWeavingContext implements IWeavingContext {
  22. protected ClassLoader loader;
  23. public DefaultWeavingContext(){
  24. loader = getClass().getClassLoader();
  25. }
  26. /**
  27. * Construct a new WeavingContext to use the specifed ClassLoader
  28. * This is the constructor which should be used.
  29. * @param loader
  30. */
  31. public DefaultWeavingContext(ClassLoader loader) {
  32. this.loader = loader;
  33. }
  34. /**
  35. * Same as ClassLoader.getResources()
  36. */
  37. public Enumeration getResources(String name) throws IOException {
  38. return loader.getResources(name);
  39. }
  40. /**
  41. * @return null as we are not in an OSGi environment (therefore no bundles)
  42. */
  43. public String getBundleIdFromURL(URL url) {
  44. return null;
  45. }
  46. /**
  47. * @return classname@hashcode
  48. */
  49. public String getClassLoaderName() {
  50. return ((loader!=null)?loader.getClass().getName()+"@"+loader.hashCode():"null");
  51. }
  52. }