You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by Glen Mazza <gl...@verizon.net> on 2008/01/26 23:07:38 UTC

Question about PhaseInterceptorChain class

Team, in the org.apache.cxf.phase.PhaseInterceptorChain (PIC) class, the
listing of phases are populated in the PIC constructor, shown in lines
131 to 136 here:  http://tinyurl.com/ytxfzk

Question: What code is calling this constructor?  I'd like to see where
the list of phases are coming from.  I am guessing it is from a Spring
configuration file, because I can't find the source file making the
constructor call.

Thanks,
Glen



Re: Question about PhaseInterceptorChain class

Posted by Glen Mazza <gl...@verizon.net>.
Thanks Freeman and Dan.  I updated the comments.

Glen

Am Samstag, den 26.01.2008, 21:29 -0500 schrieb Daniel Kulp:
> Glen,
> 
> On Saturday 26 January 2008, Glen Mazza wrote:
> > Team, in the org.apache.cxf.phase.PhaseInterceptorChain (PIC) class,
> > the listing of phases are populated in the PIC constructor, shown in
> > lines 131 to 136 here:  http://tinyurl.com/ytxfzk
> >
> > Question: What code is calling this constructor? 
> 
> Almost always, it would be the PhaseChainCache in the same package.   
> Most critical places that use the phase chains cache them as setting up 
> the chain can be expensive (evaluating all the befores/afters, etc....).   
> I think the fault chains aren't right now, but that's mostly because I 
> never got back to updating those. 
> 
> Note: the "cache" is kind of a misnomer.   PhaseChains are not reusable.   
> In the course of processing a message, the chain is modified as certain 
> interceptors will add "tail" interceptors, possibly remove others, 
> etc...  The cache holds a pre-setup phase chain and then uses the copy 
> constructor to create a new one each time.   The copy constructor is 
> much faster as all the before/after stuff, sorting, etc...  is done.   
> 
> > I'd like to see 
> > where the list of phases are coming from.  I am guessing it is from a
> > Spring configuration file, because I can't find the source file making
> > the constructor call.
> 
> The phases themselves are controlled by the PhaseManager, specifically 
> the PhaseManagerImpl in rt-core.  You can actually add phases by 
> grabbing the PhaseManager from the Bus and adding the phases.
> 
> A couple places you can look:
> 
> 1) Line 532 of org.apache.cxf.endpoint.ClientImpl.   That's where the 
> outgoing chain for the client is setup.
> 
> 2) Line 410 of same class is the incoming side
> 
> 3) Line 157 of OutgoingChainInterceptor - sets up the outgoing side on 
> the server
> 
> 4) org.apache.cxf.transport.ChainInitiationObserver - line 68 is the init 
> of chains for the incoming stuff on the server.
> 
> 
> As I said, the faults aren't using the chaches yet.   For example, if you 
> look at org.apache.cxf.interceptor.InFaultChainInitiatorObserver, (and 
> it's superclass) it creates a new chain for each fault.    That could be 
> updated to use the caches.   The outgoing faults on the server side 
> could as well.
> 
> Does that help?
> 


Re: Question about PhaseInterceptorChain class

Posted by Daniel Kulp <dk...@apache.org>.
Glen,

On Saturday 26 January 2008, Glen Mazza wrote:
> Team, in the org.apache.cxf.phase.PhaseInterceptorChain (PIC) class,
> the listing of phases are populated in the PIC constructor, shown in
> lines 131 to 136 here:  http://tinyurl.com/ytxfzk
>
> Question: What code is calling this constructor? 

Almost always, it would be the PhaseChainCache in the same package.   
Most critical places that use the phase chains cache them as setting up 
the chain can be expensive (evaluating all the befores/afters, etc....).   
I think the fault chains aren't right now, but that's mostly because I 
never got back to updating those. 

Note: the "cache" is kind of a misnomer.   PhaseChains are not reusable.   
In the course of processing a message, the chain is modified as certain 
interceptors will add "tail" interceptors, possibly remove others, 
etc...  The cache holds a pre-setup phase chain and then uses the copy 
constructor to create a new one each time.   The copy constructor is 
much faster as all the before/after stuff, sorting, etc...  is done.   

> I'd like to see 
> where the list of phases are coming from.  I am guessing it is from a
> Spring configuration file, because I can't find the source file making
> the constructor call.

The phases themselves are controlled by the PhaseManager, specifically 
the PhaseManagerImpl in rt-core.  You can actually add phases by 
grabbing the PhaseManager from the Bus and adding the phases.

A couple places you can look:

1) Line 532 of org.apache.cxf.endpoint.ClientImpl.   That's where the 
outgoing chain for the client is setup.

2) Line 410 of same class is the incoming side

3) Line 157 of OutgoingChainInterceptor - sets up the outgoing side on 
the server

4) org.apache.cxf.transport.ChainInitiationObserver - line 68 is the init 
of chains for the incoming stuff on the server.


As I said, the faults aren't using the chaches yet.   For example, if you 
look at org.apache.cxf.interceptor.InFaultChainInitiatorObserver, (and 
it's superclass) it creates a new chain for each fault.    That could be 
updated to use the caches.   The outgoing faults on the server side 
could as well.

Does that help?

-- 
J. Daniel Kulp
Principal Engineer, IONA
dkulp@apache.org
http://www.dankulp.com/blog

Re: Question about PhaseInterceptorChain class

Posted by Freeman Fang <fr...@gmail.com>.
Hi Glen,

You can see the  getChain method in PhaseChainCache.java [1] call this
constructor.

The code piece below show generally how to create the PIC
        PhaseChainCache outboundChainCache = new PhaseChainCache();
        PhaseManager pm = getBus().getExtension(PhaseManager.class);
        List<Interceptor> outList = new ArrayList<Interceptor>();
        outList.add(new SoapPreProtocolOutInterceptor());
        outList.add(new SoapOutInterceptor(getBus()));
        PhaseInterceptorChain outChain = outboundChainCache.get(
pm.getOutPhases(), outList);


[1]
https://svn.apache.org/repos/asf/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseChainCache.java

Best Regards

Freeman
On 1/27/08, Glen Mazza <gl...@verizon.net> wrote:
>
> Team, in the org.apache.cxf.phase.PhaseInterceptorChain (PIC) class, the
> listing of phases are populated in the PIC constructor, shown in lines
> 131 to 136 here:  http://tinyurl.com/ytxfzk
>
> Question: What code is calling this constructor?  I'd like to see where
> the list of phases are coming from.  I am guessing it is from a Spring
> configuration file, because I can't find the source file making the
> constructor call.
>
> Thanks,
> Glen
>
>
>