Classification: UNCLASSIFIED
Caveats: NONE

Hi, Simon,

Appreciate the quick response. I'll create a JIRA right away and attach the two 
modified classes for you to play with.

For the 2.0 policy, if it saves your time, I can send you my policy extension 
code. It's really a simple prototype. Let me know.

Thanks again.
Gang

-----Original Message-----
From: Simon Laws [mailto:[email protected]] 
Sent: Monday, January 24, 2011 5:01 PM
To: [email protected]
Subject: Re: An issue with PolicyHandler extension framework - a bug or design 
flaw? (UNCLASSIFIED)

On Mon, Jan 24, 2011 at 9:51 PM, Yang, Gang CTR US USA
<[email protected]> wrote:
> Classification: UNCLASSIFIED
> Caveats: NONE
>
> Hi, Simon and others,
>
>
>
> I'm reposting this because I found my earlier post was grouped under an old
> topic and it may be why I did not receive any response, which I badly hope
> to hear. To provide a background, I'm trying to write a Policy extension to
> add a new WS-security implementation to WS binding in Tuscany. In my earlier
> post (see http://www.mail-archive.com/[email protected]/msg15333.html),
> I described the problems with Tuscany 1.6.x Policy extension framework using
> PolicyInterceptor approach and got some pointers from Simon, one is to try
> Tuscany 2.0 and the other is to use the PolicyHandler extension in Tuscany
> 1.6.x.
>
>
>
> I did not get any response for my request for help on the 2.0 Policy
>
> issues (see
> http://www.mail-archive.com/[email protected]/msg15353.html), so I went
> ahead down to
>
> the second path Simon suggested - to work with PolicyHandler extension
>
> point in 1.6.x.
>
>
>
> Everything went well on the reference side until I was testing on the
>
> service side. I think the current PolicyHandler extension framework has
>
> a defect when processing the PolicyHandler.afterInvoke() call for the
> service side and the model does not fit the need to add WS-security to the
> binding.ws.axis2 binding implementation. Today PolicyHandler.afterInvoke()
> is call with the OMElement response and MessageContext inMC, which is still
> the message context for the inbound request. In order to add WS-security to
> the response, I need to access the message context for the outbound
> response.
>
>
>
> So I modified Axis2ServiceInOutSyncMessageReceiver and
>
> Axis2ServiceProvider classes to delay the calling of
> PolicyHandler.afterInvoke()
>
> from inside Axis2ServiceProvider.invokeTarget() before outMC is constructed
> to after outMC has been constructed in
> Axis2ServiceInOutSyncMessageReceiver.invokeBusinessLogic(). After the
> change, my prototype worked and it also passed all unit tests.
>
>
>
> Now I would like to hear Tuscany developers' opinions and/or get your
> blessing. If this change is fine, how can it be pulled back into the code
> base? If not, what can be done to support what I would like to do, which is
> pretty natural and generic.
>
>
>
> I would really appreciate responses so our project can make a decision.
>
>
>
> Thanks in advance,
>
> Gang
>
>
>
> PS:
>
> The following is the code segments to high light the change I made (with
> "Gang: ..." comments):
>
>
>
> Axis2ServiceInOutSyncMessageReceiver.invokeBusinessLogic(...) {
>
>                 ....
>
>             OMElement responseOM =
> (OMElement)provider.invokeTarget(operation, args, inMC);
>
>
>
>             /*
>
>             for ( PolicyHandler policyHandler : policyHandlerList ) {
>
>                 policyHandler.afterInvoke(operation, args, inMC,
> responseOM);
>
>             }
>
>             */
>
>
>
>             SOAPEnvelope soapEnvelope =
> getSOAPFactory(inMC).getDefaultEnvelope();
>
>             if (null != responseOM ) {
>
>                 soapEnvelope.getBody().addChild(responseOM);
>
>             }
>
>             outMC.setEnvelope(soapEnvelope);
>
>
>     outMC.getOperationContext().setProperty(Constants.RESPONSE_WRITTEN,
> Constants.VALUE_TRUE);
>
>
>
>             // Gang: Added
>
>             for ( PolicyHandler policyHandler : policyHandlerList ) {
>
>                 policyHandler.afterInvoke(responseOM, outMC);
>
>             }
>
>                 ...
>
> }
>
>
>
> Axis2ServiceProvider.invokeTarget(...) {
>
>           ...
>
>         // find the runtime wire and invoke it with the message
>
>         RuntimeWire wire =
> ((RuntimeComponentService)contract).getRuntimeWire(getBinding());
>
>         Object response =  wire.invoke(op, msg);
>
>
>
>         // Gang: Commented out
>
>         // for ( PolicyHandler policyHandler : policyHandlerList ) {
>
>         //    policyHandler.afterInvoke(response, inMC);
>
>         //}
>
>
>
>         return response;
>
> }
>
>
>
>
>
>
>
>
>
> Classification: UNCLASSIFIED
> Caveats: NONE
>
>

Hi Gang

It seems reasonable to me at first glance.

I'd like to see it running. A way for me to do this and to get it into
Tuscany is for you to create a JIRA and attach your patch to it. I can
then apply it locally and take a look at it.

Sorry I didn't notice your 2.x question. It is in my reader but I just
missed it amongst other stuff. I'd like to make sure that we can do
the same thing in 2.x as that is where most development is happening.
What I could possibly do when I get 5 minutes is create some policy
interceptors which shows you how to get hold of the MC at the before
and after locations on reference and server. If in the future you want
to move up to 2.x then we'd be more comfortable that the code does
what you need it to.

Regards

Simon

-- 
Apache Tuscany committer: tuscany.apache.org
Co-author of a book about Tuscany and SCA: tuscanyinaction.com

Classification: UNCLASSIFIED
Caveats: NONE


Reply via email to