Since we’re Java7 on CXF 3.1, I was thinking of ways to make the generated code 
more useful.   There isn’t much we can do about the JAX-WS frontend since the 
spec puts restrictions on that, but the “cxf” frontend allows us some extra 
flexibility.   The main thing I’d like to do is get the Closeable interface 
onto the proxies somehow.  Getting the BindingProvider and Client interfaces 
also fully declared would save a lot of casting as well. 

 I’d like to be able to do something like:

try (MyServicePort port = service.getSOAPPort()) {
  port.makeCall();
}

and have the close method automatically called.  My first thought was to add 
the Closeable interface as the superclass of the SEI.   This works PERFECTLY 
for the clients.   The problem is that we tend to also use the SEI on the 
service implementations and once you do that, you could need to implement all 
the other methods which makes no sense on the clients.  My next hope was do 
change the getSOAPPort() call to something like:

<T extends MyServicePort & Closeable> <T> getSOAPPort();

but the compiler doesn’t seem to like that for return values.  :(

The only other thought I had would be to generate a separate interface 
someplace like:

interface MySoapPortProxy extends MySoapPort, Closeable, BindingProvider, 
Client {
}

and make the methods return that instead.   If they just care about the 
MySoapPort methods, they can just do the normal:

MySoapPort proxy = service.getSOAPPort();

if they want the extra functionality:

MySoapPortProxy proxy = service.getSOAPPort();

I’d need to update the runtime a bit to detect these sub=interfaces, but that’s 
not a big deal.   

Thoughts?  Other ideas?  Another question:  do we generate these pretty much 
empty interfaces as separate classes and thus easy to import/use or as a inner 
interface of the Service?  Not worth pursuing?


-- 
Daniel Kulp
[email protected] - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com

Reply via email to