Package org.objectweb.celtix.bus.configuration.spring

Source Code of org.objectweb.celtix.bus.configuration.spring.JaxbBooleanEditor

package org.objectweb.celtix.bus.configuration.spring;

import java.util.logging.Logger;

import javax.xml.bind.JAXBException;
import javax.xml.namespace.QName;

import org.w3c.dom.Element;

import org.objectweb.celtix.common.i18n.Message;
import org.objectweb.celtix.common.logging.LogUtils;
import org.objectweb.celtix.configuration.ConfigurationException;
import org.objectweb.celtix.configuration.impl.TypeSchema;
import org.objectweb.celtix.configuration.impl.TypeSchemaHelper;
import org.springframework.beans.propertyeditors.CustomBooleanEditor;


public class JaxbBooleanEditor extends CustomBooleanEditor {
   
    private static final Logger LOG = LogUtils.getL7dLogger(JaxbBooleanEditor.class);
   
    public JaxbBooleanEditor() {
        super(false);
    }
   
    public Object getValue() {
        Object o = super.getValue();
        if (o instanceof Element) {
            Element el = (Element)o;
            QName type = new QName(el.getNamespaceURI(), el.getLocalName());
            TypeSchema ts = new TypeSchemaHelper(true).get(type.getNamespaceURI());
            if (null == ts) {
                throw new ConfigurationException(new Message("JAXB_PROPERTY_EDITOR_EXC", LOG, type));
            }
            try {
                return ts.unmarshal(type, el);
            } catch (JAXBException ex) {
                Message msg = new Message("JAXB_PROPERTY_EDITOR_EXC", LOG, type);
                throw new ConfigurationException(msg, ex);
            }
        }

        return o;
    }      
}
TOP

Related Classes of org.objectweb.celtix.bus.configuration.spring.JaxbBooleanEditor

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.