I think either of these should do it. First is overriding the existing
service, second is decorating it, having the option to forward the call
to the original
public static void
contributeServiceOverride(MappedConfiguration<Class,Object>
configuration, final Logger log)
{
configuration.add(TemplateParser.class, new TemplateParser() {
@Override
public ComponentTemplate parseTemplate(Resource resource) {
// Handle all parsing here
}
@Override
public Map<String, URL> getDTDURLMappings() {
// TODO
}
});
}
public TemplateParser decorateTemplateParser(TemplateParser original,
final Logger log) {
return new TemplateParser() {
@Override
public ComponentTemplate parseTemplate(Resource resource) {
// Handle parsing, or leave to the original below
return original.parseTemplate(resource);
}
@Override
public Map<String, URL> getDTDURLMappings() {
// Handle, or leave it to the original
return original.getDTDURLMappings();
}
};
}
// Mats
On 2019-04-25 15:14, Ric 2000 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
--
---------------------- Mats Andersson | Ronsoft AB | +46(0)73 368 79 82
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org