public void addLocator(final Class<? extends AssetLocator> locatorType, String rootPath){ locatorsList.add(new ImplThreadLocal(locatorType, rootPath)); }
/** * 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; }
public void removeLocator(final Class<? extends AssetLocator> locatorType, String rootPath){ ArrayList<ImplThreadLocal<AssetLocator>> locatorsToRemove = new ArrayList<ImplThreadLocal<AssetLocator>>(); Iterator<ImplThreadLocal<AssetLocator>> it = locatorsList.iterator(); while (it.hasNext()){ ImplThreadLocal locator = it.next(); if (locator.getPath().equals(rootPath) && locator.getTypeClass().equals(locatorType)){ //it.remove(); // copy on write list doesn't support iterator remove, // must use temporary list locatorsToRemove.add(locator); } } locatorsList.removeAll(locatorsToRemove); }
/** * 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; }
/** * 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; }
/** * Returns the AssetLoader registered for the given extension * of the current thread. * @return AssetLoader registered with addLoader. */ public AssetLoader aquireLoader(AssetKey key){ synchronized (loaders){ ImplThreadLocal local = loaders.get(key.getExtension()); if (local != null){ AssetLoader loader = (AssetLoader) local.get(); return loader; } return null; } }
/** * Returns the AssetLoader registered for the given extension * of the current thread. * @return AssetLoader registered with addLoader. */ public AssetLoader aquireLoader(AssetKey key){ // No need to synchronize() against map, its concurrent ImplThreadLocal local = extensionToLoaderMap.get(key.getExtension()); if (local == null){ throw new AssetLoadException("No loader registered for type \"" + key.getExtension() + "\""); } return (AssetLoader) local.get(); }
public void addLocator(final Class<? extends AssetLocator> locatorType, String rootPath){ locatorsList.add(new ImplThreadLocal(locatorType, rootPath)); }
public void removeLoader(final Class<? extends AssetLoader> loaderType){ // Synchronized access must be used for any ops on classToLoaderMap // Find the loader ImplThreadLocal for this class synchronized (classToLoaderMap){ // Remove it from the class->loader map ImplThreadLocal local = classToLoaderMap.remove(loaderType); if (local == null) return; // Remove it from the extension->loader map for (String extension : local.getExtensions()){ extensionToLoaderMap.remove(extension); } } }
public void addLoader(final Class<? extends AssetLoader> loaderType, String ... extensions){ // Synchronized access must be used for any ops on classToLoaderMap ImplThreadLocal local = new ImplThreadLocal(loaderType, extensions); for (String extension : extensions){ extension = extension.toLowerCase(); synchronized (classToLoaderMap){ classToLoaderMap.put(loaderType, local); extensionToLoaderMap.put(extension, local); } } }
public void removeLocator(final Class<? extends AssetLocator> locatorType, String rootPath){ ArrayList<ImplThreadLocal<AssetLocator>> locatorsToRemove = new ArrayList<ImplThreadLocal<AssetLocator>>(); Iterator<ImplThreadLocal<AssetLocator>> it = locatorsList.iterator(); while (it.hasNext()){ ImplThreadLocal locator = it.next(); if (locator.getPath().equals(rootPath) && locator.getTypeClass().equals(locatorType)){ //it.remove(); // copy on write list doesn't support iterator remove, // must use temporary list locatorsToRemove.add(locator); } } locatorsList.removeAll(locatorsToRemove); }
public void addLoader(final Class<?> loaderType, String ... extensions){ ImplThreadLocal local = new ImplThreadLocal(loaderType); for (String extension : extensions){ extension = extension.toLowerCase(); synchronized (loaders){ loaders.put(extension, local); } } }
public void addLocator(final Class<?> locatorType, String rootPath){ ImplThreadLocal local = new ImplThreadLocal(locatorType, rootPath); synchronized (genericLocators){ genericLocators.add(local); } }
public void removeLocator(final Class<?> locatorType, String rootPath){ synchronized (genericLocators){ Iterator<ImplThreadLocal> it = genericLocators.iterator(); while (it.hasNext()){ ImplThreadLocal locator = it.next(); if (locator.getPath().equals(rootPath) && locator.getTypeClass().equals(locatorType)){ it.remove(); } } } }
/** * Returns the AssetLoader registered for the given extension * of the current thread. * @return AssetLoader registered with addLoader. */ public AssetLoader aquireLoader(AssetKey key){ // No need to synchronize() against map, its concurrent ImplThreadLocal local = extensionToLoaderMap.get(key.getExtension()); if (local == null){ throw new AssetLoadException("No loader registered for type \"" + key.getExtension() + "\""); } return (AssetLoader) local.get(); }
public void addLoader(final Class<? extends AssetLoader> loaderType, String ... extensions){ // Synchronized access must be used for any ops on classToLoaderMap ImplThreadLocal local = new ImplThreadLocal(loaderType, extensions); for (String extension : extensions){ extension = extension.toLowerCase(); synchronized (classToLoaderMap){ classToLoaderMap.put(loaderType, local); extensionToLoaderMap.put(extension, local); } } }
public void removeLoader(final Class<? extends AssetLoader> loaderType){ // Synchronized access must be used for any ops on classToLoaderMap // Find the loader ImplThreadLocal for this class synchronized (classToLoaderMap){ // Remove it from the class->loader map ImplThreadLocal local = classToLoaderMap.remove(loaderType); if (local == null) return; // Remove it from the extension->loader map for (String extension : local.getExtensions()){ extensionToLoaderMap.remove(extension); } } }