01: package hero.xpdl;
02:
03: import java.net.URL;
04: import java.util.ArrayList;
05: import java.util.List;
06:
07: /**
08: * This class defines the declarations of the default J2EE 1.4 Schemas
09: * @author Florent Benoit
10: */
11: public class XPDLSchemas implements Schemas {
12:
13: /**
14: * List of schemas used by components
15: */
16: private static final String[] DEFAULT_SCHEMAS = new String[] { "TC-1025_schema_10_xpdl.xsd", };
17:
18: /**
19: * List where the local schemas URLs are stored
20: */
21: private static ArrayList localSchemas = null;
22:
23: /**
24: * Build a new object for Schemas handling
25: */
26: public XPDLSchemas() {
27: localSchemas = new ArrayList();
28: addSchemas(DEFAULT_SCHEMAS);
29: }
30:
31: /**
32: * Gets the URLs of the local schemas
33: * @return the URLs of the local schemas
34: */
35: public List getlocalSchemas() {
36: return localSchemas;
37: }
38:
39: /**
40: * Add to our repository the given local schemas
41: * @param schemas schemas to add to the repository
42: * @throws IllegalStateException if the dtds is not found as resource
43: */
44: protected static void addSchemas(String[] schemas)
45: throws IllegalStateException {
46: URL url = null;
47: for (int i = 0; i < schemas.length; i++) {
48: url = XPDLSchemas.class.getResource("/etc/xml/xpdl/"
49: + schemas[i]);
50: if (url == null) {
51: throw new IllegalStateException(
52: "'"
53: + schemas[i]
54: + "' was not found in the current classloader !");
55: }
56: localSchemas.add(url.toString());
57: }
58: }
59:
60: /**
61: * @param element name of the root element (jonas-ejb-jar, ...)
62: * @param schemas array of Schemas (to be always up to date)
63: * @return a header for the right element with last element
64: */
65: /* public static String getHeaderForElement(String element, String[] schemas) {
66: StringBuffer header = new StringBuffer();
67: header.append("<");
68: header.append(element);
69: header.append(" xmlns=\"http://www.objectweb.org/jonas/ns\"\n");
70: header.append(" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n");
71: header.append(" xsi:schemaLocation=\"http://www.objectweb.org/jonas/ns\n");
72: header.append(" http://www.objectweb.org/jonas/ns/");
73:
74: // Get the last XSD
75: header.append(schemas[schemas.length - 1]);
76: header.append("\" >\n");
77:
78: return header.toString();
79: }*/
80:
81: }
|