plug-in: plug-in jar file can have a not fixed name
authorSeokYeon Hwang <syeon.hwang@samsung.com>
Wed, 13 May 2015 07:03:58 +0000 (16:03 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Wed, 13 May 2015 07:12:06 +0000 (16:12 +0900)
Change-Id: Ie76e0a32a5f7ea87816f9f5b51659df37cdd081e

common-project/src/org/tizen/emulator/manager/platform/Platform.java
common-project/src/org/tizen/emulator/manager/platform/PlatformStringResources.java
common-project/src/org/tizen/emulator/manager/plugin/EMPluginLoader.java

index 73d9e8f..26a9f9b 100644 (file)
@@ -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);
index 98624b3..c6fd521 100644 (file)
@@ -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";
index c71a321..6eaa26e 100644 (file)
@@ -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;