use of org.apache.tapestry5.ioc.ServiceAdvisor in project tapestry-5 by apache.
the class AdvisorStackBuilder method createObject.
@Override
public Object createObject() {
Object service = delegate.createObject();
List<ServiceAdvisor> advisors = registry.findAdvisorsForService(serviceDef);
if (advisors.isEmpty())
return service;
final AspectInterceptorBuilder builder = aspectDecorator.createBuilder(serviceDef.getServiceInterface(), service, serviceDef, String.format("<AspectProxy for %s(%s)>", serviceDef.getServiceId(), serviceDef.getServiceInterface().getName()));
for (final ServiceAdvisor advisor : advisors) {
registry.run("Invoking " + advisor, new Runnable() {
@Override
public void run() {
advisor.advise(builder);
}
});
}
return builder.build();
}
use of org.apache.tapestry5.ioc.ServiceAdvisor in project tapestry-5 by apache.
the class RegistryImpl method findAdvisorsForService.
@Override
public List<ServiceAdvisor> findAdvisorsForService(ServiceDef3 serviceDef) {
lock.check();
assert serviceDef != null;
Logger logger = getServiceLogger(serviceDef.getServiceId());
Orderer<ServiceAdvisor> orderer = new Orderer<ServiceAdvisor>(logger, true);
for (Module module : moduleToServiceDefs.keySet()) {
Set<AdvisorDef> advisorDefs = module.findMatchingServiceAdvisors(serviceDef);
if (advisorDefs.isEmpty())
continue;
ServiceResources resources = new ServiceResourcesImpl(this, module, serviceDef, proxyFactory, logger);
for (AdvisorDef advisorDef : advisorDefs) {
ServiceAdvisor advisor = advisorDef.createAdvisor(module, resources);
orderer.add(advisorDef.getAdvisorId(), advisor, advisorDef.getConstraints());
}
}
return orderer.getOrdered();
}
Aggregations