we will possibly soon be realizing an EJB based
framework for an XML application. As I am currently
planning the details, it would be nice to have a
discussion on that. That would help me a lot. Well, here's what I am currently considering.
In particular I would like to know what people
suggest on listXXX() methods returning a very
large quantity of data. My question is: Who to
read only partial results, for example the
first 100 items, then the next 100, and so
on, without performing the query again?
Conventions in addition to EJB standards
All EntityBeans must have a method toXML().
The method result is an XML document.
Some sort Java-XML-binding is used, for
performance reasons. In particular DOM
and JDOM are forbidden.
If the EntityBeans name is SomethingBean, then
the XML document must have a document
type of Something and the class of the corresponding should be ClsSomething.
The Java package of SomethingBean and ClsSomething should the same.
The Java class ClsSomething must
have the following methods:
void toSAX(org.xml.sax.ContentHandler ch)
Marshal itself into a SAX content handler.
void toWriter(java.io.Writer w)
Marshal itself into a Writer.
String toXML(java.io.Writer w)
Marshal itself into a string.
Marshal itself into a DOM document.
static org.xml.sax.ContentHandler getSAXHandler()
Returns a SAX handler for unmarshalling one
or more documents of type Something.
The SAX handler has a method
which may be called after endDocument(). It
returns a successfully parsed instance of ClsSomething. The SAX handler must be able
to be used multiple times. In other words,
the method startDocument() must reset
the SAX handlers state.
static Object fromString(String s)
A shortcut for the use of getSAXHandler(), that
parses and returns a single instance of ClsSomething from the String s.
static Object fromDOM(org.w3c.dom.Document d)
static Object fromDOM(org.w3c.dom.Element e)
static Object fromDOM(org.w3c.dom.ElementFragment ef)
Shortcuts for the use of getSAXHandler(), that
convert a DOM document into an instance of
All EntityBeans should have a method
This constructor will
typically read only those elements from the
XML document, that aren't relevant of the work
flow. The work flow elements will typically
be initialized from defaults or with additional
parameters. In other words: This method will
leave the created entity in an initial state.
All EntityBeans should have a method
This method will update those parts of the XML
document, that aren't relevant for the workflow. The update method
will typically take the XML document, change
the work flow elements to match the current
state. In other words: This method won't change
the entity beans current state.
EntityBeans should not offer methods
like getXXX() or setXXX(), with the exception
of elements responsible for workflow or state.
In particular EntityBeans should not use CMP
(Container Managed Persistence).
EntityBeans should have methods like
Object listXXX(int format, ...)
that return a Collection or List. If the format
is FORMAT_PRIMKEY, then the collection items
must be primary keys of the listed items
and the caller needs to use findByPrimaryKey() to get
access to details. If the format is FORMAT_XML,
then the elements must be instances of ClsSomething. These elements may be incomplete,
for performance reasons. For example, if the document is created as a result of a join, then
the implementation might return the left part
of the join only. The caller may again use
findByPrimaryKey() to get access to details.
If the format is FORMAT_XML_FULL, then the elements must be instances of ClsSomething. These instances must be complete, as returned by findByPrimaryKey().asXML().
If the listXXX() methods return, then they