Make JAXWS-based webservice implement interface and unmarshall to known POJOs
Posted
by John K
on Stack Overflow
See other posts from Stack Overflow
or by John K
Published on 2010-04-15T03:40:24Z
Indexed on
2010/04/15
3:43 UTC
Read the original article
Hit count: 476
Given a Java SE 6 client, I would like to provide a configurable back-end: either directly to a database or through a web service which connects to a centralized DB. To that end, I've created some JPA- and JAXB-annotated entity classes and a DAO interface in a POJO library like the following:
public interface MyDaoInterface {
public MyEntity doSomething();
}
@javax.persistence.Entity
@javax.xml.bind.annotation.XmlRootElement
public class MyEntity {
private int a;
....
}
Now, I would like to have my auto-generated web service stubs implement that interface and interact with my defined entity classes, rather than the generated classes provided via the JAX-B unmarshaller. So, the client-side pseudo code would be something like
MyDaoInterface dao;
if (usingWebservice)
dao = new WebserviceDao();
else
dao = new JpaDao();
MyEntity e = dao.doSomething();
Is this possible with JPA, JAXB, JAXWS? Is this even advisable?
Currently we achieve this through a slow manual process of massaging code, copying generating classes, and doing other things that seem just plain wrong to me.
© Stack Overflow or respective owner