/** * @deprecated use Device.create(EmulatorContext context, ClassLoader * classLoader, String descriptorLocation); */ public void init(EmulatorContext context, String descriptorLocation) { this.context = context; if (descriptorLocation.startsWith("/")) { this.descriptorLocation = descriptorLocation.substring(1); } else { this.descriptorLocation = descriptorLocation; } try { String base = descriptorLocation.substring(0, descriptorLocation.lastIndexOf("/")); XMLElement doc = loadDeviceDescriptor(getClass().getClassLoader(), descriptorLocation); loadConfig(getClass().getClassLoader(), base, doc); } catch (IOException ex) { System.out.println("Cannot load config: " + ex); } }
public static DeviceImpl create(EmulatorContext context, ClassLoader classLoader, String descriptorLocation, Class defaultDeviceClass) throws IOException { XMLElement doc = loadDeviceDescriptor(classLoader, descriptorLocation);
private static XMLElement loadDeviceDescriptor(ClassLoader classLoader, String descriptorLocation) throws IOException { InputStream descriptor = classLoader.getResourceAsStream(descriptorLocation); if (descriptor == null) { throw new IOException("Cannot find descriptor at: " + descriptorLocation); } XMLElement doc; try { doc = loadXmlDocument(descriptor); } finally { IOUtils.closeQuietly(descriptor); } String parent = doc.getStringAttribute("extends"); if (parent != null) { return inheritXML(loadDeviceDescriptor(classLoader, expandResourcePath(besourceBase(descriptorLocation), parent)), doc, "/"); } return doc; }