Decorating will probably work, but you can also construct the service from 
within your contributing method:

public static void contributeServiceOverride(MappedConfiguration<Class, Object> 
configuration, @ContextProvider AssetFactory contextAssetFactory, 
ComponentClassResolver componentClassResolver)
{
    configuration.add(PageTemplateLocator.class, new 
PageTemplateLocatorFileSystemImpl(contextAssetFactory.getRootResource(), 
componentClassResolver));
}
        


On Thu, 06 May 2010 00:11:51 +0200, MauricioF <mauricio.fara...@ioko.com> wrote:


Mmmmm, overriding makes T5 throw an exception

Caused by: org.apache.tapestry5.ioc.internal.OperationException: Service
interface org.apache.tapestry5.internal.services.PageTemplateLocator is
matched by 2 services: PageTemplateLocator, PageTemplateLocatorFileBased.
Automatic dependency resolution requires that exactly one service implement
the interface.

What I´ve done:
In my module

        @ServiceId("TemplateFileSystem")
        public static PageTemplateLocator
buildPageTemplateLocatorFileBased(@ContextProvider
                    AssetFactory contextAssetFactory,

        ComponentClassResolver componentClassResolver)
        {
                  return new
PageTemplateLocatorFileSystemImpl(contextAssetFactory.getRootResource(),
componentClassResolver);
        }
        
    public ComponentTemplateSource
buildComponentTemplateSource(TemplateParser parser,
@InjectService("TemplateFileSystem") PageTemplateLocator locator,
            ClasspathURLConverter classpathURLConverter)
    {
        ComponentTemplateSourceImpl service = new
ComponentTemplateSourceImpl(parser, locator, classpathURLConverter);
        return service;
    }


As you can see it doe not matter if I add the serviceId and then inject the
service by name!
The problem is that the one which is throwing the exception is in
org.apache.tapestry5.internal.services.InternalModule (which I cannot
modify)

So in this case I cannot override?

An alternative can be decorate the service (ignoring whatever it does and my
small bits of logic
to return a resouce based in the FileSystem) but I´d rather do it using
overriding.

Thanks!

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

Reply via email to