You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Steve Cowx <st...@gmail.com> on 2009/10/02 01:35:11 UTC

Questions about some Tapestry core code

Hi

I have a few questions, I am looking for understanding rather than a
solution to any particular problem.

The following code comes from the
org.apache.tapestry.services.TapestryModule

/**
     * A wrapper around {@link
<%7...@link>org.apache.tapestry5.internal.services.PageRenderQueue} used
for partial
page renders.
     * Supports an ordered configuration of {@link
<%7...@link>org.apache.tapestry5.services.PartialMarkupRendererFilter}s.
     *
     * @see
#contributePartialMarkupRenderer(org.apache.tapestry5.ioc.OrderedConfiguration,
org.apache.tapestry5.Asset,
     *      org.apache.tapestry5.ioc.services.SymbolSource, AssetSource)
     */
    public PartialMarkupRenderer buildPartialMarkupRenderer(Logger logger,

List<PartialMarkupRendererFilter> configuration,
                                                            @Autobuild
PartialMarkupRendererTerminator terminator)
    {
        return pipelineBuilder.build(logger, PartialMarkupRenderer.class,
PartialMarkupRendererFilter.class,
                                     configuration, terminator);
    }


The questions that I have relate to the code above:

1) What is the type of the instance of the class that gets built by the
pipelineBuilder (ignoring the fact that it is a proxy)?  I would have
expected it to be a PartialMarkupRenderer but some experimenting has led me
to believe that it may be an instance of a
PartialMarkupRendererFilter.   The source of my confusion is that  I have
built an almost exact replica of the setup in the TapestryModule for this
particular pipeline (using all my own mirror interfaces to avoid
ambigouity). I have then injected my service into a component and called a
service method on the injected instance and received the following
error "Method
void renderMarkup(org.apache.tapestry5.MarkupWriter,
org.apache.tapestry5.json.JSONObject) has no match in filter
interface com.mypackage.PartialMarkupRendererFilter."  suggesting that an
instance of the Filter that was injected into my component and not an
instance of the service (which does have that method)

2) If I was to copy the above code exactly and paste it into my own module
then change the name to  buildMyOwnPartialMarkupRenderer()
     a) how would I disambiguate the two services which were built (i.e. the
one in the TapestryModule and the one in my module) so that I did not get
the error "Automatic dependency resolution requires that exactly one service
implement the interface".
     b) Assumin gthat this is possible how would I then disambiguate in the
page or a component where the service is to be injected.
     c) would the List of PartialMarkupRendererFilters which gets passed
into my builder method be the same instance that gets passed in to the
TapestryModule builder method?

Regards

Stephen

Re: Questions about some Tapestry core code

Posted by Steve Cowx <st...@gmail.com>.
hi Howard

Thanks for the reply, based on your description I seem to be on the right
track with the filters and the pipeline, so I will keep plugging away until
I get it right.

As far as the disambiguation goes, I have read the documentation and tried a
few things from the docs out but was not having any luck so I thought I
would ask.  It is helpful to know that it definitely is possible to have the
same interface represented in different services.   I will give the @Local a
try and will also revisit the docs to see what vital bit of info I have
missed.

Regards

Stephen


On Fri, Oct 2, 2009 at 12:47 AM, Howard Lewis Ship <hl...@gmail.com> wrote:

> Have you read the documentation?  There's a careful relationship
> between the main service interface and the related filter interface.
>
> Disambiguation can be by explicit service id (a last resort) or by
> using marker annotation, including the special built-in @Local
> annotation.  You can also help with disambiguation ... check the docs
> about overriding services.
>
> You will not get that list of filters anywhere but contributed into
> the service implementation (or service builder method).
>
> Remember; filters wrap around services.  Each filter sees the service
> as its delegate (the extra parameter). If you have multiple filters,
> the delegate is actually a special bridge to the next filter (!).
> The service itself is the stack of filters plus a terminator (which
> implements the service interface) ... one is supplied if you don't
> provide a terminator.
>
> So the first step is to define your own service and filter interfaces.
>
> The final service, which can be injected into pages, represents that
> whole stack: the filters, the bridges, the terminator. It also
> includes the lazy instantiation of the whole stack.
>
> The PipelineBuilder returns an object that implements the service
> interface: either the terminator itself, or the bridge around the
> outermost filter.
>
> It's fun stuff!
>
> On Thu, Oct 1, 2009 at 4:35 PM, Steve Cowx <st...@gmail.com> wrote:
> > Hi
> >
> > I have a few questions, I am looking for understanding rather than a
> > solution to any particular problem.
> >
> > The following code comes from the
> > org.apache.tapestry.services.TapestryModule
> >
> > /**
> >     * A wrapper around {@link
> > <%7...@link>org.apache.tapestry5.internal.services.PageRenderQueue} used
> > for partial
> > page renders.
> >     * Supports an ordered configuration of {@link
> > <%7...@link>org.apache.tapestry5.services.PartialMarkupRendererFilter}s.
>  >     *
> >     * @see
> >
> #contributePartialMarkupRenderer(org.apache.tapestry5.ioc.OrderedConfiguration,
> > org.apache.tapestry5.Asset,
> >     *      org.apache.tapestry5.ioc.services.SymbolSource, AssetSource)
> >     */
> >    public PartialMarkupRenderer buildPartialMarkupRenderer(Logger logger,
> >
> > List<PartialMarkupRendererFilter> configuration,
> >                                                            @Autobuild
> > PartialMarkupRendererTerminator terminator)
> >    {
> >        return pipelineBuilder.build(logger, PartialMarkupRenderer.class,
> > PartialMarkupRendererFilter.class,
> >                                     configuration, terminator);
> >    }
> >
> >
> > The questions that I have relate to the code above:
> >
> > 1) What is the type of the instance of the class that gets built by the
> > pipelineBuilder (ignoring the fact that it is a proxy)?  I would have
> > expected it to be a PartialMarkupRenderer but some experimenting has led
> me
> > to believe that it may be an instance of a
> > PartialMarkupRendererFilter.   The source of my confusion is that  I have
> > built an almost exact replica of the setup in the TapestryModule for this
> > particular pipeline (using all my own mirror interfaces to avoid
> > ambigouity). I have then injected my service into a component and called
> a
> > service method on the injected instance and received the following
> > error "Method
> > void renderMarkup(org.apache.tapestry5.MarkupWriter,
> > org.apache.tapestry5.json.JSONObject) has no match in filter
> > interface com.mypackage.PartialMarkupRendererFilter."  suggesting that an
> > instance of the Filter that was injected into my component and not an
> > instance of the service (which does have that method)
> >
> > 2) If I was to copy the above code exactly and paste it into my own
> module
> > then change the name to  buildMyOwnPartialMarkupRenderer()
> >     a) how would I disambiguate the two services which were built (i.e.
> the
> > one in the TapestryModule and the one in my module) so that I did not get
> > the error "Automatic dependency resolution requires that exactly one
> service
> > implement the interface".
> >     b) Assumin gthat this is possible how would I then disambiguate in
> the
> > page or a component where the service is to be injected.
> >     c) would the List of PartialMarkupRendererFilters which gets passed
> > into my builder method be the same instance that gets passed in to the
> > TapestryModule builder method?
> >
> > Regards
> >
> > Stephen
> >
>
>
>
> --
> Howard M. Lewis Ship
>
> Creator of Apache Tapestry
>
> The source for Tapestry training, mentoring and support. Contact me to
> learn how I can get you up and productive in Tapestry fast!
>
> (971) 678-5210
> http://howardlewisship.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Kind regards

Stephen Cowx
+44 (0) 7748 490 323
+44 (0) 1306 740 523

Re: Questions about some Tapestry core code

Posted by Howard Lewis Ship <hl...@gmail.com>.
Have you read the documentation?  There's a careful relationship
between the main service interface and the related filter interface.

Disambiguation can be by explicit service id (a last resort) or by
using marker annotation, including the special built-in @Local
annotation.  You can also help with disambiguation ... check the docs
about overriding services.

You will not get that list of filters anywhere but contributed into
the service implementation (or service builder method).

Remember; filters wrap around services.  Each filter sees the service
as its delegate (the extra parameter). If you have multiple filters,
the delegate is actually a special bridge to the next filter (!).
The service itself is the stack of filters plus a terminator (which
implements the service interface) ... one is supplied if you don't
provide a terminator.

So the first step is to define your own service and filter interfaces.

The final service, which can be injected into pages, represents that
whole stack: the filters, the bridges, the terminator. It also
includes the lazy instantiation of the whole stack.

The PipelineBuilder returns an object that implements the service
interface: either the terminator itself, or the bridge around the
outermost filter.

It's fun stuff!

On Thu, Oct 1, 2009 at 4:35 PM, Steve Cowx <st...@gmail.com> wrote:
> Hi
>
> I have a few questions, I am looking for understanding rather than a
> solution to any particular problem.
>
> The following code comes from the
> org.apache.tapestry.services.TapestryModule
>
> /**
>     * A wrapper around {@link
> <%7...@link>org.apache.tapestry5.internal.services.PageRenderQueue} used
> for partial
> page renders.
>     * Supports an ordered configuration of {@link
> <%7...@link>org.apache.tapestry5.services.PartialMarkupRendererFilter}s.
>     *
>     * @see
> #contributePartialMarkupRenderer(org.apache.tapestry5.ioc.OrderedConfiguration,
> org.apache.tapestry5.Asset,
>     *      org.apache.tapestry5.ioc.services.SymbolSource, AssetSource)
>     */
>    public PartialMarkupRenderer buildPartialMarkupRenderer(Logger logger,
>
> List<PartialMarkupRendererFilter> configuration,
>                                                            @Autobuild
> PartialMarkupRendererTerminator terminator)
>    {
>        return pipelineBuilder.build(logger, PartialMarkupRenderer.class,
> PartialMarkupRendererFilter.class,
>                                     configuration, terminator);
>    }
>
>
> The questions that I have relate to the code above:
>
> 1) What is the type of the instance of the class that gets built by the
> pipelineBuilder (ignoring the fact that it is a proxy)?  I would have
> expected it to be a PartialMarkupRenderer but some experimenting has led me
> to believe that it may be an instance of a
> PartialMarkupRendererFilter.   The source of my confusion is that  I have
> built an almost exact replica of the setup in the TapestryModule for this
> particular pipeline (using all my own mirror interfaces to avoid
> ambigouity). I have then injected my service into a component and called a
> service method on the injected instance and received the following
> error "Method
> void renderMarkup(org.apache.tapestry5.MarkupWriter,
> org.apache.tapestry5.json.JSONObject) has no match in filter
> interface com.mypackage.PartialMarkupRendererFilter."  suggesting that an
> instance of the Filter that was injected into my component and not an
> instance of the service (which does have that method)
>
> 2) If I was to copy the above code exactly and paste it into my own module
> then change the name to  buildMyOwnPartialMarkupRenderer()
>     a) how would I disambiguate the two services which were built (i.e. the
> one in the TapestryModule and the one in my module) so that I did not get
> the error "Automatic dependency resolution requires that exactly one service
> implement the interface".
>     b) Assumin gthat this is possible how would I then disambiguate in the
> page or a component where the service is to be injected.
>     c) would the List of PartialMarkupRendererFilters which gets passed
> into my builder method be the same instance that gets passed in to the
> TapestryModule builder method?
>
> Regards
>
> Stephen
>



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org