oh. right. another option is to look up decoration.

So instead of whole-sale replacing it, you can "decorate" the default service with your own logic. Pretty easy.


On 3/18/09 10:11 AM, Robert Zeigler wrote:
There are two services:
Alias
AliasOverrides.
Alias is intended for services that can be overridden. (ie, when there
might be multiple services implementing the same interface and you want
to specify, by default, which to use).
AliasOverrides is intended for when you want to override the default.
So, you should be contributing to AliasOverrides, really.

Your problem here is that your url encoder implementation apparently has
dependencies that rely on the alias service.
This is /really/ easy to hit, I've found, unfortunately.

If you're on 5.1, you could try the new "ServiceOverride" service; that
/might/ help you.

If you're providing your own URLEncoder implementation, then sometimes
"recursion problems" are helped by doing something like:

public static void contributeAliasOverrides(@Local URLEncoder encoder);

But YMMV.

Robert

On Mar 17, 2009, at 3/177:48 PM , Angelo Chen wrote:


Hi,

here is my code:
binder.bind(MyURLEncoderImpl.class, MyURLEncoderImpl.class);

public static void contributeAlias( MyURLEncoderImpl enc,
Configuration<AliasContribution> conf ) {
conf.add( AliasContribution.create( URLEncoder.class, enc ) );
}
but still get:

[ERROR] Registry Construction of service 'Alias' has failed due to
recursion: the service depends on itself in some way.


Fernando Padilla wrote:

looks like I might have had another typo?

The function is "contributeAlias", not "contributeAliasOverrides". Not
sure if you have already caught that.

http://tapestry.apache.org/tapestry5/guide/alias.html


but aside from that. can you put up the exact code you have?


Angelo Chen wrote:
Hi,

Thanks for the reply, I tried:
1. there is no AliasConfiguration, I replaced it with AliasContribution
2. got this error:
[ERROR] Registry Construction of service 'AliasOverrides' has failed
due
to
recursion: the service depends on itself in some way. Please check
org.apache.tapestry5.internal.services.AliasManagerImpl(Logger,
Collection)
(at AliasManagerImpl.java:32) via
org.apache.tapestry5.services.TapestryModule.bind(ServiceBinder) (at
TapestryModule.java:150) for references to another service that is
itself
dependent on service 'AliasOverrides'.

any idea?


Fernando Padilla wrote:
Sadly, this feature is aliasing, not override. So technically, you
should not step on the toes of the original service at all..


1) So do not use "withId("URLEncoder")", since there is already a
service with that name. Try changing that to "URLEncoder2".

2) if you bind it to "URLEncoder.class", like you did, then anyone
that
asks for a URLEncoder (@Inject URLEncoder enc), will fail, because
tapestry will see 2 possible matches. So i could bind it to your raw
class for now.

I think this code will work ( but untested ).


binder.bind( MyURLEncoderImpl.class, MyURLEncoderImpl.class );

public static void contributeAliasOverrides( MyURLEncoderImpl enc,
Configuration<AliasConfiguration<?>> conf ) {
conf.add( AliasConfiguration.create( URLEncoder.class, enc ) );
}




On 3/17/09 9:44 AM, Angelo Chen wrote:
Thanks, but can't make it work, here is my code, must be missing
something:

binder.bind(URLEncoder.class,
MyURLEncoderImpl.class).withId("URLEncoder");

public static void contributeAliasOverrides(
@InjectService("URLEncoder") URLEncoder urlencoder,
Configuration<AliasContribution<?>> configuration) {

configuration.add(
AliasContribution.create(
URLEncoder.class, urlencoder));
}



Ulrich Stärk wrote:
I'm sorry. It's not in the ioc documentation but in the alias
section
of
the user guide:
http://tapestry.apache.org/tapestry5/guide/alias.html

Uli

Ulrich Stärk schrieb:
Check the tapestry-ioc documentation on how to override a service.

Ui

Angelo Chen schrieb:
Hi,

I'd like to override the URLEncoder to allow '=' as part of URL,
here
is
what I did:

binder.bind(URLEncoder.class, URLEncoderImpl.class);

but I got this:
2009-03-17 23:58:13.215::WARN: failed app
ava.lang.RuntimeException: Service id 'URLEncoder' has already
been
defined
by org.apache.tapestry5.internal.services.URLEncoderImpl() (at
URLEncoderImpl.java:22) via
org.apache.tapestry5.services.TapestryModule.bind(ServiceBinder) (at

TapestryModule.java:150) and may not be redefined by
org.abx.myapp.t5.services.URLEncoderImpl() (at
URLEncoderImpl.java:22)
via
org.abx.myapp.t5.services.AppModule.bind(ServiceBinder) (at
AppModule.java:42). You should rename one of the service builder
methods.
at
org.apache.tapestry5.ioc.internal.RegistryImpl.<init>(RegistryImpl.java:170)



---------------------------------------------------------------------

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

---------------------------------------------------------------------

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



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





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




--
View this message in context:
http://www.nabble.com/t5%3A-overriding-URLEncoder-tp22562519p22570945.html

Sent from the Tapestry - User mailing list archive at Nabble.com.


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


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


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

Reply via email to