Hi all,

thanks for your replies, which I will try one by one.
Meanwhile I started also wirh decoration of the service...

Greetings, Eric

On Friday, April 26, 2019, Cezary Biernacki <cezary...@gmail.com> wrote:
> Hi,
> The problem you encountered is caused by attempting to pass "Map<String,
> URL> configuration" to the contribute method. Unfortunately, as far as I
> know, Tapestry does not provide an easy way to access to a service
> configuration from its decorators or overrides.
>
> The simplest solution in your case can be to avoid using contributed
> mapping and hard-code any mappings from DTDs to resources in your class.
> You can copy any existing mappings from
> org.apache.tapestry5.modules.TapestryModule#contributeTemplateParser() if
> you want.
>
> On the other hand, if you really need to use actual contributions to
> TemplateParser, it is possible to do that via
> ServiceConfigurationListenerHub:
>
>
>     private Map rememberedConfiguration;
>
>     @Contribute(ServiceConfigurationListenerHub.class)
>     public void
>
addListenerForTemplateParser(OrderedConfiguration<ServiceConfigurationListener>
> configuration) {
>         configuration.add("trackTemplateParser", new
> ServiceConfigurationListener() {
>             @Override
>             public void onOrderedConfiguration(final ServiceDef
serviceDef,
> final List configuration) {
>                 // nothing
>             }
>
>             @Override
>             public void onUnorderedConfiguration(final ServiceDef
> serviceDef, final Collection configuration) {
>                 // nothing
>             }
>
>             @Override
>             public void onMappedConfiguration(final ServiceDef serviceDef,
> final Map configuration) {
>                 if
> (serviceDef.getServiceId().equalsIgnoreCase("TemplateParser")) {
>                     rememberedConfiguration = configuration;
>                 }
>             }
>         });
>     }
>
>     @Decorate(serviceInterface = TemplateParser.class)
>     public TemplateParser replaceTemplateParser(
>             @Symbol(SymbolConstants.COMPRESS_WHITESPACE) boolean
> defaultCompressWhitespace,
>             OperationTracker tracker
>     ) {
>         if (rememberedConfiguration == null) {
>             throw new NullPointerException("Missing TemplateParser
> configuration");
>         }
>
>         return new MspTemplateParser(rememberedConfiguration,
> defaultCompressWhitespace, tracker);
>     }
>
>
> Note: instead using a service override, I need to use a decorator to
> trigger creation of the default TemplateParser so its configuration can be
> observed by the listener.
>
> If there is a simpler solution, I would be happy to know :-)
>
> Best regards,
> Cezary
>
>
> On Thu, Apr 25, 2019 at 3:14 PM Ric 2000 <erich.gorma...@gmail.com> wrote:
>
>> Hi,
>> here is the stacktrace:
>>
>> Caused by: 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.modules.TapestryIOCModule.bind(ServiceBinder)
(at
>> TapestryIOCModule.java:52) for references to another service that is
itself
>> dependent on service 'ServiceOverride'.
>>
>>                at
>>
>>
org.apache.tapestry5.ioc.internal.RecursiveServiceCreationCheckWrapper.createObject(RecursiveServiceCreationCheckWrapper.java:53)
>>
>>                at
>>
>>
org.apache.tapestry5.ioc.internal.OperationTrackingObjectCreator$1.invoke(OperationTrackingObjectCreator.java:47)
>>
>>                at
>>
>>
org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:82)
>>
>> And this my override method in my filter module:
>>
>> @Contribute(ServiceOverride.class)
>>
>>       public void contributeAliasOverrides(MappedConfiguration<Class<?>,
>> Object> serviceOverrides, Map<String, URL> configuration,
>>
>>                    @Symbol(SymbolConstants.COMPRESS_WHITESPACE) boolean
>> defaultCompressWhitespace, OperationTracker tracker) {
>>
>>
>>
>>             serviceOverrides.add(TemplateParser.class,
>>
>>                           new MspTemplateParser(configuration,
>> defaultCompressWhitespace, tracker));
>>
>>       }
>>
>> Regards, Eric
>>
>> On Wednesday, April 24, 2019, Mats Andersson <mats.anders...@ronsoft.se>
>> wrote:
>> > Hi Eric,
>> >
>> > What is the error you are getting? You should be able to either
override
>> or decorate the internal service. I guess it could be a problem with your
>> implementation of the service, but hard to say without knowing.
>> >
>> > Kind Regards
>> > Mats
>> >
>> > On 2019-04-24 11:59, Ric 2000 wrote:
>> >>
>> >> Hi all,
>> >>
>> >> I'am new to that list, but not to Tapestry :-)
>> >>
>> >> Nevertheless I face problems to override one of the Tapestry 5.4.3
>> internal
>> >> services, the TemplateParser.
>> >>
>> >> The normal overriding with mapped config and override annotation leads
>> to
>> >> errors.
>> >>
>> >> Background is, that I want to use a customized SaxTemplateParser in
>> order
>> >> to use an own namespace.
>> >> This is to be able to hide the Tapestry version info in the xsd
>> declaration
>> >> of our tml files.
>> >>
>> >> Can give me advice how to do it correctly?
>> >>
>> >> Thanks in advance.
>> >>
>> >> Kind Regards, Eric
>> >>
>> > --
>> > ---------------------- Mats Andersson | Ronsoft AB | +46(0)73 368 79 82
>> >
>> >
>>
>

Reply via email to