You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by garz <ga...@gmx.net> on 2014/01/31 17:05:46 UTC

Override AssertSource

Hi all,

i want to override the AssetSource service. I am doing it like described in http://tapestry.apache.org/ioc-cookbook-overriding-ioc-services.html like this:

	@Contribute(ServiceOverride.class)
	public static void setupApplicationServiceOverrides(
			MappedConfiguration<Class, Object> configuration) {
		configuration.add(AssetSource.class, MyAssetSourceImpl.class);
	}

But the following error occurs:
Exception constructing service 'PageSource': Error invoking method public org.apache.tapestry5.internal.services.PageSource org.apache.tapestry5.internal.services.InternalModule.buildPageSource(org.apache.tapestry5.internal.services.PageSourceImpl,org.apache.tapestry5.services.InvalidationEventHub,org.apache.tapestry5.services.InvalidationEventHub): Exception constructing service 'ComponentMessagesInvalidationEventHub': Error invoking method public static org.apache.tapestry5.services.InvalidationEventHub org.apache.tapestry5.services.TapestryModule.buildComponentMessagesInvalidationEventHub(org.apache.tapestry5.services.messages.ComponentMessagesSource): Exception constructing service 'ComponentMessagesSource': Error invoking service contribution method org.apache.tapestry5.services.TapestryModule.contributeComponentMessagesSource(AssetSource, Resource, OrderedConfiguration): Cannot cast java.lang.Class to org.apache.tapestry5.services.AssetSource

What needs to be done to override the AssetSource service?

Best regards

Re: Override AssertSource

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Fri, 31 Jan 2014 16:29:28 -0200, Dimitris Zenios  
<di...@gmail.com> wrote:

> Create the assetSource inside bind method
> then inject it inside the contributeSerrviceOverride and instead of
> addInstance use plain add

Or just decorate the service instead of overriding it. The result is the  
same, but you avoid the service recursion problems:

public static void decorateAssetSource(AssetSource originalAssetSource,  
ObjectLocator locator) {
	return locator.autobuild(MyAssetSourceImpl.class);
}

Or use service advice instead of overriding or decorating it.

What exactly do you want to do, Garz?

-- 
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

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


Re: Override AssertSource

Posted by Dimitris Zenios <di...@gmail.com>.
Create the assetSource inside bind method
then inject it inside the contributeSerrviceOverride and instead of
addInstance use plain add



On Fri, Jan 31, 2014 at 7:43 PM, garz <ga...@gmx.net> wrote:

> With addInstance the exception is:
>
> java.lang.IllegalStateException: Construction of service 'ServiceOverride'
> has failed due to recursion: the service depends on itself in some way.
> Please check
> org.apache.tapestry5.ioc.internal.services.ServiceOverrideImpl(Map) (at
> ServiceOverrideImpl.java:31) via
> org.apache.tapestry5.ioc.services.TapestryIOCModule.bind(ServiceBinder) (at
> TapestryIOCModule.java:49) for references to another service that is itself
> dependent on service 'ServiceOverride'.
>
> On 31.01.2014, at 17:25, Dusko Jovanovski <du...@gmail.com> wrote:
>
> > try configuration.addInstance(AssetSource.class,
> MyAssetSourceImpl.class);
> >
> > Here's the documentation for MappedConfiguration:
> >
> http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/MappedConfiguration.html
> >
> >
> > On Fri, Jan 31, 2014 at 5:05 PM, garz <ga...@gmx.net> wrote:
> >
> >> Hi all,
> >>
> >> i want to override the AssetSource service. I am doing it like described
> >> in
> http://tapestry.apache.org/ioc-cookbook-overriding-ioc-services.htmllikethis:
> >>
> >>        @Contribute(ServiceOverride.class)
> >>        public static void setupApplicationServiceOverrides(
> >>                        MappedConfiguration<Class, Object>
> configuration) {
> >>                configuration.add(AssetSource.class,
> >> MyAssetSourceImpl.class);
> >>        }
> >>
> >> But the following error occurs:
> >> Exception constructing service 'PageSource': Error invoking method
> public
> >> org.apache.tapestry5.internal.services.PageSource
> >>
> org.apache.tapestry5.internal.services.InternalModule.buildPageSource(org.apache.tapestry5.internal.services.PageSourceImpl,org.apache.tapestry5.services.InvalidationEventHub,org.apache.tapestry5.services.InvalidationEventHub):
> >> Exception constructing service 'ComponentMessagesInvalidationEventHub':
> >> Error invoking method public static
> >> org.apache.tapestry5.services.InvalidationEventHub
> >>
> org.apache.tapestry5.services.TapestryModule.buildComponentMessagesInvalidationEventHub(org.apache.tapestry5.services.messages.ComponentMessagesSource):
> >> Exception constructing service 'ComponentMessagesSource': Error invoking
> >> service contribution method
> >>
> org.apache.tapestry5.services.TapestryModule.contributeComponentMessagesSource(AssetSource,
> >> Resource, OrderedConfiguration): Cannot cast java.lang.Class to
> >> org.apache.tapestry5.services.AssetSource
> >>
> >> What needs to be done to override the AssetSource service?
> >>
> >> Best regards
>
>

Re: Override AssertSource

Posted by garz <ga...@gmx.net>.
With addInstance the exception is:

java.lang.IllegalStateException: Construction of service 'ServiceOverride' has failed due to recursion: the service depends on itself in some way. Please check org.apache.tapestry5.ioc.internal.services.ServiceOverrideImpl(Map) (at ServiceOverrideImpl.java:31) via org.apache.tapestry5.ioc.services.TapestryIOCModule.bind(ServiceBinder) (at TapestryIOCModule.java:49) for references to another service that is itself dependent on service 'ServiceOverride'.

On 31.01.2014, at 17:25, Dusko Jovanovski <du...@gmail.com> wrote:

> try configuration.addInstance(AssetSource.class, MyAssetSourceImpl.class);
> 
> Here's the documentation for MappedConfiguration:
> http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/MappedConfiguration.html
> 
> 
> On Fri, Jan 31, 2014 at 5:05 PM, garz <ga...@gmx.net> wrote:
> 
>> Hi all,
>> 
>> i want to override the AssetSource service. I am doing it like described
>> in http://tapestry.apache.org/ioc-cookbook-overriding-ioc-services.htmllike this:
>> 
>>        @Contribute(ServiceOverride.class)
>>        public static void setupApplicationServiceOverrides(
>>                        MappedConfiguration<Class, Object> configuration) {
>>                configuration.add(AssetSource.class,
>> MyAssetSourceImpl.class);
>>        }
>> 
>> But the following error occurs:
>> Exception constructing service 'PageSource': Error invoking method public
>> org.apache.tapestry5.internal.services.PageSource
>> org.apache.tapestry5.internal.services.InternalModule.buildPageSource(org.apache.tapestry5.internal.services.PageSourceImpl,org.apache.tapestry5.services.InvalidationEventHub,org.apache.tapestry5.services.InvalidationEventHub):
>> Exception constructing service 'ComponentMessagesInvalidationEventHub':
>> Error invoking method public static
>> org.apache.tapestry5.services.InvalidationEventHub
>> org.apache.tapestry5.services.TapestryModule.buildComponentMessagesInvalidationEventHub(org.apache.tapestry5.services.messages.ComponentMessagesSource):
>> Exception constructing service 'ComponentMessagesSource': Error invoking
>> service contribution method
>> org.apache.tapestry5.services.TapestryModule.contributeComponentMessagesSource(AssetSource,
>> Resource, OrderedConfiguration): Cannot cast java.lang.Class to
>> org.apache.tapestry5.services.AssetSource
>> 
>> What needs to be done to override the AssetSource service?
>> 
>> Best regards


Re: Override AssertSource

Posted by Dusko Jovanovski <du...@gmail.com>.
try configuration.addInstance(AssetSource.class, MyAssetSourceImpl.class);

Here's the documentation for MappedConfiguration:
http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/MappedConfiguration.html


On Fri, Jan 31, 2014 at 5:05 PM, garz <ga...@gmx.net> wrote:

> Hi all,
>
> i want to override the AssetSource service. I am doing it like described
> in http://tapestry.apache.org/ioc-cookbook-overriding-ioc-services.htmllike this:
>
>         @Contribute(ServiceOverride.class)
>         public static void setupApplicationServiceOverrides(
>                         MappedConfiguration<Class, Object> configuration) {
>                 configuration.add(AssetSource.class,
> MyAssetSourceImpl.class);
>         }
>
> But the following error occurs:
> Exception constructing service 'PageSource': Error invoking method public
> org.apache.tapestry5.internal.services.PageSource
> org.apache.tapestry5.internal.services.InternalModule.buildPageSource(org.apache.tapestry5.internal.services.PageSourceImpl,org.apache.tapestry5.services.InvalidationEventHub,org.apache.tapestry5.services.InvalidationEventHub):
> Exception constructing service 'ComponentMessagesInvalidationEventHub':
> Error invoking method public static
> org.apache.tapestry5.services.InvalidationEventHub
> org.apache.tapestry5.services.TapestryModule.buildComponentMessagesInvalidationEventHub(org.apache.tapestry5.services.messages.ComponentMessagesSource):
> Exception constructing service 'ComponentMessagesSource': Error invoking
> service contribution method
> org.apache.tapestry5.services.TapestryModule.contributeComponentMessagesSource(AssetSource,
> Resource, OrderedConfiguration): Cannot cast java.lang.Class to
> org.apache.tapestry5.services.AssetSource
>
> What needs to be done to override the AssetSource service?
>
> Best regards