You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jun Tsai <ju...@gmail.com> on 2007/05/21 09:36:07 UTC

"withId" not override the service id in T5?

public static void bind(ServiceBinder binder){
	 binder.bind(MyPersistentFieldStorageImpl.class).withId("MyPersistentFieldStrategy");
		
}

public class MyPersistentFieldStorageImpl extends
		ClientPersistentFieldStorageImpl

exception:

Service interface
org.apache.tapestry.internal.services.ClientPersistentFieldStorage is
matched by 2 services: ClientPersistentFieldStorage,
MyPersistentFieldStrategy. Automatic dependency resolution requires
that exactly one service implement the interface.
-- 
Welcome to China Java Users Group(CNJUG).
http://cnjug.dev.java.net

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


Re: "withId" not override the service id in T5?

Posted by Howard Lewis Ship <hl...@gmail.com>.
Tapestry is doing exactly what you told it, just not what you want.

Your implementation has it own id (you see it in the exception).  However,
it's type overlaps the built-in ClientPersistentFieldStorage class.

When Tapestry tries to resolve the injection by that type, it sees both
services.

The solution is to choose one and contribute it into the Alias or
AliasOverrides service configuration.  i.e.

    public static void contributeAlias(Configuration<AliasContribution>
configuration,
            ObjectLocator locator,

            @InjectService("ComponentClassFactory")
            ClassFactory componentClassFactory,

            @InjectService("DefaultDataTypeAnalyzer")
            DataTypeAnalyzer dataTypeAnalyzer)
    {
        add(configuration, locator, ComponentEventResultProcessor.class,
ObjectRenderer.class);

        configuration.add(AliasContribution.create(ClassFactory.class,
componentClassFactory));
        configuration.add(AliasContribution.create(DataTypeAnalyzer.class,
dataTypeAnalyzer));
    }


(this is from TapestryModule).  Here you inject using an explicit service
id.

On 5/21/07, Jun Tsai <ju...@gmail.com> wrote:
>
> public static void bind(ServiceBinder binder){
>          binder.bind(MyPersistentFieldStorageImpl.class
> ).withId("MyPersistentFieldStrategy");
>
> }
>
> public class MyPersistentFieldStorageImpl extends
>                 ClientPersistentFieldStorageImpl
>
> exception:
>
> Service interface
> org.apache.tapestry.internal.services.ClientPersistentFieldStorage is
> matched by 2 services: ClientPersistentFieldStorage,
> MyPersistentFieldStrategy. Automatic dependency resolution requires
> that exactly one service implement the interface.
> --
> Welcome to China Java Users Group(CNJUG).
> http://cnjug.dev.java.net
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com