Hi,

Do we want to generalize the fix a bit to have a XmlJavaTypeAdapter backed by 
the databinding framework to deal with XML-friendly types that are not JAXB? 
The only difficulty is that the adapter has to access the databinding framework 
statically (for example, from a static variable or some context on the thread) 
as the instance will be instantiated by the JAXB runtime.

Thanks,
Raymond


From: Ramkumar R 
Sent: Wednesday, February 11, 2009 10:10 AM
To: [email protected] 
Subject: Re: Update on Databinding Scope & Issues


Hi All,

I am planning to fix the data binding issue with OMElement as described in 
https://issues.apache.org/jira/browse/TUSCANY-2664,
by creating a pre-defined XMLAdapter called OMElementXMLAdapter.java as we have 
done for CallableReferences earlier.

Please let me know if any one has issues in this fix.

By fixing TUSCANY-2664, we can now claim that we have a complete support for 
Axis2 MTOM.

I have opened a seperate JIRA TUSCANY-2840 to track the issue around the usage 
of @XmlJavaTypeAdapter in service methods.



On Wed, Feb 11, 2009 at 5:11 PM, Ramkumar R <[email protected]> wrote:

  Hi Simon,

  You are right, by configuring our databinding framework to know about the 
types that JAXB struggles, its possible that we will get rid of this issue. 

  In fact as I mentioned earlier, By adding XMLAdapter's in 
DataBindingModuleActivator.java, (as how we do for CallableReferences too) as 
shown below.....


  XMLAdapterExtensionPoint xmlAdapterExtensionPoint = 
registry.getExtensionPoint(XMLAdapterExtensionPoint.class);
  xmlAdapterExtensionPoint.addAdapter(Exception.class, 
ExceptionXMLAdapter.class);


  resolves the issue. I believe this solution holds good for some critical data 
types like OMElement that we like to support for Axis2 MTOM.

  But looking at the broader picture, there might me quite a lot of java 
defined interfaces that the user might want to use as a parameter 
  types (for example java.lang.Exception), so in such cases it would be good we 
allow the users to define their own XMLAdapter's and allow them to use with 
  our databinding framework, rather than we develop pre-defined XMLAdapter for 
possible interfaces that can be use.

  Please let me know, if you have any comments/sugggestion. Thanks.




  On Mon, Feb 9, 2009 at 6:47 PM, Simon Laws <[email protected]> wrote:




    On Mon, Feb 9, 2009 at 12:20 PM, Ramkumar R <[email protected]> wrote:

      As mentioned earlier, since JAXB can't handle interfaces like 
org.apache.axiom.om.OMElement OR java.lang.Exception
      one way to make this interfaces work with JAXB is to write an XMLAdapter 
to convert these data types to the known JAXB data types.

      Defining @XmlJavaTypeAdapter annotation with the XMLAdapter as value in 
the service method does not seem to work in Tuscany 
      as I mentioned earlier.

      So I tried adding XMLAdapter's in DataBindingModuleActivator.java, as 
shown below.....

      XMLAdapterExtensionPoint xmlAdapterExtensionPoint = 
registry.getExtensionPoint(XMLAdapterExtensionPoint.class);
      xmlAdapterExtensionPoint.addAdapter(Exception.class, 
ExceptionXMLAdapter.class);

      This seem to be work fine for me, and now I am able to pass these 
interfaces as parameter through JAXB.

      Just wanted to make sure, if anyone have tried using @XmlJavaTypeAdapter 
annotations with the service methods,
      if not I can open JIRA to fix this issue. 




      On Fri, Feb 6, 2009 at 5:49 PM, Ramkumar R <[email protected]> wrote:

        The DataBinding Scope wiki page 
http://cwiki.apache.org/confluence/display/TUSCANYWIKI/Databinding+Scope
         is now updated with the databinding scope for Axis2 MTOM support.

        Just wanted to update everyone that, the standard type 
javax.activation.DataHandler is now fully supported, more details 
        can be viewed from TUSCANY-2451.

        Currently we have 2 outstanding issue that needs to be resolved...

        1. Support for javax.xml.transform.Source data type, raised as 
TUSCANY-2386, TUSCANY-2387 and TUSCANY-2452.
        2. Support for org.apache.axiom.om.OMElement, raised as TUSCANY-2664

        Here I like to talk about the options to support 
org.apache.axiom.om.OMElement datatype in our databinding scope....

        Since OMElement is an interface, the JAXB runtime throws the following 
exception....

        org.apache.axiom.om.OMElement is an interface, and JAXB can't handle 
interfaces.
            this problem is related to the following location:
                at org.apache.axiom.om.OMElement
                at protected org.apache.axiom.om.OMElement 
org.apache.tuscany.sca.binding.ws.axis2.itests.mtom.jaxws.UploadOMElementFile.arg0
                at 
org.apache.tuscany.sca.binding.ws.axis2.itests.mtom.jaxws.UploadOMElementFile

        JAXB recommends to use an XMLAdapter to solve this issue, by creating 
an XMLAdapter for your interfaces (OMElement) and by using
        @XmlJavaTypeAdapter in the service method as shown below.

        @XmlJavaTypeAdapter(value=OMElementXmlAdapter.class, 
type=OMElement.class)
        public String uploadOMElementFile(OMElement attachment) throws 
Exception;

        Using @XmlJavaTypeAdapter in the service method, throws the following 
exception.....

        java.lang.IllegalArgumentException: value class 
org.apache.tuscany.sca.binding.ws.axis2.itests.mtom.OMElementXmlAdapter
            at org.objectweb.asm.ClassWriter.a(Unknown Source)
            at org.objectweb.asm.AnnotationWriter.visit(Unknown Source)
            at 
org.apache.tuscany.sca.interfacedef.java.jaxws.BaseBeanGenerator.declareField(BaseBeanGenerator.java:250)
            at 
org.apache.tuscany.sca.interfacedef.java.jaxws.BaseBeanGenerator.declareProperty(BaseBeanGenerator.java:195)
            at 
org.apache.tuscany.sca.interfacedef.java.jaxws.BaseBeanGenerator.defineClass(BaseBeanGenerator.java:153)
            at 
org.apache.tuscany.sca.interfacedef.java.jaxws.BaseBeanGenerator.generate(BaseBeanGenerator.java:437)
            at 
org.apache.tuscany.sca.interfacedef.java.jaxws.WrapperBeanGenerator.generateResponseWrapper(WrapperBeanGenerator.java:190)
            at 
org.apache.tuscany.sca.interfacedef.java.jaxws.GeneratedDataTypeImpl.getPhysical(GeneratedDataTypeImpl.java:101)
            at 
org.apache.tuscany.sca.databinding.jaxb.JAXBContextHelper.findClasses(JAXBContextHelper.java:230)
            at 
org.apache.tuscany.sca.databinding.jaxb.JAXBContextHelper.createJAXBContext(JAXBContextHelper.java:210)
            at 
org.apache.tuscany.sca.databinding.jaxb.JAXBContextHelper.createJAXBContext(JAXBContextHelper.java:89)
            at 
org.apache.tuscany.sca.databinding.jaxb.axiom.JAXB2OMElement.transform(JAXB2OMElement.java:52)
            at 
org.apache.tuscany.sca.databinding.jaxb.axiom.JAXB2OMElement.transform(JAXB2OMElement.java:40)
            at 
org.apache.tuscany.sca.databinding.DefaultTransformerExtensionPoint$LazyPullTransformer.transform(DefaultTransformerExtensionPoint.java:200)
            at 
org.apache.tuscany.sca.databinding.impl.MediatorImpl.mediate(MediatorImpl.java:81)
            at 
org.apache.tuscany.sca.core.databinding.transformers.Input2InputTransformer.transform(Input2InputTransformer.java:190)
            at 
org.apache.tuscany.sca.core.databinding.transformers.Input2InputTransformer.transform(Input2InputTransformer.java:1)
            at 
org.apache.tuscany.sca.databinding.impl.MediatorImpl.mediate(MediatorImpl.java:81)
            at 
org.apache.tuscany.sca.core.databinding.wire.DataTransformationInterceptor.transform(DataTransformationInterceptor.java:208)
            at 
org.apache.tuscany.sca.core.databinding.wire.DataTransformationInterceptor.invoke(DataTransformationInterceptor.java:97)
            at 
org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JDKInvocationHandler.java:310)
            at 
org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JDKInvocationHandler.java:163)
            at $Proxy19.uploadOMElementFile(Unknown Source)

        Like to know if we have any sample to demonstrate the use of  various 
xml binding annotation like @XmlAttachmentRef, @XmlMimeType, and 
@XmlJavaTypeAdapter in service interface methods.

        Any other comments and suggestions are appreciated. Thanks.

        -- 
        Thanks & Regards,
        Ramkumar Ramalingam





      -- 
      Thanks & Regards,
      Ramkumar Ramalingam



    Ram 

    Question for you. Are we able to do a similar transformation using our 
databinding framework? I.e. can we configure our databinding framework to know 
about the types that JAXB struggles with so that JAXB2OMElement doesn't get 
used directly. 

    This may not be practivcal if having these types messes up the WSDL 
generation stage also but worth a look if it means we can do away with 
mandatory requirement to add more annotations. 

    I'm asking this question as when, a while back, we needed to do some 
specific data transformation steps to handle callable references (which are 
exterenalizble) that appear as arguments as service interfaces we wrote a 
special transformer [1][2] and configured it as part of the databinding 
framework [3]

    Maybe we can treat these problematic types in the same way? There is maybe 
a good reason why this won't work but intersted in your thoughts.

    Regards

    Simon

    [1] 
http://svn.apache.org/repos/asf/tuscany/branches/sca-java-1.x/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/Externalizable2OMElement.java
    [2] 
http://svn.apache.org/repos/asf/tuscany/branches/sca-java-1.x/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2Externalizable.java
    [3] 
http://svn.apache.org/repos/asf/tuscany/branches/sca-java-1.x/modules/databinding-axiom/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer







  -- 
  Thanks & Regards,
  Ramkumar Ramalingam




-- 
Thanks & Regards,
Ramkumar Ramalingam

Reply via email to