How to isolate application from generated stubs

View: New views
4 Messages — Rating Filter:   Alert me  

How to isolate application from generated stubs

by metro-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,

I've an application with the classic layers: presentation, business and data access.

In my data access layer, I access an Authorization web service to get user roles.

In order to isolate other layers from DAL, I'd like to use my own domain classes instead of the generated stubs with JAX-WS/JAXB.

Can someone with more experience point to me which a good practice? Would be plain conversion of the stub objects returned from the WS into my domain classes? Or any other solution?

thanks a lot,

Daniel
[Message sent by forum member 'dpmelo' (dpmelo)]

http://forums.java.net/jive/thread.jspa?messageID=353823

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: How to isolate application from generated stubs

by metro-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I believe we have done something similar to what you are talking about. If I understand correctly, here is a suggested way.  (BTW - you still need some of the generated classes, for the port, service, etc - but you can eliminate the equivalent POJOs that make up your domain objects)

1) Your domain [b]POJOs[/b] that you wish to share between the front and backend would be annotated something like this:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Vendor", namespace = "http://dvo.services.myapp.acme.com/")
public class Vendor implements Serializable {

...
...
}



This insures the classes keep their package naming.

2) The resulting .class files should then be packaged into a separate "shared objects" JAR file that will be bundled now into your web service WAR file (our Ant script does not include these in the WEB-INF/classes during WAR creation), instead it adds the "shared objects" JAR to /WEB-INF/lib....AND then.....the same JAR would then be used by the front end app instead of the [i]generated[/i] equivalents that will be created by wsimport usage when you are building the client (the consumer).

3) In the case of building the front end application, we have the Ant script on that side exclude the "generated" POJO equivalents. You wind up w/ 2 jars being used by the front end app - one is the "shared objects" JAR - the exact same one used by the back end (web service) and the other is simply the JAR containing the "generated" stubs (the service interface, the service itself with the methods to return the Port and the constructor for the service instance, etc)   for the service (MINUS the generated [b]POJO[/b] classes - wsimport still generates them, we just discard them).

Hope this helps.  One big caveat:  this idea works as long as you "own" both ends of the wire.  Otherwise, an "external" consumer would not rely on some sort of "generated/provided" artifact required to interact w/ the deployed service - they'd be using the WSDL and building whatever client "stub" was required (say .NET, or even Java) that works in THEIR environment with their tools.
[Message sent by forum member 'mcs130' (mcs130)]

http://forums.java.net/jive/thread.jspa?messageID=353826

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: How to isolate application from generated stubs

by metro-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

That seems to be fine to me. This way, if I change a web service call for a database query, only code in data access layer would need to be changed.

Is there any other approach?
[Message sent by forum member 'dpmelo' (dpmelo)]

http://forums.java.net/jive/thread.jspa?messageID=353833

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: How to isolate application from generated stubs

by metro-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

If you wanna save the namespace annotation on each class it should also work by providing the annotation on the package
[Message sent by forum member 'zulux' (zulux)]

http://forums.java.net/jive/thread.jspa?messageID=354662

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...