/** * Attempts to locate the given resource name. * @param key The full name of the resource. * @return The AssetInfo containing resource information required for * access, or null if not found. */ public AssetInfo tryLocate(AssetKey key){ if (locatorsList.isEmpty()){ logger.warning("There are no locators currently"+ " registered. Use AssetManager."+ "registerLocator() to register a"+ " locator."); return null; } for (ImplThreadLocal<AssetLocator> local : locatorsList){ AssetInfo info = local.get().locate(assetManager, key); if (info != null) { return info; } } return null; }
@Override protected T initialValue(){ try { T obj = type.newInstance(); if (path != null) { ((AssetLocator)obj).setRootPath(path); } return obj; } catch (InstantiationException ex) { logger.log(Level.SEVERE,"Cannot create locator of type {0}, does" + " the class have an empty and publically accessible"+ " constructor?", type.getName()); logger.throwing(type.getName(), "<init>", ex); } catch (IllegalAccessException ex) { logger.log(Level.SEVERE,"Cannot create locator of type {0}, " + "does the class have an empty and publically " + "accessible constructor?", type.getName()); logger.throwing(type.getName(), "<init>", ex); } return null; } }
/** * Attempts to locate the given resource name. * @param name The full name of the resource. * @return The AssetInfo containing resource information required for * access, or null if not found. */ public AssetInfo tryLocate(AssetKey key){ synchronized (genericLocators){ if (genericLocators.size() == 0) return null; for (ImplThreadLocal local : genericLocators){ AssetLocator locator = (AssetLocator) local.get(); if (local.getPath() != null){ locator.setRootPath((String) local.getPath()); } AssetInfo info = locator.locate(owner, key); if (info != null) return info; } } return null; }
@Override protected T initialValue(){ try { T obj = type.newInstance(); if (path != null) { ((AssetLocator)obj).setRootPath(path); } return obj; } catch (InstantiationException ex) { logger.log(Level.SEVERE,"Cannot create locator of type {0}, does" + " the class have an empty and publically accessible"+ " constructor?", type.getName()); logger.throwing(type.getName(), "<init>", ex); } catch (IllegalAccessException ex) { logger.log(Level.SEVERE,"Cannot create locator of type {0}, " + "does the class have an empty and publically " + "accessible constructor?", type.getName()); logger.throwing(type.getName(), "<init>", ex); } return null; } }
/** * Attempts to locate the given resource name. * @param key The full name of the resource. * @return The AssetInfo containing resource information required for * access, or null if not found. */ public AssetInfo tryLocate(AssetKey key){ if (locatorsList.isEmpty()){ logger.warning("There are no locators currently"+ " registered. Use AssetManager."+ "registerLocator() to register a"+ " locator."); return null; } for (ImplThreadLocal<AssetLocator> local : locatorsList){ AssetInfo info = local.get().locate(assetManager, key); if (info != null) { return info; } } return null; }