Search in sources :

Example 1 with ServiceDef

use of org.apache.tapestry5.ioc.def.ServiceDef in project tapestry-5 by apache.

the class RegistryImpl method getMappedConfiguration.

@Override
public <K, V> Map<K, V> getMappedConfiguration(ServiceDef3 serviceDef, Class<K> keyType, Class<V> objectType) {
    lock.check();
    // When the key type is String, then a case insensitive map is used.
    Map<K, V> result = newConfigurationMap(keyType);
    Map<K, ContributionDef> keyToContribution = newConfigurationMap(keyType);
    Map<K, MappedConfigurationOverride<K, V>> overrides = newConfigurationMap(keyType);
    for (Module m : moduleToServiceDefs.keySet()) addToMappedConfiguration(result, overrides, keyToContribution, keyType, objectType, serviceDef, m);
    for (MappedConfigurationOverride<K, V> override : overrides.values()) {
        override.apply();
    }
    if (!isServiceConfigurationListenerServiceDef(serviceDef)) {
        serviceConfigurationListener.onMappedConfiguration(serviceDef, result);
    }
    return result;
}
Also used : TapestryIOCModule(org.apache.tapestry5.ioc.modules.TapestryIOCModule)

Example 2 with ServiceDef

use of org.apache.tapestry5.ioc.def.ServiceDef in project tapestry-5 by apache.

the class RegistryImpl method addToMappedConfiguration.

private <K, V> void addToMappedConfiguration(Map<K, V> map, Map<K, MappedConfigurationOverride<K, V>> overrides, Map<K, ContributionDef> keyToContribution, Class<K> keyClass, Class<V> valueType, ServiceDef3 serviceDef, final Module module) {
    String serviceId = serviceDef.getServiceId();
    Set<ContributionDef2> contributions = module.getContributorDefsForService(serviceDef);
    if (contributions.isEmpty())
        return;
    Logger logger = getServiceLogger(serviceId);
    final ServiceResources resources = new ServiceResourcesImpl(this, module, serviceDef, proxyFactory, logger);
    for (final ContributionDef def : contributions) {
        final MappedConfiguration<K, V> validating = new ValidatingMappedConfigurationWrapper<K, V>(valueType, resources, typeCoercerProxy, map, overrides, serviceId, def, keyClass, keyToContribution);
        String description = "Invoking " + def;
        logger.debug(description);
        operationTracker.run(description, new Runnable() {

            @Override
            public void run() {
                def.contribute(module, resources, validating);
            }
        });
    }
}
Also used : Logger(org.slf4j.Logger) ServiceResources(org.apache.tapestry5.ioc.ServiceResources)

Example 3 with ServiceDef

use of org.apache.tapestry5.ioc.def.ServiceDef in project tapestry-5 by apache.

the class DefaultModuleDefImpl method addServiceDef.

@Override
public void addServiceDef(ServiceDef serviceDef) {
    String serviceId = serviceDef.getServiceId();
    ServiceDef existing = serviceDefs.get(serviceId);
    if (existing != null)
        throw new RuntimeException(IOCMessages.buildMethodConflict(serviceId, serviceDef.toString(), existing.toString()));
    serviceDefs.put(serviceId, serviceDef);
}
Also used : ServiceDef(org.apache.tapestry5.ioc.def.ServiceDef)

Example 4 with ServiceDef

use of org.apache.tapestry5.ioc.def.ServiceDef in project tapestry-5 by apache.

the class RegistryImpl method addToOrderedConfiguration.

private <T> void addToOrderedConfiguration(Orderer<T> orderer, Map<String, OrderedConfigurationOverride<T>> overrides, Class<T> valueType, ServiceDef3 serviceDef, final Module module) {
    String serviceId = serviceDef.getServiceId();
    Set<ContributionDef2> contributions = module.getContributorDefsForService(serviceDef);
    if (contributions.isEmpty())
        return;
    Logger logger = getServiceLogger(serviceId);
    final ServiceResources resources = new ServiceResourcesImpl(this, module, serviceDef, proxyFactory, logger);
    for (final ContributionDef def : contributions) {
        final OrderedConfiguration<T> validating = new ValidatingOrderedConfigurationWrapper<T>(valueType, resources, typeCoercerProxy, orderer, overrides, def);
        String description = "Invoking " + def;
        logger.debug(description);
        operationTracker.run(description, new Runnable() {

            @Override
            public void run() {
                def.contribute(module, resources, validating);
            }
        });
    }
}
Also used : ServiceResources(org.apache.tapestry5.ioc.ServiceResources) Logger(org.slf4j.Logger)

Example 5 with ServiceDef

use of org.apache.tapestry5.ioc.def.ServiceDef in project tapestry-5 by apache.

the class RegistryImpl method findDecoratorsForService.

@Override
public List<ServiceDecorator> findDecoratorsForService(ServiceDef3 serviceDef) {
    lock.check();
    assert serviceDef != null;
    Logger logger = getServiceLogger(serviceDef.getServiceId());
    Orderer<ServiceDecorator> orderer = new Orderer<ServiceDecorator>(logger, true);
    for (Module module : moduleToServiceDefs.keySet()) {
        Set<DecoratorDef> decoratorDefs = module.findMatchingDecoratorDefs(serviceDef);
        if (decoratorDefs.isEmpty())
            continue;
        ServiceResources resources = new ServiceResourcesImpl(this, module, serviceDef, proxyFactory, logger);
        for (DecoratorDef decoratorDef : decoratorDefs) {
            ServiceDecorator decorator = decoratorDef.createDecorator(module, resources);
            try {
                orderer.add(decoratorDef.getDecoratorId(), decorator, decoratorDef.getConstraints());
            } catch (IllegalArgumentException e) {
                throw new RuntimeException(String.format("Service %s has two different decorators methods named decorate%s in different module classes. " + "You can solve this by renaming one of them and annotating it with @Match(\"%2$s\").", serviceDef.getServiceId(), decoratorDef.getDecoratorId()));
            }
        }
    }
    return orderer.getOrdered();
}
Also used : ServiceDecorator(org.apache.tapestry5.ioc.ServiceDecorator) ServiceResources(org.apache.tapestry5.ioc.ServiceResources) Logger(org.slf4j.Logger) TapestryIOCModule(org.apache.tapestry5.ioc.modules.TapestryIOCModule) Orderer(org.apache.tapestry5.ioc.internal.util.Orderer)

Aggregations

Logger (org.slf4j.Logger)6 ServiceResources (org.apache.tapestry5.ioc.ServiceResources)5 TapestryIOCModule (org.apache.tapestry5.ioc.modules.TapestryIOCModule)5 ServiceDef (org.apache.tapestry5.ioc.def.ServiceDef)3 Orderer (org.apache.tapestry5.ioc.internal.util.Orderer)3 ServiceAdvisor (org.apache.tapestry5.ioc.ServiceAdvisor)2 ServiceDecorator (org.apache.tapestry5.ioc.ServiceDecorator)2 ServletContext (javax.servlet.ServletContext)1 ObjectCreator (org.apache.tapestry5.commons.ObjectCreator)1 NullAnnotationProvider (org.apache.tapestry5.commons.internal.NullAnnotationProvider)1 AdvisorDef (org.apache.tapestry5.ioc.AdvisorDef)1 ServiceBuilderResources (org.apache.tapestry5.ioc.ServiceBuilderResources)1 AspectInterceptorBuilder (org.apache.tapestry5.ioc.services.AspectInterceptorBuilder)1 MasterObjectProvider (org.apache.tapestry5.ioc.services.MasterObjectProvider)1 BeanDefinition (org.springframework.beans.factory.config.BeanDefinition)1 ConfigurableListableBeanFactory (org.springframework.beans.factory.config.ConfigurableListableBeanFactory)1 ConfigurableWebApplicationContext (org.springframework.web.context.ConfigurableWebApplicationContext)1 Test (org.testng.annotations.Test)1