Package com.biglybt.pifimpl.local.ipc
Class IPCInterfaceImpl
- java.lang.Object
-
- com.biglybt.pifimpl.local.ipc.IPCInterfaceImpl
-
- All Implemented Interfaces:
IPCInterface
public class IPCInterfaceImpl extends java.lang.Object implements IPCInterface
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
plugin_class
private PluginInitializer
plugin_initializer
private java.lang.Object
target_use_accessor
-
Constructor Summary
Constructors Constructor Description IPCInterfaceImpl(PluginInitializer _plugin_initializer, Plugin _target)
Constructor for real plugin based providers.IPCInterfaceImpl(java.lang.Object _target)
Constructor for non-plugin providers
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canInvoke(java.lang.String methodName, java.lang.Class<?>[] params)
boolean
canInvoke(java.lang.String methodName, java.lang.Object[] params)
Test for existance of IPC method - params as aboveprotected java.lang.reflect.Method
getMethod(java.lang.Object target, java.lang.String methodName, java.lang.Class<?>[] paramTypes)
protected java.lang.reflect.Method
getMethod(java.lang.Object target, java.lang.String methodName, java.lang.Object[] params)
protected java.lang.Object
getTarget()
java.lang.Object
invoke(java.lang.String methodName, java.lang.Object[] params)
This function will call the given method on the plugin.void
unload()
-
-
-
Field Detail
-
target_use_accessor
private java.lang.Object target_use_accessor
-
plugin_class
private java.lang.String plugin_class
-
plugin_initializer
private PluginInitializer plugin_initializer
-
-
Constructor Detail
-
IPCInterfaceImpl
public IPCInterfaceImpl(PluginInitializer _plugin_initializer, Plugin _target)
Constructor for real plugin based providers. Supports plugin unloading- Parameters:
_plugin_initializer
-_target
-
-
IPCInterfaceImpl
public IPCInterfaceImpl(java.lang.Object _target)
Constructor for non-plugin providers- Parameters:
_target
-
-
-
Method Detail
-
canInvoke
public boolean canInvoke(java.lang.String methodName, java.lang.Object[] params)
Description copied from interface:IPCInterface
Test for existance of IPC method - params as above- Specified by:
canInvoke
in interfaceIPCInterface
- Returns:
-
canInvoke
public boolean canInvoke(java.lang.String methodName, java.lang.Class<?>[] params)
-
invoke
public java.lang.Object invoke(java.lang.String methodName, java.lang.Object[] params) throws IPCException
Description copied from interface:IPCInterface
This function will call the given method on the plugin. This function allows direct method calls to the plugin using Java Reflection API. Primitives likeint
,boolean
need to be wrapped in their Objects (int -> Integer). Results will be returned as Object and can be classcasted.WARNING: only call Methods that use Java or client Classes the use of custom classes may cause problems.
Examples:
1. Plugin has method
int add (int x, int y);
int result = ((Integer)invoke ("add", new Object[] {Integer.valueOf(10),Integer.valueOf(5)}).intValue(); //result (15)
2. Plugin has methodString randomize (String x);
String result = (String)invoke("randomize", new Object[]{"foobar"}); //result ("bfaoro")
- Specified by:
invoke
in interfaceIPCInterface
- Parameters:
methodName
- the name of the Methods to be calledparams
- Parameters of the Method- Returns:
- returns the result of the method
- Throws:
IPCException
-
getMethod
protected java.lang.reflect.Method getMethod(java.lang.Object target, java.lang.String methodName, java.lang.Object[] params) throws java.lang.Throwable
- Throws:
java.lang.Throwable
-
getMethod
protected java.lang.reflect.Method getMethod(java.lang.Object target, java.lang.String methodName, java.lang.Class<?>[] paramTypes) throws java.lang.Throwable
- Throws:
java.lang.Throwable
-
getTarget
protected java.lang.Object getTarget() throws IPCException
- Throws:
IPCException
-
unload
public void unload()
-
-