I have a WS ( CarASessionBean )it will call another WS ( CarBProxy ) to create a car details. So inside my CarASessionBean WS has a method call createCar : (In proxy has the same method as well call createCar just it take in CarB object as parameter).
public void createCar(CarA car) {
//here i will call the proxy and here error occur as CarBProxy take in CarB object
...
**carBProxy.createCar(car);**
}
In this case is it possible to use wrapper? I just 开发者_StackOverflowheard about wrapper not much understand what wrapper can do, can rougly guide me how to use wrapper i had reseached through google most example is about primitive type I was wonder is there possible to use wrapper to convert an object to another object. Example from CarA to CarB?
This is referred to as the Adapter Pattern. Depending on the circumstances there's no reason you can't design CarB to wrap a CarA object. However, if you have two preexisting (non interface) classes CarB and CarA, converting one to another is going to be more than just a wrapper. Can you be a little more precise about what you're trying to accomplish?
You could, but you'd be writing this wrapper yourself. There isn't anything built into standard Java that will do this for you. Something interesting in the Eclipse APIs is the IAdaptable interface which may be a pattern you want to use for this.
精彩评论