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;
}
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);
}
});
}
}
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);
}
});
}
}
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);
}
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);
}
});
}
}
Aggregations