RE: DOMWriter proposed change
"Christian Cryder" <[email protected]>
| Newsgroups | gmane.comp.java.enhydra.barracuda.general |
|---|---|
| Message-ID | <[email protected]> |
> I'd like to hear what Christian has to say about this since he wrote the > DefaultDOMWriter originally and came up with the concept of the > setLeaveWriterOpen(boolean) method. I suspect the reason it was Hey guys, I _will_ respond to this, I promise, but its going to be tomorrow before I can get to it. I will try to take a few minutes tonight while I'm studying and ponder it a bit, and then get some kind of opinion put together by tomorrow... Christian ---------------------------------------------- Christian Cryder Internet Architect, ATMReports.com Project Chair, BarracudaMVC - http://barracudamvc.org ---------------------------------------------- "Coffee? I could quit anytime, just not today" > -----Original Message----- > From: [email protected] > [mailto:[email protected]]On Behalf Of Jacob Kjome > Sent: Thursday, October 02, 2003 1:01 PM > To: [email protected] > Subject: Re: [Barracuda] DOMWriter proposed change > > > At 02:03 PM 10/1/2003 -0600, you wrote: > >To: [email protected] > >Subject: [Barracuda] DOMWriter proposed change > > > >Hi folks, > > > >Jake just sent an email mentioning proposed changes to DOMLoader that > >triggered my memory about a change I was thinking of making to DOMWriter > >and DefaultDOMWriter. > > > >Presently the DOMWriter interface provides various versions of a write() > >method (each for different output types). However DOMWriter does not > >provide any explanation (in the comments) as to whether or not the > >implementing class must close the output objects or not. > DefaultDOMWriter > >solves this by providing its own "leaveWriterOpen" option that controls > >this behavior. > > > >My proposal is that we remove the "leaveWriterOpen" option from > >DefaultDOMWriter and provide eplanation in the comments of > DOMWriter that > >implementing class MUST NOT close the output. It should be > stated clearly > >that it is the responsibility of the class(es) using the DOMWriter to > >manually close any output streams. > > Hmm.... I kind of agree with this in principal, but I'm not sure it will > make matters any easier for people. It is just more gruntwork. > > > >My thinking behind this is that since a DOMWriter does not open (create) > >the output stream, it should therefore also not close it. It > should simply > >map input in the form of DOM Nodes to the output. > > The problem is that main use-case for the DefaultDOMWriter is... > > new DefaultDOMWriter().write(dom, vec.getResponse()); > > Here we send the response object to the writer and let the DOMWriter open > up the writer or output stream associated with the response. Since the > DOMWriter opens it, it seems like it should close it. It is also > much less > klunky than.... > > new DefaultDOMWriter().write(dom, vec.getResponse()); > vec.getResponse().getWriter().close(); > > Actually, would we close the writer or output stream here? It > all depends > on what goes on internally in the DOMWriter implementation. > > >Any objections to this change? This shouldn't affect any users > unless they > >are using DefaultDOMWriter or the DOMWriter interface on their own. Is > >anyone using these classes directly in their code? To make the change I > >would have to make sure I find every instance where DefaultDOMWriter is > >used within Barracuda and make sure it does not expect the output stream > >to be automatically closed (adding a manual close where necessary); this > >shouldn't be too hard. > > Hmm... not too hard, but I'm not sure it gains us anything. We > could even > document that it is the responsibility of the implementation to > decide how > it deals with opening and closing of writers and output streams. > > I'd like to hear what Christian has to say about this since he wrote the > DefaultDOMWriter originally and came up with the concept of the > setLeaveWriterOpen(boolean) method. I suspect the reason it was > done this > way was because it is generally the rare case where one would want to > actually leave the writer or output steam open after the call to the > write() method. > > I'm not saying I'm completely opposed to this, just skeptical > that it would > be of benefit. I'd definitely like to hear more discussion on the topic. > > Jake > > >Thanks, > >-shawn > > _______________________________________________ > Barracuda mailing list > [email protected] > http://barracudamvc.org/lists/listinfo/barracuda