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 configuration) {
configuration.add(
AliasContribution.create(
PageTemplateLocator.class, locator));
}
public void contributeAssetSource(MappedConfigurationAssetFactory> 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]