1 26 27 package org.objectweb.jonas_lib.deployment.api; 28 29 30 import java.net.URL ; 31 import java.util.ArrayList ; 32 import java.util.List ; 33 34 35 39 public abstract class CommonsSchemas implements Schemas { 40 41 42 45 private static final String [] DEFAULT_SCHEMAS = new String [] { 46 "j2ee_1_4.xsd", 47 "j2ee_web_services_client_1_1.xsd", 48 "xml.xsd", 49 "jonas_j2ee_4_0.xsd", 50 "jonas_j2ee_4_1.xsd", 51 "jonas_j2ee_4_1_2.xsd", 52 "jonas_j2ee_4_1_4.xsd", 53 "jonas_j2ee_4_2.xsd" 54 }; 55 56 57 60 private static ArrayList localSchemas = null; 61 62 63 66 public CommonsSchemas() { 67 localSchemas = new ArrayList (); 68 addSchemas(DEFAULT_SCHEMAS); 69 } 70 71 75 public List getlocalSchemas() { 76 return localSchemas; 77 } 78 79 80 85 protected static void addSchemas(String [] schemas) throws IllegalStateException { 86 URL url = null; 87 for (int i = 0; i < schemas.length; i++) { 88 url = CommonsSchemas.class.getResource("/" + schemas[i]); 89 if (url == null) { 90 throw new IllegalStateException ("'" + schemas[i] + "' was not found in the current classloader !"); 91 } 92 localSchemas.add(url.toString()); 93 } 94 } 95 96 101 public static String getHeaderForElement(String element, String [] schemas) { 102 StringBuffer header = new StringBuffer (); 103 header.append("<"); 104 header.append(element); 105 header.append(" xmlns=\"http://www.objectweb.org/jonas/ns\"\n"); 106 header.append(" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"); 107 header.append(" xsi:schemaLocation=\"http://www.objectweb.org/jonas/ns\n"); 108 header.append(" http://www.objectweb.org/jonas/ns/"); 109 110 header.append(schemas[schemas.length - 1]); 112 header.append("\" >\n"); 113 114 return header.toString(); 115 } 116 117 } 118 | Popular Tags |