I was wondering what best practices were in java when running a nested class – im thinking of running an rmi server that would be created upon the instanciation of the parent class so, say
class foo() [the 'parent']
constructor for foo() - instanciates rmifoo()
this get a bit painful when you want to call a method from rmifoo() back in the ‘parent’ class (you cant simply import the class, because of rmi). one way is of course to make rmifoo() an actual child class, and then be able to access methods in the parent, but this seems needlessly OTT (esp because then, presumably you need to make the parent abstract, etc etc and that really complicates a lot of other functionality).
I was wonder what the best practise is in terms of setting up a system like this, so one can call methods back in the foo() class from within its server ie. rmifoo()
*********update*******
Code (as im thinking of it currently) would be somethine like:
A.java:
public class A {
B aBinstance;
public fooParent() {
[do something..]
}
}
B.Java
public class B {
public fooChild() {
[super].fooParent() (super wont work...?)
}
}
I think this is what you’re trying to do:
This is doable and very useful in some cases, but you end up with these circular references, and that is something that you usually want to avoid.
Think about why you need to call the class A from B. Maybe there is a way to split your problem into three classes and break your circular references that way.