On Fri, Aug 5, 2011 at 1:51 AM, Andreas Veithen <[email protected]>wrote:
> On Thu, Aug 4, 2011 at 07:44, Amila Suriarachchi > <[email protected]> wrote: > > > > > > On Wed, Aug 3, 2011 at 11:18 PM, Andreas Veithen < > [email protected]> > > wrote: > >> > >> That is related to the fact that the OMElement is actually an > >> OMSourcedElement. If the element is not expanded, then there is no > >> builder and build() is a no-op. Whether this is the expected behavior > >> in this particular case is subject to interpretation, given that the > >> Javadoc of the method is limited to "Builds itself." > > > > I also looked at the java doc. If you look at the user point of view, is > it > > useful only to have a method which builds that element? I think when you > > access the element that builds itself isn't it? > > No. Axiom only builds what is strictly necessary. If you request the > first child, it will only make sure that the first child is created > (but not necessarily built completely). In most cases (but not all), > calling build() has the same effect as iterating over the children of > that element. > take the following code in Axis2. will that work if the build() only builds that element itself? The idea of this code is to read the whole input stream into Axiom object structure before returning the thread. > > > And also if you look at the following code in AbstractMessage receiver > > > > if ((!WSDLUtil.isOutputPresentForMEP(mep)) > > || (replyTo != null && > !replyTo.hasAnonymousAddress())) > > { > > AsyncMessageReceiverWorker worker = new > > AsyncMessageReceiverWorker( > > messageCtx); > > messageCtx.getEnvelope().build(); > > > > messageCtx.getConfigurationContext().getThreadPool().execute( > > worker); > > return; > > } > > > > We can see It has meant to build all. > > "build all" is not more precise than "Builds itself". Things get > fairly subtle if the tree contains OMSourcedElement instances, OMText > nodes that refer to MTOM attachments or if the element is > programmatically created but has descendants that are linked to a > builder. > > > Anyway having a method for build all is a useful feature :). > > If you can come up with a precise and consistent definition of what > "build" vs "build all" means, then we could consider implementing > that. > Take the Axis2 code example I have given. The idea is to build the whole OMElement structure so that it can be used even after underline data source invalid etc .. thanks, Amila. > > > > >> > >> A workaround would be to request the first child (so that the > >> OMSourcedElement is expanded and a builder is created) before calling > >> build(). > > > > ok. But this assumes OMSourcedElement is in the immediate child. > > No. It assumes that the element on which you call build() is an > OMSourcedElement. The purpose of requesting the first child is simply > to force the expansion of the OMSourcedElement. > > > thanks, > > Amila. > >> > >> Andreas > >> > >> On Wed, Aug 3, 2011 at 14:14, Amila Suriarachchi > >> <[email protected]> wrote: > >> > I did the following test with an generated ADBBean. > >> > > >> > MyInfo myInfo = new MyInfo(); > >> > myInfo.setAge(23); > >> > myInfo.setName("amila"); > >> > > >> > try { > >> > OMElement omElement = > >> > myInfo.getOMElement(GetMyInfo.MY_QNAME, > >> > OMAbstractFactory.getOMFactory()); > >> > omElement.build(); > >> > } catch (ADBException e) { > >> > e.printStackTrace(); > >> > } > >> > > >> > although I call build it does not call to serialize method at the > >> > ADBBean. > >> > But if I call cloneOMElement it calls that. > >> > > >> > is there any other way to build the whole OMElement without traversing > >> > one > >> > by one. > >> > > >> > thanks, > >> > Amila. > >> > > >> > -- > >> > Amila Suriarachchi > >> > WSO2 Inc. > >> > blog: http://amilachinthaka.blogspot.com/ > >> > > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: [email protected] > >> For additional commands, e-mail: [email protected] > >> > > > > > > > > -- > > Amila Suriarachchi > > WSO2 Inc. > > blog: http://amilachinthaka.blogspot.com/ > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > > -- Amila Suriarachchi WSO2 Inc. blog: http://amilachinthaka.blogspot.com/
