A few comments:

1) You have AssetSource in your constructor definition, but you also seem to 
have the field marked with @Inject in your implementation; any particular 
reason? If you're "injecting" via constructor injection, you shouldn't need the 
@Inject annotation on the service field.

2) looking at this now, I'm surprised you need the marker at all in your 
"decorate" method. Normally, decorate will pass in a handle to the original 
service implementation.

3) The recursion is caused by the injection of AssetSource, which, itself, 
depends on cilentinfrastructure. Glad to hear that using the marker annotations 
fixed things.

4) Sorry, I jumped into this thread late, but, if all you're looking to do is 
to override the version/location of blackbird, there's a much easier way to do 
it. :)

Tapestry resolves the blackbird location via symbol. Check out these lines in 
AppModule:

    public static void contributeFactoryDefaults(MappedConfiguration<String, 
String> configuration)
    {
     ...
        configuration.add("tapestry.blackbird.path", 
"org/apache/tapestry5/blackbird_1_0");
        configuration.add("tapestry.blackbird", 
"classpath:${tapestry.blackbird.path}");
     ...
    }

You can easily override those values (the most important one is 
tapestry.blackbird, since that is the symbol tapestry uses everywhere else to 
resolve the component library):

public static void contributeApplicationDefaults(MappedConfiguration<String, 
String> configuration) 
{
    configuration.add("tapestry.blackbird", 
"context:/scripts/blackbird_1_0/blackbird.js");
}

Voila!  No nasty recursions, no services to implement, now tapestry uses your 
customized version of blackbird.

Cheers!

Robert

On Jul 23, 2010, at 7/239:24 AM , Rich wrote:

> Whoops. Seems I spoke too soon. After looking at that code out of context it 
> looked like the @InjectService and @Core are at stakes in the AppModule, and 
> removing @InjectService allowed @Core to resolve through properly. Seems to 
> be working alright now. Thanks Jim and Robert for the help.
> 
> Regards,
> Rich
> 
> Rich wrote:
>> Sure, here is the current code from AppModule and MyClientInfrastructure.
>> 
>> AppModule
>> 
>> |public static ClientInfrastructure
>>   decorateClientInfrastructure(@InjectService("ClientInfrastructure") @Core
>>   ClientInfrastructure original, @InjectService("AssetSource") AssetSource
>>   assetSource) {
>>       return new MyClientInfrastructure(original, assetSource);
>>   }    |
>> 
>> MyClientInfrastructure
>> 
>> |public class MyClientInfrastructure implements ClientInfrastructure {
>> 
>>   private ClientInfrastructure clientInfrastructure;
>>   @Inject private AssetSource assetSource;
>>   private List jsStack = new ArrayList();
>>     public MyClientInfrastructure(ClientInfrastructure original, AssetSource 
>> asource){
>>       this.assetSource = asource;          this.clientInfrastructure = 
>> original;
>>             System.out.println("ClientInfrastructure -> " + 
>> clientInfrastructure);
>>             List assets = this.clientInfrastructure.getJavascriptStack();
>>       for (Iterator i = assets.iterator(); i.hasNext();) {
>>           Asset asset = (Asset) i.next();
>>           if (!asset.toString().contains("blackbird.js")) {
>>               jsStack.add(asset);
>>           } else {
>>               jsStack.add(assetSource.getAsset(null, 
>> "context:/scripts/blackbird_1_0/blackbird.js", null));
>>           }
>>                }
>>   }
>>     public List<Asset> getJavascriptStack() {
>>       return jsStack;
>>   }
>> 
>>   public List<Asset> getStylesheetStack() {
>>       return clientInfrastructure.getStylesheetStack();
>>   }
>> 
>> }
>> 
>> |||At this point I still get a recursion issue on ClientInfrastructure 
>> class. I chose this permutation because that recursion seems potentially 
>> 'easier' to solve than one on Alias or AliasOverrides.
>> 
>> -Rich
>> 
>> Robert Zeigler wrote:
>>> Hey Rich,
>>> 
>>> Can you post the code for your various attempts? I know you said earlier 
>>> you were having issues posting the code... if it still fails, you can try 
>>> e-mailing me directly with the code. In any event, if you're basing your 
>>> code on Jim's code that he posted below, the main thing that stands out to 
>>> me is that messing with AliasOverrides is tricky because it's used in /so/ 
>>> many places, particularly if you're not /very/ explicit about which service 
>>> you want to inject.  One thing you could try is to mark, as appropriate, 
>>> the various injections of the ClientInfrastructure with @Core or @Local, as 
>>> the case may be: when you want tapestry's native service injected, use 
>>> @Core; when you want your version of the service, use @Local.  You might 
>>> try that and see if it helps with the issues where tapestry is complaining 
>>> about recursion.  Theoretically, specifying the serviceid 
>>> (@InjectService("somesersviceid")) should be sufficient, as well, but I've 
>>> found I have better success using the Marker annotations.
>>> 
>>> HTH
>>> 
>>> Robert
>>> 
>>> On Jul 22, 2010, at 7/223:30 PM , Rich wrote:
>>> 
>>> 
>>>> No problem, I appreciate the time and effort. I've got the code using 
>>>> Tapestry 1.5.0.5. I suppose this isn't the biggest bug in the world and 
>>>> with 5.2 on the horizon it might be worth just waiting, but I've also got 
>>>> my curiosity piqued as to the whole service decoration stuff now. I'm 
>>>> still trying to be able to intelligibly build on tapestry rather than just 
>>>> using it, and concepts like this seem to be vital components to that 
>>>> progress.
>>>> 
>>>> Regards,
>>>> Rich
>>>> 
>>>> Jim O'Callaghan wrote:
>>>>   
>>>>> Sorry I can't be of more help Rich - we've migrated over to T5.2.0 so I
>>>>> don't have a pre T5.2.0 environment I can test this under at the moment.
>>>>> You're right though it shouldn't be difficult at all - I've found a lot of
>>>>> these minor things have me banging my head on the desk until someone chips
>>>>> in with the solution, before having the 'ahhh' moment.  Hopefully someone
>>>>> here can steer you straight - what exact version of Tapestry are you 
>>>>> using?
>>>>> 
>>>>> Regards,
>>>>> Jim.
>>>>> 
>>>>> -----Original Message-----
>>>>> From: Rich [mailto:rich...@moremagic.com] Sent: 22 July 2010 20:51
>>>>> To: Tapestry users
>>>>> Subject: Re: blackbird.js and IE breaking fixed CSS background image
>>>>> 
>>>>> No luck still =/
>>>>> 
>>>>> I tried it many ways:
>>>>> decorateClientInfrastructure with contributeAliasOverride with bind:
>>>>> java.lang.IllegalStateException: 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:251) for references to another service that is itself 
>>>>> dependent on service 'AliasOverrides'.
>>>>> 
>>>>> decorateClientInfrastructure without contributeAliasOverride without bind:
>>>>> java.lang.IllegalStateException: Construction of service 
>>>>> 'ClientInfrastructure' has failed due to recursion: the service depends 
>>>>> on itself in some way. Please check 
>>>>> org.apache.tapestry5.internal.services.ClientInfrastructureImpl(SymbolSource
>>>>>  
>>>>> , AssetSource, ThreadLocale) (at ClientInfrastructureImpl.java:64) via 
>>>>> org.apache.tapestry5.services.TapestryModule.bind(ServiceBinder) (at 
>>>>> TapestryModule.java:251) for references to another service that is itself 
>>>>> dependent on service 'ClientInfrastructure'.
>>>>> 
>>>>> decorateClientInfrastructure without contributeAliasOverride with bind:
>>>>> java.lang.RuntimeException: Service interface 
>>>>> org.apache.tapestry5.services.ClientInfrastructure is matched by 2 
>>>>> services: ClientInfrastructure, MyClientInfrastructure.  Automatic 
>>>>> dependency resolution requires that exactly one service implement the 
>>>>> interface.
>>>>> 
>>>>> buildMyClientInfrastructure with contributeAlias:
>>>>> java.lang.IllegalStateException: Construction of service 'Alias' has 
>>>>> failed due to recursion: the service depends on itself in some way. 
>>>>> Please check 
>>>>> org.apache.tapestry5.services.TapestryModule.buildAlias(Logger, String, 
>>>>> AliasManager, Collection) (at TapestryModule.java:325) for references to 
>>>>> another service that is itself dependent on service 'Alias'.
>>>>> 
>>>>> 
>>>>> buildMyClientInfrastructure without contributeAlias:
>>>>> java.lang.RuntimeException: Service interface 
>>>>> org.apache.tapestry5.services.ClientInfrastructure is matched by 2 
>>>>> services: ClientInfrastructure, MyClientInfrastructure.  Automatic 
>>>>> dependency resolution requires that exactly one service implement the 
>>>>> interface.
>>>>> 
>>>>> buildMyClientInfrastructure with contributeAliasOverrides:
>>>>> java.lang.IllegalStateException: 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:251) for references to another service that is itself 
>>>>> dependent on service 'AliasOverrides'.
>>>>> 
>>>>> Errors were pretty similar, and this was about as many permutations as I 
>>>>> could imagine. Can anyone shed some light towards a reasonable way to 
>>>>> decorate the ClientInfrastructure so I can swap the blackbird.js? I find 
>>>>> it hard to believe decoration is this complicated.
>>>>> 
>>>>> Thanks,
>>>>> Rich
>>>>> 
>>>>> Jim O'Callaghan wrote:
>>>>>      
>>>>>> Rich,
>>>>>> 
>>>>>> I'm on T5.2.0 so the code has been updated accordingly - looking through
>>>>>>           
>>>>> my
>>>>>      
>>>>>> file history, I have:
>>>>>> 
>>>>>>          public static MyClientInfrastructure
>>>>>> buildMyClientInfrastructure(@InjectService("ClientInfrastructure")
>>>>>> ClientInfrastructure original, @InjectService("AssetSource") AssetSource
>>>>>> assetSource)
>>>>>>          {
>>>>>>              return new MyClientInfrastructure(original,
>>>>>> assetSource);
>>>>>>          }                public static void contributeAlias(
>>>>>>                @InjectService("MyClientInfrastructure")
>>>>>> ClientInfrastructure cInfraService,
>>>>>>    org.apache.tapestry5.ioc.Configuration<AliasContribution> 
>>>>>> configuration) {
>>>>>>    
>>>>>> configuration.add(AliasContribution.create(ClientInfrastructure.class, 
>>>>>>                    cInfraService));
>>>>>>        }
>>>>>> 
>>>>>> ... in my AppModule.  It's been a while since I looked at it so can't say
>>>>>> for sure but perhaps this is more in line with what is required for
>>>>>> T5.1.0.x.  I think ClientInfrastructure is deprecated in T5.2.0.  Hope
>>>>>>           
>>>>> this
>>>>>      
>>>>>> is of use.
>>>>>> 
>>>>>> Regards,
>>>>>> Jim.
>>>>>> 
>>>>>> -----Original Message-----
>>>>>> From: Rich [mailto:rich...@moremagic.com] Sent: 22 July 2010 16:32
>>>>>> To: Tapestry users
>>>>>> Subject: Re: blackbird.js and IE breaking fixed CSS background image
>>>>>> 
>>>>>> Hi,
>>>>>> 
>>>>>> attempt 6 at getting through spam blocker. I used the code mentioned but 
>>>>>> the "original" object from the decorate method is always null. I'm not 
>>>>>> sure what to do about that?
>>>>>> 
>>>>>> -Rich
>>>>>> 
>>>>>> Jim O'Callaghan wrote:
>>>>>>            
>>>>>>> Hi Rich,
>>>>>>> 
>>>>>>> Yep same guy, guilty as charged.  This may not be the best solution, you
>>>>>>>                   
>>>>>> may
>>>>>>            
>>>>>>> get some better advice from some of the more experienced Tapestry people
>>>>>>>                   
>>>>>> on
>>>>>>            
>>>>>>> the forum, but it's the approach I used.  The post I included earlier 
>>>>>>> was
>>>>>>> indeed about just ensuring a specific order was enforced in the js
>>>>>>>                   
>>>>>> includes
>>>>>>            
>>>>>>> for the ClientInfrastructure, but I have used a variation on it to
>>>>>>>               
>>>>> include
>>>>>      
>>>>>>> my local version of blackbird.js, rather than the one that comes with
>>>>>>> T5.1.0.5.  The code is as follows:
>>>>>>> 
>>>>>>> AppModule.java:
>>>>>>>     public ClientInfrastructure
>>>>>>> decorateClientInfrastructure(ClientInfrastructure original,
>>>>>>> @InjectService("AssetSource") AssetSource assetSource) {
>>>>>>>         return new MyClientInfrastructure(original, assetSource);
>>>>>>>     }
>>>>>>> 
>>>>>>> 
>>>>>>> MyClientInfrastructure.java:
>>>>>>> public class MyClientInfrastructure implements ClientInfrastructure {
>>>>>>> 
>>>>>>>    @Inject
>>>>>>>    AssetSource assetSource;
>>>>>>>        ClientInfrastructure clientInfrastructure;
>>>>>>>   List javascriptStack = new ArrayList();    
>>>>>>> @SuppressWarnings("unchecked")
>>>>>>>    public MyClientInfrastructure(ClientInfrastructure
>>>>>>> clientInfrastructure, AssetSource assetSource) {
>>>>>>>       this.assetSource = assetSource;            
>>>>>>> this.clientInfrastructure = clientInfrastructure;
>>>>>>>       // Add jQuery assets in ahead of Prototype - IE8 was burping
>>>>>>> otherwise, despite jQuery.noConflict being set
>>>>>>>       javascriptStack.add(assetSource.getAsset(null,
>>>>>>> "context:/scripts/jquery-1.4.2.min.js", null));
>>>>>>>       javascriptStack.add(assetSource.getAsset(null,
>>>>>>> "context:/scripts/jquery-ui-1.8.1.custom.min.js", null));
>>>>>>> 
>>>>>>>       List assets = this.clientInfrastructure.getJavascriptStack();
>>>>>>>       for (Iterator i = assets.iterator(); i.hasNext();) {
>>>>>>>           Asset asset = (Asset) i.next();
>>>>>>>           if (!asset.toString().contains("blackbird.js")) {
>>>>>>>               javascriptStack.add(asset);
>>>>>>>           } else {
>>>>>>>               javascriptStack.add(assetSource.getAsset(null,
>>>>>>> "context:/scripts/blackbird_1_0/blackbird.js", null));
>>>>>>>           }
>>>>>>>                  }
>>>>>>>   }
>>>>>>> 
>>>>>>>   public List<Asset> getJavascriptStack() {
>>>>>>>           //return clientInfrastructure.getJavascriptStack();
>>>>>>>           return javascriptStack;
>>>>>>>   }
>>>>>>> 
>>>>>>>   public List<Asset> getStylesheetStack() {
>>>>>>>           return clientInfrastructure.getStylesheetStack();
>>>>>>>   }
>>>>>>> }
>>>>>>> 
>>>>>>> I have my local blackbird.js physically located in the project under
>>>>>>> src\main\webapp\scripts\blackbird_1_0\blackbird.js.
>>>>>>> 
>>>>>>> Obviously the jQuery ordering is not relevant to your specific problem,
>>>>>>>                   
>>>>>> just
>>>>>>            
>>>>>>> the replacement of blackbird.js is.  Probably could be more
>>>>>>> elegant/efficient, but it's just called once at startup so I wasn't too
>>>>>>> concerned about it.
>>>>>>> 
>>>>>>> Hope this get things working for you <and I don't get chewed by the more
>>>>>>> enlightened forum members!>.
>>>>>>> 
>>>>>>> Regards,
>>>>>>> Jim.
>>>>>>>                    
>>>>>>>> -----Original Message-----
>>>>>>>> From: Rich [mailto:rich...@moremagic.com] Sent: 20 July 2010 17:25
>>>>>>>> To: users@tapestry.apache.org
>>>>>>>> Subject: blackbird.js and IE breaking fixed CSS background image
>>>>>>>> 
>>>>>>>> Hi,
>>>>>>>> 
>>>>>>>> I'm aware blackbird.js is not directly Tapestry code, but I'm looking 
>>>>>>>> for advice on how to handle an issue with the blackbird.js file. I had 
>>>>>>>> been having problems with getting the fixed background image in my 
>>>>>>>> tapestry webapp to stay fixed in Internet Explorer. I'd given up 
>>>>>>>> searching for a solution (it appeared to be beyond the CSS I was 
>>>>>>>> using) until someone recently pointed out that a line of code in 
>>>>>>>> blackbird.js breaks the fixed background for IE.
>>>>>>>> 
>>>>>>>> I went and re-jared the tapestry-core with the line of code commented 
>>>>>>>> out and it now works in internet explorer. However, having to manage 
>>>>>>>> my own version of the tapestry-core jar to fix an IE bug does not seem 
>>>>>>>> like
>>>>>>>>                   
>>>>>      
>>>>>>>> a good idea. Is there a way to exclude blackbird from my projects all 
>>>>>>>> together? Or maybe there is some other, better solution?
>>>>>>>> 
>>>>>>>> Regards,
>>>>>>>> Rich
>>>>>>>> 
>>>>>>>>                             
>>>>>> ---------------------------------------------------------------------
>>>>>> 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
>>>>> 
>>>>>       
>>>> ---------------------------------------------------------------------
>>>> 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


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

Reply via email to