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

2007-11-03 Thread Mike Lake


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]



Re: T5: How can I inject a different resource type?

2007-11-01 Thread Mike Lake

Michael Lake wrote:


Basically, I want to be able to store my component .tml files in a 
database.
I've been looking at the code, stepping through the debugger, and it 
seems that I need to implement org.apache.tapestry.ioc.Resource or 
perhaps extend AbstractResource.
ClasspathResouce and ContextResource are classes that already extend 
AbstractResource. I assume these are what load the .tml files either 
from classpath or from a file on the context.


I'm having trouble navigating the code to the point where I could tell 
a component to choose a resource( content of .tml) from an alternate 
storage. Can someone point me in the right direction?


I'm not afraid of editing tapesty base code if I have to, although I'd 
rather not (perhaps I can inject a custom implementation?)


I'm scared I might be limited to providing the .tml content via 
URL..is that so?


Thanks
Michael Lake

after more digging, i can see I need to provide an AssetFactory...

lets say
DatabaseAssetFactory
which could return a DatabaseResource which would implement Resource

I'll need something like @Marker(DatabaseProvider.class) which is in 
InternalModule..



...I'll keep digging..

-mike

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]