All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.razorvine.pyro.ProxyClassConstructor Maven / Gradle / Ivy

Go to download

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).

There is a newer version: 5.1
Show newest version
package net.razorvine.pyro;

import java.io.IOException;

import net.razorvine.pickle.IObjectConstructor;
import net.razorvine.pickle.PickleException;

public class ProxyClassConstructor implements IObjectConstructor {

	public PyroProxy construct(Object[] args) throws PickleException {
		if(args.length==0) {
			// no-arg constructor
			return new PyroProxy();
		} else if(args.length==1 && args[0] instanceof PyroURI) {
			// constructor with PyroURI arg
			try {
				return new PyroProxy((PyroURI)args[0]);
			} catch (IOException e) {
				throw new PickleException("can't create PyroProxy:" +e.getMessage());
			}
		} else if(args.length==3) {
			// constructor with hostname,port,objectid args
			String hostname=(String)args[0];
			Integer port=(Integer)args[1];
			String objectId=(String)args[2];
			try {
				return new PyroProxy(hostname, port, objectId);
			} catch (IOException e) {
				throw new PickleException("can't create PyroProxy:" +e.getMessage());
			}
		} else {
			throw new PickleException("invalid args for PyroProxy unpickling");
		}
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy