From: Sherrell, D. <dsh...@ad...> - 2010-02-16 19:13:54
|
Allright, So I have a MessageInterface interface in Java as: package jyinterface.interfaces; public interface MessageInterface { public int getSource(); public int getDestination(); public int getLength(); public int getVersion(); public int getMessageID(); public int setSource(int val); public int setDestination(int val); public int setLength(int val); public int setVersion(int val); public int setMessageID(int val); } And a jython object that implements the interface: class Message(MessageInterface): def __init__(self): """@sig Message()""" self.length = 0 self.msg_verion = 0 self.source = 0 self.destination = 0 self.Message_ID = 0 f=open(path + 'Message.txt','r') #dictionary containing class attribute information useful for encode/decode #has keys: type complex_name bits name dimensions self.properties = pickle.load(f) f.close() def getLength(self): return self.length def getSource(self): return self.source def getDestination(self): return self.destination def getMessageID(self): return self.Message_ID def getVersion(self): return self.msg_version def setLength(self, val): self.length = val def setSource(self, val): self.source = val def setDestination(self, val): self.destination = val def setMessageId(self, val): self.Message_ID = val def setVersion(self, val): self.msg_version = val there is another jython object that inherits the Message object like this: class Network_Definition_Fields(NetworkDefinitionInterface,Message): def __init__(self, message = None): Message.__init__(self) self.number_of_subnets = None self.Preset_Net_Profiles = None .... .... when this object is instantiated in the jython code and Message.__init__ is invoked, I get an error self.length = val RunTimeError: maximum recursion depth exceeded A little background..i have existing python code that I am trying to integrate with java. So I'm using jython as the glue rather than being in a situation where I am developing code from scratch. Could my problem here be that I am inheriting from both the NetworkDefinitionInterface and Message? Your help is greatly appreciated. Thanks, Dana -----Original Message----- From: Alex Grönholm [mailto:ale...@ne...] Sent: Tuesday, February 16, 2010 9:08 AM To: jyt...@li... Subject: Re: [Jython-users] use jython object from java 16.2.2010 18:48, Sherrell, Dana kirjoitti: Hello, I am fairly new to java/jython integration so please be patient. I followed the jython factory examples to use the interpreter to call my jython objects and all is well until I need to access a user defined object in jython from java. The examples that I have seen use simple types in the interfaces.i need to access a complex data type. How do I access a user defined type - defined in the jython module - in my java app? So if my interface looked something like: public interface AFE_ClientInterface { public int messageId(); public String clientName(); public NetworkDefinition getNetworkDefinition(); .. .. public void shutDown(); } How do I translate the jython NetworkDefinition object into one that java can understand? Thanks, Dana You have to have a Java interface for NetworkDefinition, and the corresponding Jython class must inherit from that. |