* 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
3.0
Sha..rd 13 years ago
parent 0c1294c57c
commit c67e6d32c5
  1. 20
      engine/src/core/com/jme3/asset/AssetConfig.java

@ -73,16 +73,18 @@ public class AssetConfig {
for (int i = 0; i < extensions.length; i++){ for (int i = 0; i < extensions.length; i++){
extensions[i] = extensions[i].trim(); extensions[i] = extensions[i].trim();
} }
if (hasClass(loaderClass)) { Class clazz = acquireClass(loaderClass);
manager.registerLoader(loaderClass, extensions); if (clazz != null) {
manager.registerLoader(clazz, extensions);
} else { } else {
Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "Cannot find loader {0}", loaderClass); Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "Cannot find loader {0}", loaderClass);
} }
} else if (cmd.equals("LOCATOR")) { } else if (cmd.equals("LOCATOR")) {
String rootPath = scan.next(); String rootPath = scan.next();
String locatorClass = scan.nextLine().trim(); String locatorClass = scan.nextLine().trim();
if (hasClass(locatorClass)) { Class clazz = acquireClass(locatorClass);
manager.registerLocator(rootPath, locatorClass); if (clazz != null) {
manager.registerLocator(rootPath, clazz);
} else { } else {
Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "Cannot find locator {0}", locatorClass); 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 { try {
Class clazz = Class.forName(name); Class clazz = Class.forName(name);
return clazz != null; return clazz;
} catch (ClassNotFoundException ex) { } catch (ClassNotFoundException ex) {
return false; return null;
} }
} }
/*
private static String readString(DataInput dataIn) throws IOException{ private static String readString(DataInput dataIn) throws IOException{
int length = dataIn.readUnsignedShort(); int length = dataIn.readUnsignedShort();
char[] chrs = new char[length]; char[] chrs = new char[length];
@ -110,7 +113,6 @@ public class AssetConfig {
return String.valueOf(chrs); return String.valueOf(chrs);
} }
/*
public void loadBinary(DataInput dataIn) throws IOException{ public void loadBinary(DataInput dataIn) throws IOException{
// read signature and version // read signature and version

Loading…
Cancel
Save