Search in sources :

Example 1 with ContributionDef

use of org.apache.tapestry5.ioc.def.ContributionDef 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 ContributionDef

use of org.apache.tapestry5.ioc.def.ContributionDef 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 ContributionDef

use of org.apache.tapestry5.ioc.def.ContributionDef 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 4 with ContributionDef

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

the class ValidatingMappedConfigurationWrapper method add.

@Override
public void add(K key, V value) {
    validateKey(key);
    if (value == null)
        throw new NullPointerException(IOCMessages.contributionWasNull(serviceId));
    V coerced = typeCoercer.coerce(value, expectedValueType);
    ContributionDef existing = keyToContributor.get(key);
    if (existing != null)
        throw new IllegalArgumentException(IOCMessages.contributionDuplicateKey(serviceId, key, existing));
    map.put(key, coerced);
    // Remember that this key is provided by this contribution, when looking
    // for future conflicts.
    keyToContributor.put(key, contributionDef);
}
Also used : ContributionDef(org.apache.tapestry5.ioc.def.ContributionDef)

Example 5 with ContributionDef

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

the class RegistryImpl method addToUnorderedConfiguration.

private <T> void addToUnorderedConfiguration(Collection<T> collection, 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 Configuration<T> validating = new ValidatingConfigurationWrapper<T>(valueType, resources, typeCoercerProxy, collection, serviceId);
        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)

Aggregations

ServiceResources (org.apache.tapestry5.ioc.ServiceResources)4 ContributionDef (org.apache.tapestry5.ioc.def.ContributionDef)3 Logger (org.slf4j.Logger)3 Map (java.util.Map)1 AbstractContributionDef (org.apache.tapestry5.http.internal.AbstractContributionDef)1 ModuleBuilderSource (org.apache.tapestry5.ioc.ModuleBuilderSource)1 OperationTracker (org.apache.tapestry5.ioc.OperationTracker)1 TapestryIOCModule (org.apache.tapestry5.ioc.modules.TapestryIOCModule)1 ApplicationContext (org.springframework.context.ApplicationContext)1 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)1 ConfigurableWebApplicationContext (org.springframework.web.context.ConfigurableWebApplicationContext)1 WebApplicationContext (org.springframework.web.context.WebApplicationContext)1