01: /**************************************************************************************
02: * Copyright (c) Jonas BonŽr, Alexandre Vasseur. All rights reserved. *
03: * http://aspectwerkz.codehaus.org *
04: * ---------------------------------------------------------------------------------- *
05: * The software in this package is published under the terms of the LGPL license *
06: * a copy of which has been included with this distribution in the license.txt file. *
07: **************************************************************************************/package org.codehaus.aspectwerkz.definition;
08:
09: import java.io.File;
10: import java.net.MalformedURLException;
11: import java.util.Set;
12: import java.util.HashSet;
13:
14: /**
15: * TODO remove class and move single method to SystemDefinitionContainer?s
16: * <p/>
17: * Handles the loading of the definition in various ways and formats.
18: *
19: * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
20: */
21: public class DefinitionLoader {
22: /**
23: * The UUID of the single AspectWerkz system if only one definition is used.
24: */
25: public static final String DEFAULT_SYSTEM = "default";
26:
27: /**
28: * The path to the definition file.
29: */
30: public static final String DEFINITION_FILE = System.getProperty(
31: "aspectwerkz.definition.file", null);
32:
33: /**
34: * The default name for the definition file.
35: */
36: public static final String DEFAULT_DEFINITION_FILE_NAME = "aspectwerkz.xml";
37:
38: /**
39: * Returns the default defintion.
40: *
41: * @param loader
42: * @return the default defintion
43: */
44: public static Set getDefaultDefinition(final ClassLoader loader) {
45: if (DEFINITION_FILE != null) {
46: File file = new File(DEFINITION_FILE);
47: if (file.canRead()) {
48: try {
49: return XmlParser.parseNoCache(loader, file.toURL());
50: } catch (MalformedURLException e) {
51: System.err.println("<WARN> Cannot read "
52: + DEFINITION_FILE);
53: e.printStackTrace();
54: }
55: } else {
56: System.err.println("<WARN> Cannot read "
57: + DEFINITION_FILE);
58: }
59: }
60: return new HashSet();
61: }
62: }
|