Package com.alibaba.graphscope.runtime
Class GraphScopeClassLoader
- java.lang.Object
-
- com.alibaba.graphscope.runtime.GraphScopeClassLoader
-
public class GraphScopeClassLoader extends Object
GraphScope Class Loader contains several static functions which will be used by GraphScope grape_engine at runtime, to initiating java runtime environment. When java app(packed in jar) is submitted to grape engine, a jvm will be initiated via JNI interface pointer if jvm has not been created is this process. Rather than directly load java classes via JNI interface pointer, we utilize a URLClassLoader for each jar to do this. The benefit of this solution is the ioslated jvm environment provided by class loaders, which can avoid possible class conflicts.
-
-
Constructor Summary
Constructors Constructor Description GraphScopeClassLoader()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Object
CreateFFIPointer(URLClassLoader classLoader, String foreignName, long address)
This function wrap one C++ object into a java object, namely a FFIPointer.static Object
loadAndCreate(URLClassLoader classLoader, String className, String serialPath)
Load the specified class with one URLClassLoader, return a new instance for this class.static Class<?>
loadClass(URLClassLoader classLoader, String className)
We now accept two kind of className, a/b/c or a.b.c are both ok.static Class<?>
loadCommunicatorClass(URLClassLoader classLoader)
A special case for loadClass, i.e.static URLClassLoader
newGraphScopeClassLoader()
Return a default URLClassLoader with no classPath.static URLClassLoader
newGraphScopeClassLoader(String classPath)
Create a new URLClassLoaders with given classPaths.
-
-
-
Method Detail
-
newGraphScopeClassLoader
public static URLClassLoader newGraphScopeClassLoader(String classPath) throws IllegalAccessException
Create a new URLClassLoaders with given classPaths. The classPath shall be in form/path/to/A:B.jar
.- Parameters:
classPath
- a string will be interpreted as java class path.- Returns:
- new classloader with specified classPath.
- Throws:
IllegalAccessException
- if ClassScope cannot get loaded libraries.
-
newGraphScopeClassLoader
public static URLClassLoader newGraphScopeClassLoader() throws IllegalAccessException
Return a default URLClassLoader with no classPath.- Returns:
- the default class loader.
- Throws:
IllegalAccessException
- if ClassScope cannot get loaded libraries.
-
loadAndCreate
public static Object loadAndCreate(URLClassLoader classLoader, String className, String serialPath) throws ClassNotFoundException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException
Load the specified class with one URLClassLoader, return a new instance for this class. The class name could be fully-specified or dash-separated.- Parameters:
classLoader
-className
- a/b/c/ or a.b.c- Returns:
- a instance for loaded class.
- Throws:
ClassNotFoundException
- if class cannot be found in current path.InstantiationException
- if error in creating new instance.IllegalAccessException
- if error in creating new instance.InvocationTargetException
NoSuchMethodException
-
CreateFFIPointer
public static Object CreateFFIPointer(URLClassLoader classLoader, String foreignName, long address) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, InstantiationException
This function wrap one C++ object into a java object, namely a FFIPointer.- Parameters:
classLoader
- The class loader with used to load java classes.foreignName
- The foreign name for C++ object,shall be fully specified.address
- The address for C++ object.- Returns:
- a FFIPointer wrapper.
- Throws:
ClassNotFoundException
- if class cannot be found in current path.NoSuchMethodException
- if method for ffi type factory cannot be found.InvocationTargetException
- if error in invoke the specific method.IllegalAccessException
- if error in invoke the specific method.InstantiationException
- if error in creating new instance.
-
loadClass
public static Class<?> loadClass(URLClassLoader classLoader, String className) throws ClassNotFoundException
We now accept two kind of className, a/b/c or a.b.c are both ok.- Parameters:
classLoader
- url class loader to utilized.className
- full name for java class.- Returns:
- loaded class.
- Throws:
ClassNotFoundException
- if target class cannot be found in current path.
-
loadCommunicatorClass
public static Class<?> loadCommunicatorClass(URLClassLoader classLoader) throws ClassNotFoundException
A special case for loadClass, i.e. loading the communicator class.- Parameters:
classLoader
- url class loader to utilized.- Returns:
- loaded class.
- Throws:
ClassNotFoundException
- if target class cannot be found in current path.
-
-