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.CustomBooleanEditor; 16 17 18 public class JaxbBooleanEditor extends CustomBooleanEditor { 19 20 private static final Logger LOG = LogUtils.getL7dLogger(JaxbBooleanEditor.class); 21 22 public JaxbBooleanEditor() { 23 super(false); 24 } 25 26 public Object getValue() { 27 Object o = super.getValue(); 28 if (o instanceof Element ) { 29 Element el = (Element )o; 30 QName type = new QName (el.getNamespaceURI(), el.getLocalName()); 31 TypeSchema ts = new TypeSchemaHelper(true).get(type.getNamespaceURI()); 32 if (null == ts) { 33 throw new ConfigurationException(new Message("JAXB_PROPERTY_EDITOR_EXC", LOG, type)); 34 } 35 try { 36 return ts.unmarshal(type, el); 37 } catch (JAXBException ex) { 38 Message msg = new Message("JAXB_PROPERTY_EDITOR_EXC", LOG, type); 39 throw new ConfigurationException(msg, ex); 40 } 41 } 42 43 return o; 44 } 45 } 46 | Popular Tags |