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.

IWeavingContext.java 2.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. import java.util.List;
  17. import org.aspectj.weaver.loadtime.definition.Definition;
  18. import org.aspectj.weaver.tools.WeavingAdaptor;
  19. /**
  20. * This class adds support to AspectJ for an OSGi environment
  21. *
  22. * @author David Knibb
  23. */
  24. public interface IWeavingContext {
  25. /**
  26. * Allows the standard ClassLoader.getResources() mechanisms to be
  27. * replaced with a different implementation.
  28. * In an OSGi environment, this will allow for filtering to take
  29. * place on the results of ClassLoader.getResources(). In a non-OSGi
  30. * environment, ClassLoader.getResources should be returned.
  31. * @param name the name of the resource to search for
  32. * @return an enumeration containing all of the matching resources found
  33. * @throws IOException
  34. */
  35. Enumeration<URL> getResources(String name) throws IOException;
  36. /**
  37. * In an OSGi environment, determine which bundle a URL originated from.
  38. * In a non-OSGi environment, implementors should return <code>null</code>.
  39. * @param url
  40. * @return
  41. * @deprecated use getFile() or getClassLoaderName()
  42. */
  43. String getBundleIdFromURL(URL url);
  44. /**
  45. * In an environment with multiple class loaders allows each to be
  46. * identified using something safer and possibly shorter than toString
  47. * @return name of the associated class loader
  48. */
  49. String getClassLoaderName();
  50. ClassLoader getClassLoader();
  51. /**
  52. * Format a URL
  53. * @return filename
  54. */
  55. String getFile(URL url);
  56. /**
  57. * In an environment with multiple class loaders allows messages
  58. * to identified according to the weaving context
  59. * @return short name
  60. */
  61. String getId();
  62. /**
  63. * Return true if the classloader associated with this weaving context
  64. * is the one that will define the class with the specified name.
  65. * In a delegating classloader hierarchy this might check the parent won't
  66. * define it and the child will - in OSGi it will do something else.
  67. * @param classname name of the class, eg. "java.lang.String"
  68. * @return true if the associated classloader will define the class
  69. */
  70. boolean isLocallyDefined(String classname);
  71. /**
  72. * Allow custom parsing of aop.xml or alternative mechanism for providing
  73. * Definitions
  74. *
  75. * @param loader
  76. * @param adaptor
  77. * @return List containing 0 or more Definition instances
  78. */
  79. List<Definition> getDefinitions(final ClassLoader loader, WeavingAdaptor adaptor);
  80. }