You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Mike Lake <ml...@netvue.com> on 2007/11/03 16:50:44 UTC

T5: Contributing a custom PageTemplateLocator, did I find a bug?

I'm trying to create my own resource type in addition to the 
ClasspathResource (for returning a URL of "classpath:") and the 
ContextResource(for returning a URL of "context:")

What I'm trying to achieve is to add a third resource type which I'm 
calling HttpResource(so I can return a URL of 
"http://hostname.org:80/my_external_template_root/")

I have built and succesfully implemented the following:

HttpResource
HttpAssetFactory
HttpProvider


Now it appears that I need to add my own implementation of 
PageTemplateLocator and I'm contributing it in the following way in my 
AppModule:
-----------------------------------------------------------------------------------------------------
    public static void bind(ServiceBinder binder) {
        binder.bind(PageTemplateLocator.class, 
CustomPageTemplateLocatorImpl.class).withId("HttpPageLocator").withMarker(PLMarker.class);
    }


    @Marker(PLMarker.class)
    public PageTemplateLocator buildHttpPageLocator(
            @HttpProvider AssetFactory httpAssetFactory,
            ComponentClassResolver componentClassResolver
    ) {
        return new 
CustomPageTemplateLocatorImpl(httpAssetFactory.getRootResource(),
                componentClassResolver);
    }


    public static void contributeAliasOverrides(
            @InjectService("HttpPageLocator")PageTemplateLocator locator,
            Configuration<AliasContribution> configuration) {

        configuration.add(
                AliasContribution.create(
                        PageTemplateLocator.class, locator));
    }

    public void contributeAssetSource(MappedConfiguration<String, 
AssetFactory> configuration,
                                      @HttpProvider
                                      AssetFactory httpAssetFactory) {

        configuration.add("http", httpAssetFactory);

    }


    @Marker(HttpProvider.class)
    public AssetFactory buildHttpAssetFactory(ApplicationGlobals globals) {
        return new HttpAssetFactory(_request, globals.getContext());
    }


-----------------------------------------------------------------------------------------------------
Make note of my: method signature with the PageTemplateLocator contibution:
public PageTemplateLocator buildHttpPageLocator( @HttpProvider 
AssetFactory httpAssetFactory ....


shouldn't the Annotation be enough to differentiate between which 
locator is selected?

 From debugging it appears that I've completely knocked out Tapesty's 
PageTemplateLocator
which is found in InternalModule.java:
----------------------------------------------------------------------------------------------------------------
public PageTemplateLocator build(@ContextProvider
    AssetFactory contextAssetFactory,

    ComponentClassResolver componentClassResolver)
    {
        return new 
PageTemplateLocatorImpl(contextAssetFactory.getRootResource(),
                componentClassResolver);
    }
-----------------------------------------------------------------------------------------------------

so you see how the method signature is different than mine?

What am I missing here? Or have I stumbled into something that hasn't 
been fleshed out?

Thanks,
Mike

BTW: Howard, you are a genius





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