net.razorvine.pickle.objects.Reconstructor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pyrolite Show documentation
Show all versions of pyrolite Show documentation
This library allows your Java program to interface very easily with the Python world. It uses the Pyro protocol to call methods on remote objects. (See https://pyro5.readthedocs.io/).
Pyrolite only implements part of the client side Pyro library, hence its name 'lite'... So if you don't need Pyro's full feature set, Pyrolite may be a good choice to connect java or .NET and python.
Version 5.0 changes: support Pyro5 wire protocol. Dropped support of Pyro4 (stick to version 4.xx for that).
package net.razorvine.pickle.objects;
import java.lang.reflect.Method;
import net.razorvine.pickle.IObjectConstructor;
import net.razorvine.pickle.PickleException;
/**
* This constructor is called by the helper methods that pickle protocol 0
* uses from the python copy_reg module to reconstruct c objects.
*/
public class Reconstructor implements IObjectConstructor {
public Object construct(Object[] args) {
if(args.length != 3)
throw new PickleException("invalid pickle data; expecting 3 args to copy_reg reconstructor but recieved " + args.length);
Object reconstructor = args[0];
try {
Method reconstruct=reconstructor.getClass().getMethod("reconstruct", Object.class, Object.class);
return reconstruct.invoke(reconstructor, args[1], args[2]);
} catch (Exception e) {
throw new PickleException("failed to reconstruct()", e);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy