You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ws.apache.org by Amila Suriarachchi <am...@gmail.com> on 2011/08/03 14:14:38 UTC

Axiom build method does not build the whole Axiom node.

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/

Re: Axiom build method does not build the whole Axiom node.

Posted by Andreas Veithen <an...@gmail.com>.
On Fri, Aug 5, 2011 at 06:46, Amila Suriarachchi
<am...@gmail.com> wrote:
>
>
> On Fri, Aug 5, 2011 at 1:51 AM, Andreas Veithen <an...@gmail.com>
> wrote:
>>
>> On Thu, Aug 4, 2011 at 07:44, Amila Suriarachchi
>> <am...@gmail.com> wrote:
>> >
>> >
>> > On Wed, Aug 3, 2011 at 11:18 PM, Andreas Veithen
>> > <an...@gmail.com>
>> > 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?

There is no such thing as "_only_ building the element itself". If the
element was constructed based on a parser event, then calling build()
will make sure that Axiom has processed all events from the parser
until the END_ELEMENT event. Therefore it will also build the
children.

> The idea of this code is to read the whole input stream into Axiom object
> structure before returning the
> thread.

That is what Axiom will do in this case.

>>
>> > 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
>> >> <am...@gmail.com> 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: dev-unsubscribe@ws.apache.org
>> >> For additional commands, e-mail: dev-help@ws.apache.org
>> >>
>> >
>> >
>> >
>> > --
>> > Amila Suriarachchi
>> > WSO2 Inc.
>> > blog: http://amilachinthaka.blogspot.com/
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@ws.apache.org
>> For additional commands, e-mail: dev-help@ws.apache.org
>>
>
>
>
> --
> Amila Suriarachchi
> WSO2 Inc.
> blog: http://amilachinthaka.blogspot.com/
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ws.apache.org
For additional commands, e-mail: dev-help@ws.apache.org


Re: Axiom build method does not build the whole Axiom node.

Posted by Amila Suriarachchi <am...@gmail.com>.
On Fri, Aug 5, 2011 at 1:51 AM, Andreas Veithen
<an...@gmail.com>wrote:

> On Thu, Aug 4, 2011 at 07:44, Amila Suriarachchi
> <am...@gmail.com> wrote:
> >
> >
> > On Wed, Aug 3, 2011 at 11:18 PM, Andreas Veithen <
> andreas.veithen@gmail.com>
> > 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
> >> <am...@gmail.com> 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: dev-unsubscribe@ws.apache.org
> >> For additional commands, e-mail: dev-help@ws.apache.org
> >>
> >
> >
> >
> > --
> > Amila Suriarachchi
> > WSO2 Inc.
> > blog: http://amilachinthaka.blogspot.com/
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: dev-help@ws.apache.org
>
>


-- 
Amila Suriarachchi
WSO2 Inc.
blog: http://amilachinthaka.blogspot.com/

Re: Axiom build method does not build the whole Axiom node.

Posted by Andreas Veithen <an...@gmail.com>.
On Thu, Aug 4, 2011 at 07:44, Amila Suriarachchi
<am...@gmail.com> wrote:
>
>
> On Wed, Aug 3, 2011 at 11:18 PM, Andreas Veithen <an...@gmail.com>
> 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.

> 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.

>
>>
>> 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
>> <am...@gmail.com> 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: dev-unsubscribe@ws.apache.org
>> For additional commands, e-mail: dev-help@ws.apache.org
>>
>
>
>
> --
> Amila Suriarachchi
> WSO2 Inc.
> blog: http://amilachinthaka.blogspot.com/
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ws.apache.org
For additional commands, e-mail: dev-help@ws.apache.org


Re: Axiom build method does not build the whole Axiom node.

Posted by Amila Suriarachchi <am...@gmail.com>.
On Wed, Aug 3, 2011 at 11:18 PM, Andreas Veithen
<an...@gmail.com>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?

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.

Anyway having a method for build all is a useful feature :).



> 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.

thanks,
Amila.

>
> Andreas
>
> On Wed, Aug 3, 2011 at 14:14, Amila Suriarachchi
> <am...@gmail.com> 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: dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: dev-help@ws.apache.org
>
>


-- 
Amila Suriarachchi
WSO2 Inc.
blog: http://amilachinthaka.blogspot.com/

Re: Axiom build method does not build the whole Axiom node.

Posted by Andreas Veithen <an...@gmail.com>.
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."

A workaround would be to request the first child (so that the
OMSourcedElement is expanded and a builder is created) before calling
build().

Andreas

On Wed, Aug 3, 2011 at 14:14, Amila Suriarachchi
<am...@gmail.com> 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: dev-unsubscribe@ws.apache.org
For additional commands, e-mail: dev-help@ws.apache.org