Package xyz.janboerman.scalaloader.util
Class ScalaLoaderUtils
java.lang.Object
xyz.janboerman.scalaloader.util.ScalaLoaderUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic <P extends IScalaPlugin>
PcreateScalaPluginInstance(Class<P> clazz) Tries to get the plugin instance from the scala plugin class.static voiddownloadFile(URL inputResourceLocation, File outputFile) static <ScalaLoader extends JavaPlugin & IScalaLoader>
voidinitBStats(ScalaLoader scalaLoader) static <ScalaLoader extends JavaPlugin & IScalaLoader>
voidinitConfiguration(ScalaLoader scalaLoader) static <Super,Type extends Super>
Typeinstantiate(Class<Type> clazz) Tries to obtain an instance of the given class either by using an `object`'s singleton instance, or by calling the public no-args consturctor.static ScalaLibraryClassLoaderloadOrGetScalaVersion(Map<String, ScalaLibraryClassLoader> scalaLibraryClassLoaders, PluginScalaVersion scalaVersion, boolean download, IScalaLoader scalaLoader) Get a (fresh or cached)ScalaLibraryClassLoaderthat loads standard library classes from a specific Scala version.
-
Method Details
-
initConfiguration
public static <ScalaLoader extends JavaPlugin & IScalaLoader> void initConfiguration(ScalaLoader scalaLoader) -
initBStats
public static <ScalaLoader extends JavaPlugin & IScalaLoader> void initBStats(ScalaLoader scalaLoader) -
instantiate
public static <Super,Type extends Super> Type instantiate(Class<Type> clazz) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException, InstantiationException Tries to obtain an instance of the given class either by using an `object`'s singleton instance, or by calling the public no-args consturctor.- Parameters:
clazz- the class for which to create an instance- Returns:
- the instance
- Throws:
IllegalAccessExceptionInvocationTargetExceptionNoSuchMethodExceptionInstantiationException
-
createScalaPluginInstance
public static <P extends IScalaPlugin> P createScalaPluginInstance(Class<P> clazz) throws ScalaPluginLoaderException Tries to get the plugin instance from the scala plugin class. This method is able to get the static instances from scala `object`s, as well as it is able to create plugins using their public NoArgsConstructors.- Type Parameters:
P- the plugin type- Parameters:
clazz- the plugin class- Returns:
- the plugin's instance.
- Throws:
ScalaPluginLoaderException- when a plugin instance could not be created for the given class
-
downloadFile
- Throws:
IOException
-
loadOrGetScalaVersion
public static ScalaLibraryClassLoader loadOrGetScalaVersion(Map<String, ScalaLibraryClassLoader> scalaLibraryClassLoaders, PluginScalaVersion scalaVersion, boolean download, IScalaLoader scalaLoader) throws ScalaPluginLoaderExceptionGet a (fresh or cached)ScalaLibraryClassLoaderthat loads standard library classes from a specific Scala version. The classloader can either load classes from over the network directly, or use downloaded library archives (jar files).- Parameters:
scalaVersion- the scala version- Returns:
- the class loader
- Throws:
ScalaPluginLoaderException- if a url is malformed.
-