Package org.jrd.backend.decompiling
Class PluginManager
- java.lang.Object
-
- org.jrd.backend.decompiling.PluginManager
-
public class PluginManager extends java.lang.Object
Executes manages external decompiler wrapper plugins. Wrapper plugins are stored as .java files along with .json file containing classname, wrapper url and dependencies url. When user calls decompile method with decompiler name and bytecode, wrapper plugin gets compiled and executed.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) com.google.gson.Gson
gson
private java.util.List<DecompilerWrapperInformation>
wrappers
-
Constructor Summary
Constructors Constructor Description PluginManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
createUserPluginDir()
DecompilerWrapperInformation
createWrapper()
java.lang.String
decompile(DecompilerWrapperInformation wrapper, byte[] bytecode)
Decompile with default optionsjava.lang.String
decompile(DecompilerWrapperInformation wrapper, byte[] bytecode, java.lang.String[] options)
void
deleteWrapper(DecompilerWrapperInformation wrapperInformation)
static java.lang.String
flipWrapperExtension(java.lang.String filePath)
java.util.List<DecompilerWrapperInformation>
getWrappers()
private void
InitializeWrapper(DecompilerWrapperInformation wrapper)
Compiles wrapper plugin, loads it into JVM and stores it for later.private void
loadConfig(java.io.File file)
Loads information decompiler json file into ListWrapper. void
loadConfigs()
Searches plugin configuration locations and calls loadConfig(file) on files.void
replace(DecompilerWrapperInformation oldWrapper, DecompilerWrapperInformation newWrapper)
void
saveWrapper(DecompilerWrapperInformation wrapper)
void
setLocationForNewWrapper(DecompilerWrapperInformation wrapperInformation)
private java.lang.String
URLListToCSV(java.util.List<ExpandableUrl> list, java.lang.String delimeter)
Converts list of URLs to CSV String
example: (list){URL1,URL2,URL3} -> (String)URL1:URL2:URL3java.lang.String
validatePlugin(DecompilerWrapperInformation plugin)
Validating the @param plugin using compilation
-
-
-
Field Detail
-
wrappers
private java.util.List<DecompilerWrapperInformation> wrappers
-
gson
com.google.gson.Gson gson
-
-
Method Detail
-
getWrappers
public java.util.List<DecompilerWrapperInformation> getWrappers()
-
loadConfigs
public void loadConfigs()
Searches plugin configuration locations and calls loadConfig(file) on files.
-
loadConfig
private void loadConfig(java.io.File file)
Loads information decompiler json file into ListWrapper.
-
decompile
public java.lang.String decompile(DecompilerWrapperInformation wrapper, byte[] bytecode) throws java.lang.Exception
Decompile with default options- Throws:
java.lang.Exception
-
decompile
public java.lang.String decompile(DecompilerWrapperInformation wrapper, byte[] bytecode, java.lang.String[] options) throws java.lang.Exception
- Parameters:
wrapper
- decompiler used for decompilingbytecode
- bytecode to be decompiled- Returns:
- Decompiled bytecode or exception String.
- Throws:
java.lang.Exception
-
InitializeWrapper
private void InitializeWrapper(DecompilerWrapperInformation wrapper)
Compiles wrapper plugin, loads it into JVM and stores it for later.- Parameters:
wrapper
-- Throws:
java.lang.RuntimeException
-
replace
public void replace(DecompilerWrapperInformation oldWrapper, DecompilerWrapperInformation newWrapper) throws java.io.IOException
- Throws:
java.io.IOException
-
deleteWrapper
public void deleteWrapper(DecompilerWrapperInformation wrapperInformation)
-
setLocationForNewWrapper
public void setLocationForNewWrapper(DecompilerWrapperInformation wrapperInformation)
-
validatePlugin
public java.lang.String validatePlugin(DecompilerWrapperInformation plugin)
Validating the @param plugin using compilation- Parameters:
plugin
- - plugin to validate- Returns:
- error message or null
-
createWrapper
public DecompilerWrapperInformation createWrapper()
-
saveWrapper
public void saveWrapper(DecompilerWrapperInformation wrapper) throws java.io.IOException
- Throws:
java.io.IOException
-
createUserPluginDir
public static void createUserPluginDir()
-
URLListToCSV
private java.lang.String URLListToCSV(java.util.List<ExpandableUrl> list, java.lang.String delimeter)
Converts list of URLs to CSV String
example: (list){URL1,URL2,URL3} -> (String)URL1:URL2:URL3- Parameters:
list
-delimeter
-- Returns:
-
flipWrapperExtension
public static java.lang.String flipWrapperExtension(java.lang.String filePath)
-
-