1 package org.objectweb.celtix.bus.configuration.spring; 2 3 import java.util.logging.Logger ; 4 5 import javax.xml.bind.JAXBException; 6 import javax.xml.namespace.QName ; 7 8 import org.w3c.dom.Element ; 9 10 import org.objectweb.celtix.common.i18n.Message; 11 import org.objectweb.celtix.common.logging.LogUtils; 12 import org.objectweb.celtix.configuration.ConfigurationException; 13 import org.objectweb.celtix.configuration.impl.TypeSchema; 14 import org.objectweb.celtix.configuration.impl.TypeSchemaHelper; 15 import org.springframework.beans.propertyeditors.CustomNumberEditor; 16 17 public class JaxbNumberEditor extends CustomNumberEditor { 18 19 private static final Logger LOG = LogUtils.getL7dLogger(JaxbNumberEditor.class); 20 21 JaxbNumberEditor(Class cl) { 22 super(cl, false); 23 } 24 25 public Object getValue() { 26 Object o = super.getValue(); 27 if (o instanceof Element ) { 28 Element el = (Element )o; 29 QName type = new QName (el.getNamespaceURI(), el.getLocalName()); 30 TypeSchema ts = new TypeSchemaHelper(true).get(type.getNamespaceURI()); 31 if (null == ts) { 32 throw new ConfigurationException(new Message("JAXB_PROPERTY_EDITOR_EXC", LOG, type)); 33 } 34 try { 35 return ts.unmarshal(type, el); 36 } catch (JAXBException ex) { 37 Message msg = new Message("JAXB_PROPERTY_EDITOR_EXC", LOG, type); 38 throw new ConfigurationException(msg, ex); 39 } 40 } 41 42 return o; 43 } 44 } 45 | Popular Tags |