01: package org.objectweb.celtix.bus.configuration.spring;
02:
03: import java.util.logging.Logger;
04:
05: import javax.xml.bind.JAXBException;
06: import javax.xml.namespace.QName;
07:
08: import org.w3c.dom.Element;
09:
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: public class JaxbBooleanEditor extends CustomBooleanEditor {
18:
19: private static final Logger LOG = LogUtils
20: .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
31: .getLocalName());
32: TypeSchema ts = new TypeSchemaHelper(true).get(type
33: .getNamespaceURI());
34: if (null == ts) {
35: throw new ConfigurationException(new Message(
36: "JAXB_PROPERTY_EDITOR_EXC", LOG, type));
37: }
38: try {
39: return ts.unmarshal(type, el);
40: } catch (JAXBException ex) {
41: Message msg = new Message("JAXB_PROPERTY_EDITOR_EXC",
42: LOG, type);
43: throw new ConfigurationException(msg, ex);
44: }
45: }
46:
47: return o;
48: }
49: }
|