cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bhole, Ulhas" <ulhas.bh...@iona.com>
Subject Proposing minor change to AbstractBeanDefinitionParser.getJaxbPackage()
Date Tue, 03 Apr 2007 21:56:41 GMT
Hi, 

I have a configurartion usecase where I need to decide the package name
based on the element that is getting parsed in
org.apache.cxf.configuration.spring.AbstractBeanDefinitionParser.mapElem
entToJaxbProperty() method.

Currently it calls on to getJaxbPackage() which doesn't provided
flexibility of returning different pacakge names based on the item being
processed. 

I have a scenario where my configuration schema imports some other
schema for the types and wires it's own configuration type which contain
elemements of some local type plus elements of some types from imported
schema. 

If we can modify the getJaxbPackage() method to pass in namespace URI of
the item being processed it will allow the me to decide what package
name to return. 

Original code looks like:

protected void mapElementToJaxbProperty(Element parent,
BeanDefinitionBuilder bean, QName name,
                                            String string, Class<?> c) {
        Node data = null;
     ...
        if (data == null) {
            return;
        }

        JAXBContext context = null;
        Object obj = null;
        try {
            context = JAXBContext.newInstance(getJaxbPackage(),
getClass().getClassLoader());
            Unmarshaller u = context.createUnmarshaller();
        ...
    }

    protected String getJaxbPackage() {
        return "";
    }

Proposed change is:

protected void mapElementToJaxbProperty(Element parent,
BeanDefinitionBuilder bean, QName name,
                                            String string, Class<?> c) {
        Node data = null;
     ...
        if (data == null) {
            return;
        }

        JAXBContext context = null;
        Object obj = null;
        try {
            context =
JAXBContext.newInstance(getJaxbPackage(data.getNamespaceURI()),
getClass().getClassLoader());
            Unmarshaller u = context.createUnmarshaller();
        ...
    }

    protected String getJaxbPackage(String uri) {
        return "";
    }


There are 4 classes currently which extends this class (2 in http config
and 2 in JMS config) which will need the change along with the change I
mentioned but it will allow a flexibility in other usecases where the
configuration is composed of elements from multiple schemas and multiple
namespaces.

Any objections?

Regards,

Ulhas Bhole


Mime
View raw message