Search in sources :

Example 1 with ServiceAdvisor

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();
}
Also used : AspectInterceptorBuilder(org.apache.tapestry5.ioc.services.AspectInterceptorBuilder) ServiceAdvisor(org.apache.tapestry5.ioc.ServiceAdvisor)

Example 2 with ServiceAdvisor

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();
}
Also used : ServiceResources(org.apache.tapestry5.ioc.ServiceResources) Logger(org.slf4j.Logger) TapestryIOCModule(org.apache.tapestry5.ioc.modules.TapestryIOCModule) ServiceAdvisor(org.apache.tapestry5.ioc.ServiceAdvisor) AdvisorDef(org.apache.tapestry5.ioc.AdvisorDef) Orderer(org.apache.tapestry5.ioc.internal.util.Orderer)

Aggregations

ServiceAdvisor (org.apache.tapestry5.ioc.ServiceAdvisor)2 AdvisorDef (org.apache.tapestry5.ioc.AdvisorDef)1 ServiceResources (org.apache.tapestry5.ioc.ServiceResources)1 Orderer (org.apache.tapestry5.ioc.internal.util.Orderer)1 TapestryIOCModule (org.apache.tapestry5.ioc.modules.TapestryIOCModule)1 AspectInterceptorBuilder (org.apache.tapestry5.ioc.services.AspectInterceptorBuilder)1 Logger (org.slf4j.Logger)1