ViewInstanceEntity viewInstanceDefinition)
throws ClassNotFoundException {
ViewContext viewInstanceContext = new ViewContextImpl(viewInstanceDefinition, this);
ViewExternalSubResourceService externalSubResourceService =
new ViewExternalSubResourceService(viewDefinition.getExternalResourceType(), viewInstanceDefinition);
viewInstanceDefinition.addService(ResourceConfig.EXTERNAL_RESOURCE_PLURAL_NAME, externalSubResourceService);
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(), viewInstanceDefinition.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));
}