| 1 8 package com.mvnforum.jaxb.db.impl.runtime; 9 10 import javax.xml.bind.DatatypeConverter; 11 import javax.xml.bind.JAXBContext; 12 import javax.xml.bind.JAXBException; 13 import javax.xml.bind.Marshaller; 14 import javax.xml.bind.PropertyException; 15 import javax.xml.bind.Unmarshaller; 16 import javax.xml.bind.Validator; 17 18 import com.sun.xml.bind.Messages; 19 import com.sun.xml.bind.DatatypeConverterImpl; 20 21 28 public class DefaultJAXBContextImpl extends JAXBContext { 29 30 36 private GrammarInfo gi = null; 37 38 44 public DefaultJAXBContextImpl( String contextPath, ClassLoader classLoader ) 45 throws JAXBException { 46 47 this( GrammarInfoFacade.createGrammarInfoFacade( contextPath, classLoader ) ); 48 49 DatatypeConverter.setDatatypeConverter(DatatypeConverterImpl.theInstance); 51 } 52 53 58 public DefaultJAXBContextImpl( GrammarInfo gi ) { 59 this.gi = gi; 60 } 61 62 public GrammarInfo getGrammarInfo() { 63 return gi; 64 } 65 66 67 68 71 private com.sun.msv.grammar.Grammar grammar = null; 72 73 80 public synchronized com.sun.msv.grammar.Grammar getGrammar() throws JAXBException { 81 if( grammar==null ) 82 grammar = gi.getGrammar(); 83 return grammar; 84 } 85 86 87 95 public Marshaller createMarshaller() throws JAXBException { 96 return new MarshallerImpl( this ); 97 } 98 99 107 public Unmarshaller createUnmarshaller() throws JAXBException { 108 return new UnmarshallerImpl( this, gi ); 109 } 110 111 119 public Validator createValidator() throws JAXBException { 120 return new ValidatorImpl( this ); 121 } 122 123 124 125 132 public Object newInstance( Class javaContentInterface ) 133 throws JAXBException { 134 135 if( javaContentInterface == null ) { 136 throw new JAXBException( Messages.format( Messages.CI_NOT_NULL ) ); 137 } 138 139 try { 140 Class c = gi.getDefaultImplementation( javaContentInterface ); 141 if(c==null) 142 throw new JAXBException( 143 Messages.format( Messages.MISSING_INTERFACE, javaContentInterface )); 144 145 return c.newInstance(); 146 } catch( Exception e ) { 147 throw new JAXBException( e ); 148 } 149 } 150 151 155 public void setProperty( String name, Object value ) 156 throws PropertyException { 157 158 throw new PropertyException(name, value); 159 } 160 161 165 public Object getProperty( String name ) 166 throws PropertyException { 167 168 throw new PropertyException(name); 169 } 170 171 172 } 173 | Popular Tags |