[jboss-dev-forums] [Embedded JBoss Development] - Re: ShrinkWrap - Descriptors

johnbailey do-not-reply at jboss.com
Tue Sep 29 09:54:37 EDT 2009


I agree they need to be decoupled.  When combined the interface has a bit of mismatch.  This may simply be due to Discritptor being in the name.  The following looks very strange to me:


  | WebArchiveDescriptor webArchiveDescriptor = ...
  | 
  | webArchiveDescriptor.add(path, archive)
  |       .addWebResource(path, asset);
  | 
  | 

The issue I have is neither of those operations really affects the descriptor for the archive, but nothing would tell me that from the usage.  

If the archive behavior was kept as it is today and the WebArchiveDescriptor actually implemented Asset (which is what it is in the end) that will serialize the content to xml prior in the getStream call.  There could then be a builder that creates a unified interface to both WebArchive, and WebArchiveDescriptor.  Internally the builder creates the WebArchiveDescriptor(extends asset), adds it as the web.xml asset for the archive, and delegates to the archive, descriptor, or both as needed.

Could look like the following:


  | WebArchive webArchive = ....
  | WebArchiveBuilder builder = new WebArchiveBuilder(webArchive);
  | 
  | builder.addLibrary(...)
  |       .addWebResource(...)
  |       .addServlet(...);
  | 
  | 


It may be the builder is too generic, but it does seem to better describe what you are doing.  It would also be possible to do the following:


  | WebArchive webArchive = ....
  | WebArchiveDescriptor descriptor = new WebArchiveDescriptor(webArchive);
  | 
  | webArchive.addWebResource(descriptor);
  | 
  | descriptor.addFilter(...)
  |          .addServlet(...);
  | 
  | 

There is a bit more code, but it is more clear when operations affect the archive structure/contents, and when they affect the descriptor.  The nice thing about some unified interface like the builder is there are cases where the operation affects both, like addServlet adding the both the descriptor information and the asset.




View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4257661#4257661

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4257661



More information about the jboss-dev-forums mailing list