0 Replies Latest reply on Jul 7, 2004 10:32 AM by Eduardo Yáñez Parareda

    Change the way JBossAOP gets jboss-aop.xml

    Eduardo Yáñez Parareda Newbie

      Hi again. In order to get my goals, I've had to modify the source code os JBossAOP.
      I've modified in the class org.jboss.aop.AspectXmlLoader the method loadURL.
      The original code was:

      private static Document loadURL(URL configURL) throws Exception {
      InputStream is = configURL != null ? configURL.openStream() : null;
      if (is == null) {
      throw new IOException("Failed to obtain InputStream from url: " + configURL);
      }

      DocumentBuilderFactory docBuilderFactory = null;
      docBuilderFactory = DocumentBuilderFactory.newInstance();
      DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
      Document doc = docBuilder.parse(is);
      return doc;
      }

      And I've added:

      private static Document loadURL(URL configURL) throws Exception {
      InputStream is = AspectXmlLoader.class.getResourceAsStream("/jboss-aop.xml");
      if (is == null) {
      is = configURL != null ? configURL.openStream() : null;
      }

      if (is == null) {
      throw new IOException("Failed to obtain InputStream from url: " + configURL);
      }

      DocumentBuilderFactory docBuilderFactory = null;
      docBuilderFactory = DocumentBuilderFactory.newInstance();
      DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
      Document doc = docBuilder.parse(is);
      return doc;
      }

      Now, each application within servlet-container or application server will have his own
      jboss-aop.xml and the only thing to do is put into the classpath of the application
      (i.e.: at WEB-INF/classes/jboss-aop.xml)

      It would be nice that name and relative path of this file were specified by a property
      (not a system property, please!).