From: SeokYeon Hwang Date: Wed, 13 May 2015 07:03:58 +0000 (+0900) Subject: plug-in: plug-in jar file can have a not fixed name X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cbd83381e48e156da177f9d5920479609d8e0a9c;p=sdk%2Femulator%2Femulator-manager.git plug-in: plug-in jar file can have a not fixed name Change-Id: Ie76e0a32a5f7ea87816f9f5b51659df37cdd081e --- diff --git a/common-project/src/org/tizen/emulator/manager/platform/Platform.java b/common-project/src/org/tizen/emulator/manager/platform/Platform.java index 73d9e8f..26a9f9b 100644 --- a/common-project/src/org/tizen/emulator/manager/platform/Platform.java +++ b/common-project/src/org/tizen/emulator/manager/platform/Platform.java @@ -48,6 +48,7 @@ import org.tizen.emulator.manager.tool.SettingInfoFile; import org.tizen.emulator.manager.ui.detail.item.OptionType; import org.tizen.emulator.manager.vms.RESOLUTION; import org.tizen.emulator.manager.vms.VMProperty; +import org.tizen.emulator.manager.vms.option.IOption; import org.tizen.emulator.manager.vms.option.IOptionFactory; import org.tizen.emulator.manager.vms.xml.template.DeviceList; import org.tizen.emulator.manager.vms.xml.template.Item; @@ -55,7 +56,6 @@ import org.tizen.emulator.manager.vms.xml.template.ItemList; import org.tizen.emulator.manager.vms.xml.template.ObjectFactory; import org.tizen.emulator.manager.vms.xml.template.Option; import org.tizen.emulator.manager.vms.xml.template.PropertyList; -import org.tizen.emulator.manager.vms.option.IOption; public class Platform { // platform name = profile + version = profile-version @@ -338,12 +338,23 @@ public class Platform { } private void loadPlugin() { - File pluginJar = new File(platformPath + File.separator - + FilePathResources.getPlatformPluginsPath() - + File.separator - + PlatformStringResources.PluignFile); + File pluginDir = new File(platformPath + File.separator + + FilePathResources.getPlatformPluginsPath()); + if(!pluginDir.isDirectory()) { + return; + } + + File pluginJar = null; + File[] fileList = pluginDir.listFiles(); + for (File file : fileList) { + if (file.getName().startsWith(PlatformStringResources.PluginFilePrefix) && + file.getName().endsWith(".jar")) { + pluginJar = file; + break; + } + } - if (pluginJar.exists()) { + if (pluginJar != null && pluginJar.exists()) { plugin = EMPluginLoader.makePlugin(pluginJar); if (plugin != null) { plugin.setPlatform(this); diff --git a/common-project/src/org/tizen/emulator/manager/platform/PlatformStringResources.java b/common-project/src/org/tizen/emulator/manager/platform/PlatformStringResources.java index 98624b3..c6fd521 100644 --- a/common-project/src/org/tizen/emulator/manager/platform/PlatformStringResources.java +++ b/common-project/src/org/tizen/emulator/manager/platform/PlatformStringResources.java @@ -34,7 +34,7 @@ public class PlatformStringResources { public static String OldMobileProfile = "phone"; public static String MobileProfile = "mobile"; - public static String PluignFile = "em-plugin.jar"; + public static String PluginFilePrefix = "em-plugin"; public static String TemplateFile = "standard.xml"; public static String CONFIG_EXTENSION = "xml"; public static String TEMPLATE = "template"; diff --git a/common-project/src/org/tizen/emulator/manager/plugin/EMPluginLoader.java b/common-project/src/org/tizen/emulator/manager/plugin/EMPluginLoader.java index c71a321..6eaa26e 100644 --- a/common-project/src/org/tizen/emulator/manager/plugin/EMPluginLoader.java +++ b/common-project/src/org/tizen/emulator/manager/plugin/EMPluginLoader.java @@ -76,7 +76,7 @@ public class EMPluginLoader { try { url = plugin.toURI().toURL(); } catch (MalformedURLException e) { - EMLogger.getLogger().warning("Fail to load url from jar file: " + e.getMessage()); + EMLogger.getLogger().warning("Failed to load url from jar file: " + e.getMessage()); return null; } @@ -89,7 +89,7 @@ public class EMPluginLoader { try { jarFile = new JarFile(plugin.getAbsolutePath()); } catch (IOException e) { - EMLogger.addStaticLog("Faile to load plugin jar file: " + e.getMessage()); + EMLogger.addStaticLog("Failed to load plugin jar file: " + e.getMessage()); } if (jarFile != null) { @@ -99,7 +99,7 @@ public class EMPluginLoader { attr = jarFile.getManifest().getMainAttributes(); } } catch (IOException e) { - EMLogger.addStaticLog("Faile to load Manifest file: " + e.getMessage()); + EMLogger.addStaticLog("Failed to load Manifest file: " + e.getMessage()); } if (attr != null) { try { @@ -139,16 +139,16 @@ public class EMPluginLoader { try { classToLoad = Class.forName(pointClass, true, loader); } catch (ClassNotFoundException e) { - EMLogger.getLogger().warning("Fail to load point class jar file: " + e.getMessage()); + EMLogger.getLogger().warning("Failed to load point class jar file: " + e.getMessage()); return null; } try { return classToLoad.newInstance(); } catch (InstantiationException e) { - EMLogger.getLogger().warning("Fail to create new instance from class: " + e.getMessage()); + EMLogger.getLogger().warning("Failed to create new instance from class: " + e.getMessage()); } catch (IllegalAccessException e) { - EMLogger.getLogger().warning("Fail to create new instance from class: " + e.getMessage()); + EMLogger.getLogger().warning("Failed to create new instance from class: " + e.getMessage()); } return null;