[ 
https://issues.apache.org/jira/browse/CXF-3722?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13403306#comment-13403306
 ] 

Greg Holmberg commented on CXF-3722:
------------------------------------

OK, this is your proposal:

{code}
public class Book implements NamedObject { ... }

public class BookAdapter extends XmlAdapter<Book, NamedObject> {
    public Book marshal(NamedObject v) throws Exception {
        return (Book)v;
    }

    public NamedObject unmarshal(Book v) throws Exception {
        return v;
    }
}

@XmlType
@XmlJavaTypeAdapter(BookAdapter.class)
public interface NamedObject {
    @XmlAttribute
    public String getName();
}
{code}

So, NamedObject.java has the line "@XmlJavaTypeAdapter(BookAdapter.class)".  
Therefore, NamedObject knows about BookAdapter.

BookAdapter has this line: "public class BookAdapter extends XmlAdapter<Book, 
NamedObject> {".  Therefore, BookAdapter knows about Book.

So there's a transitive dependency: NamedObject -> BookAdapter -> Book.

Now if I want to add another POJO, let's call it "Song", I have to do this:

{code}
public class Song implements NamedObject { ... }

public class SongAdapter extends XmlAdapter<Song, NamedObject> {
    public Song marshal(NamedObject v) throws Exception {
        return (Song)v;
    }

    public NamedObject unmarshal(Song v) throws Exception {
        return v;
    }
}

@XmlType
@XmlJavaTypeAdapter(BookAdapter.class)
@XmlJavaTypeAdapter(SongAdapter.class)
public interface NamedObject {
    @XmlAttribute
    public String getName();
}
{code}

So every person who wants to add another POJO, like Song, has to add a line to 
NamedObject.java.

Having an interface, like NamedObject, know about its implementations just 
isn't a scalable way to re-use code. 

I need a way to implement POJOs like Book and Song without touching 
NamedObject.java or NamedObjectService.java.

Is it clear now?

Thanks,

Greg
                
> Generic interface and Implementation
> ------------------------------------
>
>                 Key: CXF-3722
>                 URL: https://issues.apache.org/jira/browse/CXF-3722
>             Project: CXF
>          Issue Type: Bug
>    Affects Versions: 2.2
>         Environment: CXF 2.2.6
> JAVA 6 
> Windows XP
> Tomcat 6 
> Code First
>            Reporter: Deboschère Tony
>            Assignee: Daniel Kulp
>            Priority: Minor
>             Fix For: Invalid
>
>
> I ve createad a Generic interface, let say IGenericInterface<TYPE extends 
> MyAbstracTypeOne, TYPE2 extends MyAbstractTypeTwo>
> In this interface  are some méthode like : 
> public TYPE getTypeFromType2(TYPE2);
> In another interface I extends IGenericInterface
> and add some specific methods 
> ex : 
> @WebService
> ISpecificInterface extends IgenericInterface<MySubTypeOne, MySubTypeTwo> {
> @WebMethod
> public MySubTypeOne getTest();
> }
> When I implement ISpecificInterface in an implementation class, then add the 
> @Webservice @WebResult and other @WebParam  and launch my server 
> I do see a web service with two methods in the wsdl
> getTest and getTypeFromType2.
> But the second method returns xml corresponding to the abstractType 
> MyAbstracTypeOne and not MySubTypeOne
> PS : I launch the webservice serverside via : 
> Object webServiceImpl = webServiceClass.newInstance();
> Endpoint endpoint = Endpoint.create(webServiceImpl);
> endpoint.publish("/" + name);

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


Reply via email to