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

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