1 22 package org.jboss.xb.binding.sunday.unmarshalling; 23 24 import org.jboss.logging.Logger; 25 import org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver; 26 import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingResolver; 27 import org.jboss.xb.binding.sunday.unmarshalling.SchemaResolverFactory; 28 29 35 public class SingletonSchemaResolverFactory implements SchemaResolverFactory 36 { 37 38 private static final Logger log = Logger.getLogger(SingletonSchemaResolverFactory.class); 39 40 41 private static final SingletonSchemaResolverFactory singleton = new SingletonSchemaResolverFactory(); 42 43 44 private final DefaultSchemaResolver resolver = new DefaultSchemaResolver(); 45 46 51 public static SingletonSchemaResolverFactory getInstance() 52 { 53 return singleton; 54 } 55 56 59 private SingletonSchemaResolverFactory() 60 { 61 addSchema("urn:jboss:aop-beans:1.0", "org.jboss.aop.microcontainer.beans.xml.AOPBeansSchemaInitializer", Boolean.FALSE); 62 addSchema("urn:jboss:bean-deployer", "org.jboss.kernel.plugins.deployment.xml.BeanSchemaInitializer", Boolean.FALSE); 63 addSchema("urn:jboss:bean-deployer:2.0", "org.jboss.kernel.plugins.deployment.xml.BeanSchemaInitializer20", Boolean.FALSE); 64 addSchema("urn:jboss:javabean:1.0", "org.jboss.kernel.plugins.config.xml.JavaBeanSchemaInitializer", Boolean.FALSE); 65 } 66 67 public SchemaBindingResolver getSchemaBindingResolver() 68 { 69 return resolver; 70 } 71 72 79 protected boolean addSchema(String namespace, String initializer) 80 { 81 try 82 { 83 resolver.addSchemaInitializer(namespace, initializer); 84 log.trace("Mapped initializer '" + namespace + "' to '" + initializer + "'"); 85 return true; 86 } 87 catch (Exception ignored) 88 { 89 log.trace("Ignored: ", ignored); 90 return false; 91 } 92 } 93 94 102 protected boolean addSchema(String namespace, String initializer, Boolean parseAnnotations) 103 { 104 if (addSchema(namespace, initializer) == false) 105 return false; 106 setParseAnnotations(namespace, parseAnnotations); 107 return true; 108 } 109 110 118 protected boolean addSchema(String namespace, String initializer, String location) 119 { 120 if (addSchema(namespace, initializer) == false) 121 return false; 122 try 123 { 124 resolver.addSchemaLocation(namespace, location); 125 log.trace("Mapped location '" + namespace + "' to '" + location + "'"); 126 return true; 127 } 128 catch (Exception ignored) 129 { 130 log.trace("Ignored: ", ignored); 131 return false; 132 } 133 } 134 135 144 protected boolean addSchema(String namespace, String initializer, String location, Boolean parseAnnotations) 145 { 146 if (addSchema(namespace, initializer, location) == false) 147 return false; 148 setParseAnnotations(namespace, parseAnnotations); 149 return true; 150 } 151 152 158 protected void setParseAnnotations(String namespace, Boolean parseAnnotations) 159 { 160 resolver.addSchemaParseAnnotations(namespace, parseAnnotations); 161 log.trace("Parse annotations '" + namespace + "' set to '" + parseAnnotations + "'"); 162 } 163 } 164 | Popular Tags |