Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

DefaultWeavingContext.java 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. private String shortName;
  24. /**
  25. * Construct a new WeavingContext to use the specifed ClassLoader
  26. * This is the constructor which should be used.
  27. * @param loader
  28. */
  29. public DefaultWeavingContext(ClassLoader loader) {
  30. this.loader = loader;
  31. }
  32. /**
  33. * Same as ClassLoader.getResources()
  34. */
  35. public Enumeration getResources(String name) throws IOException {
  36. return loader.getResources(name);
  37. }
  38. /**
  39. * @return null as we are not in an OSGi environment (therefore no bundles)
  40. */
  41. public String getBundleIdFromURL(URL url) {
  42. return "";
  43. }
  44. /**
  45. * @return classname@hashcode
  46. */
  47. public String getClassLoaderName() {
  48. return ((loader!=null)?loader.getClass().getName()+"@"+loader.hashCode():"null");
  49. }
  50. /**
  51. * @return filename
  52. */
  53. public String getFile(URL url) {
  54. return url.getFile();
  55. }
  56. /**
  57. * @return unqualifiedclassname@hashcode
  58. */
  59. public String getId () {
  60. if (shortName == null) {
  61. shortName = getClassLoaderName().replace('$','.');
  62. int index = shortName.lastIndexOf(".");
  63. shortName = shortName.substring(index + 1);
  64. }
  65. return shortName;
  66. }
  67. public String getSuffix () {
  68. return getClassLoaderName();
  69. }
  70. }