/** * Load a model. * @param name The name of the model (file name or logical name). * @param imports The imports to use when resolving logical names. * @param clkey The class loader key to allow caching by e.g. RID. */ public synchronized ICacheableModel loadModel(String name, String[] imports, Object clkey, ClassLoader classloader, Object context) throws Exception { return loadModel(name, null, imports, clkey, classloader, context); }
info = extension!=null ? getResourceInfo(name, extension, imports, classloader) : getResourceInfo(name, imports, classloader); if(cached.getLastModified()<info.getLastModified()) info = extension!=null ? getResourceInfo(name, extension, imports, classloader) : getResourceInfo(name, imports, classloader); cached = modelcache.get(new Tuple(new Object[]{info.getFilename()})); if(cached!=null) cached = doLoadModel(name, imports, info, classloader, context);
/** * Find the file for a given name using any supported extension. * @param name The filename or logical name (resolved via imports and extensions). * @param imports The imports, if any. * @return The resource info identifying the file. * @throws Exception when the file could not be found. */ protected ResourceInfo getResourceInfo(String name, String[] imports, ClassLoader classloader) throws Exception { ResourceInfo ret; if(registered.containsKey(name)) { // Hack!!! ignore file handling for registered models. ICacheableModel model = (ICacheableModel)registered.get(name); ret = new ResourceInfo(name, null, model.getLastModified()); } else { ret = getResourceInfo0(name, imports, classloader); if(ret==null || ret.getInputStream()==null) throw new IOException("File "+name+" not found in imports.");//: "+SUtil.arrayToString(imports)); } return ret; }