@Override
	public void load(DataSource dataSource) throws ResourceException {
		try {
			
			dataSource.addListener(definitionManager);
			
			dataSource.load();

			for (ResourceDefinition definition : definitionManager
					.getAllElements()) {

				ResourceLoader<?> loader = getLoaderByDefinition(definition);

				if (loader != null) {

					if (!definition.isDeferred()) {
						loader.loadResource(definition);
					}
				} else {
					throw new ResourceException("Loader for "
							+ definition.getType() + " resource does not exist");
				}
			}
		} finally {
			dataSource.removeListener(definitionManager);
		}
	}