From c67e6d32c5c5c517d50053b6331057e4dd516be7 Mon Sep 17 00:00:00 2001 From: "Sha..rd" Date: Sat, 14 Apr 2012 19:30:47 +0000 Subject: [PATCH] * Since AssetManager registerLoader/Locator method that take a string class are deprecated, AssetConfig will no longer use them git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9301 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../src/core/com/jme3/asset/AssetConfig.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/engine/src/core/com/jme3/asset/AssetConfig.java b/engine/src/core/com/jme3/asset/AssetConfig.java index eaf203600..babce5b88 100644 --- a/engine/src/core/com/jme3/asset/AssetConfig.java +++ b/engine/src/core/com/jme3/asset/AssetConfig.java @@ -73,16 +73,18 @@ public class AssetConfig { for (int i = 0; i < extensions.length; i++){ extensions[i] = extensions[i].trim(); } - if (hasClass(loaderClass)) { - manager.registerLoader(loaderClass, extensions); + Class clazz = acquireClass(loaderClass); + if (clazz != null) { + manager.registerLoader(clazz, extensions); } else { Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "Cannot find loader {0}", loaderClass); } } else if (cmd.equals("LOCATOR")) { String rootPath = scan.next(); String locatorClass = scan.nextLine().trim(); - if (hasClass(locatorClass)) { - manager.registerLocator(rootPath, locatorClass); + Class clazz = acquireClass(locatorClass); + if (clazz != null) { + manager.registerLocator(rootPath, clazz); } else { Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "Cannot find locator {0}", locatorClass); } @@ -92,15 +94,16 @@ public class AssetConfig { } } - private boolean hasClass(String name) { + private Class acquireClass(String name) { try { Class clazz = Class.forName(name); - return clazz != null; + return clazz; } catch (ClassNotFoundException ex) { - return false; + return null; } } - + + /* private static String readString(DataInput dataIn) throws IOException{ int length = dataIn.readUnsignedShort(); char[] chrs = new char[length]; @@ -110,7 +113,6 @@ public class AssetConfig { return String.valueOf(chrs); } - /* public void loadBinary(DataInput dataIn) throws IOException{ // read signature and version