Collection<ViewSubResourceDefinition> resourceDefinitions = viewDefinition.getResourceDefinitions().values();
for (ViewSubResourceDefinition resourceDefinition : resourceDefinitions) {
Resource.Type type = resourceDefinition.getType();
ResourceConfig resourceConfig = resourceDefinition.getResourceConfiguration();
ViewResourceHandler viewResourceService =
new ViewSubResourceService(type, viewDefinition.getName(), instanceConfig.getName());
ClassLoader cl = viewDefinition.getClassLoader();
Object service = getService(resourceConfig.getServiceClass(cl), viewResourceService, viewInstanceContext);
if (resourceConfig.isExternal()) {
externalSubResourceService.addResourceService(resourceConfig.getName(), service);
} else {
viewInstanceDefinition.addService(viewDefinition.getResourceDefinition(type).getPluralName(),service);
viewInstanceDefinition.addResourceProvider(type,
getProvider(resourceConfig.getProviderClass(cl), viewInstanceContext));
}
}
viewDefinition.addInstanceDefinition(viewInstanceDefinition);
ViewRegistry.getInstance().addInstanceDefinition(viewDefinition, viewInstanceDefinition);