[weld-dev] DocumentStore

Nicklas Karlsson nickarls at gmail.com
Fri Nov 13 16:00:23 EST 2009


Actually this could be something for the seam-dev-list but I assume
that most of them are over here, too and this discussion could be view
from a general "portable extension"-point of view

Anyway, I started to look at porting the Seam Excel module and it's
content delivery mechanism, the stuff in org.jboss.seam.document
(namely, the DocumentStore). I assume a general DocumentStore
extension would be a natural candidate for a CDI extension, yes?

I don't know the history and evolution of the code and most stuff is
probably there for a reason but as I see it, the action is split up in
a Servlet part and a PhaseListener part (for redirects?). Some
questions:

1) Given Servlet 3, JSF 2 and CDI, Is there something in this
architecture that can be simplified? I assume we still can't just dump
the data to the response stream and be done with it?

2) Assuming the redirect is still needed, could we have a
self-registering Servlet 3- style DocumentServlet that would be
available just by dropping in the JAR? And the usage from an JSF
action would be something like

@Inject DocumentStore documentStore;

Document document = documentStore.getDocument();
document.setData(myByteArray);
document.setName("myfile.pdf");
document.setMimeType("application/pdf");
document.show(); // does the redirect;

There could of course be shorthands as

documentStore.PDFDocument.of(myByteArray).show();

And the DocumentServlet would then access the same (conversation
scoped) DocumentStore and deliver the data to the response stream

or perhaps DocumentServlet could have a factory for Document and you
would just do

@Inject Document document;

document.PDFof(myByteArray).show(); // sets mime type etc and redirects

3) Haven't looked at REST-stuff that much, could a DocumentServlet
like this also be used for permanent document delivery with fixed
paths, something like http://localhost/app/documents/secrets/1234 ?

-- 
---
Nik


More information about the weld-dev mailing list