public ResourceData load( final ResourceKey key ) throws ResourceLoadingException { final ResourceBundleData bundle = loadResourceBundle( key ); if ( bundle != null ) { logger.debug( "Loaded bundle for key " + key ); return bundle; } final ResourceKey parent = key.getParent(); if ( parent != null ) { // try to load the bundle data of the parent final ResourceBundleData parentData = loadResourceBundle( parent ); if ( parentData != null ) { logger.debug( "Loaded bundle for key (derivate) " + key ); return parentData.deriveData( key ); } } return loadRawData( key ); }
public Resource create( final ResourceManager manager, ResourceData data, final ResourceKey context ) throws ResourceCreationException, ResourceLoadingException { if ( data instanceof CachingResourceBundleData ) { // todo: Friggin' cheap hack final CachingResourceBundleData cachingResourceBundleData = (CachingResourceBundleData) data; data = cachingResourceBundleData.getBackend(); } if ( data instanceof RepositoryResourceBundleData == false ) { data = manager.loadResourceBundle( data.getKey() ); if ( data instanceof CachingResourceBundleData ) { // todo: Friggin' cheap hack 2 final CachingResourceBundleData cachingResourceBundleData = (CachingResourceBundleData) data; data = cachingResourceBundleData.getBackend(); } } if ( data instanceof RepositoryResourceBundleData == false ) { throw new ContentNotRecognizedException( "No valid handler for the given content." ); } final RepositoryResourceBundleData bdata = (RepositoryResourceBundleData) data; final Repository repository = bdata.getRepository(); try { final StaticDocumentBundle bundle = new StaticDocumentBundle( repository, manager, bdata.getBundleKey() ); return new SimpleResource( data.getKey(), bundle, getFactoryType(), data.getVersion( manager ) ); } catch ( ResourceException e ) { throw new ResourceCreationException( "Unable to interpret document-bundle", e ); } }