Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 320513

Summary: Interfaces unneccessarily excluded from annotation processing
Product: z_Archived Reporter: Blaise Doughan <blaise.doughan>
Component: EclipselinkAssignee: Blaise Doughan <blaise.doughan>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: eclipselink.oxm-inbox, karenfbutzke
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
MOXy - Fix
none
MOXy - Fix
none
MOXy - Test Cases
none
MOXy - Test Cases
none
MOXy - Fix
none
MOXy - Fix (to address issue for re-opening)
none
MOXy - Test Cases (to test issue for re-opening) none

Description Blaise Doughan CLA 2010-07-21 10:25:10 EDT
EclipseLink MOXy should support:

package example.interfaces;

import java.io.FileInputStream;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;

public class Demo {

    public static void main(String[] args) throws Exception {
        JAXBContext jaxbContext = JAXBContext.newInstance(Customer.class);

        FileInputStream xml = new FileInputStream("src/example/interfaces/input.xml");
        Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
        Customer customer = (Customer) unmarshaller.unmarshal(xml);

        Marshaller marshaller = jaxbContext.createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
        marshaller.marshal(customer, System.out);
    }

}

For the interface:

package example.interfaces;

import java.util.List;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

import org.eclipse.persistence.oxm.annotations.XmlCustomizer;
import example.interfaces.metadata.InterfaceCustomizer;

@XmlRootElement()
@XmlCustomizer(InterfaceCustomizer.class)
@XmlType(propOrder={"name", "address"})
public interface Customer {

    String getName();
    void setName(String name);

    Address getAddress();
    void setAddress(Address address);

    public List<PhoneNumber> getPhoneNumbers();
    public void setPhoneNumbers(List<PhoneNumber> phoneNumbers);

}
Comment 1 Blaise Doughan CLA 2010-07-21 10:26:37 EDT
Created attachment 174858 [details]
MOXy - Fix
Comment 2 Blaise Doughan CLA 2010-07-21 11:44:07 EDT
Created attachment 174871 [details]
MOXy - Fix
Comment 3 Blaise Doughan CLA 2010-07-21 12:24:59 EDT
Created attachment 174880 [details]
MOXy - Test Cases
Comment 4 Blaise Doughan CLA 2010-07-22 09:57:09 EDT
Created attachment 174976 [details]
MOXy - Test Cases
Comment 5 Blaise Doughan CLA 2010-07-22 09:59:18 EDT
Created attachment 174977 [details]
MOXy - Fix
Comment 6 Karen Butzke CLA 2010-07-22 10:53:05 EDT
Blaise, isn't this an enhancement, I'm curious how it can go in a maintenance release?
Comment 7 Blaise Doughan CLA 2010-07-22 11:10:39 EDT
(In reply to comment #6)
> Blaise, isn't this an enhancement, I'm curious how it can go in a maintenance
> release?

Not really an enhacement, just a one line change to enable this functionality.
Comment 8 Blaise Doughan CLA 2010-07-22 11:11:01 EDT
Now interfaces aren't excluded from annotation process.  When using interfaces
you must set up a corresponding ObjectFactory.

Fix checked into 2.1.1 at rev:  7890
Fix checked into trunk at rev:  7891
Comment 9 Karen Butzke CLA 2010-07-22 11:17:49 EDT
I don't think it matters that the enhancement is simple to implement, it is still new functionality. Thinking in terms of future Dali support, if we were to support interfaces in the next release we would have to have a 2.1.0 platform that doesn't support them and a specific 2.1.1+ platform that does.
Comment 10 Blaise Doughan CLA 2010-07-29 10:31:45 EDT
Problem encountered with the fix.  There may be cases where a property type is an interface but it will have values of objects that implement that interface and therefore there does not need to be a way to instantiate an instance of that interface.
Comment 11 Blaise Doughan CLA 2010-07-29 10:34:32 EDT
Created attachment 175503 [details]
MOXy - Fix (to address issue for re-opening)
Comment 12 Blaise Doughan CLA 2010-07-29 11:18:12 EDT
Created attachment 175508 [details]
MOXy - Test Cases (to test issue for re-opening)
Comment 13 Blaise Doughan CLA 2010-07-29 11:22:16 EDT
Amended fix checked into:
- 2.1.1 at revision:  7949
- trunk at revision:  7950
Comment 14 Eclipse Webmaster CLA 2022-06-09 10:05:26 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink