J
Jeff
Hi, we are trying to implement the following:
Conditions: Both processes on same machine.
Process A - starts up independently, testfile CTGrabber.java
attempts to get the CTTest singleton object via class static method
and utilize accessor methods. Example could be a GUI process.
Process B - starts up independently, testfile CTTest.java starts up
on cmd line. Example could be a data gathering process.
Result: Process A is unable to get a handle to Process B object
(retrieveHandle function returns null).
Q: Is there a simple way of getting a handle to a object (in
another process) other than using RMI or ? The classfile is
accessible to both. We don't even have to control the creation, just
getting a handle is the main requirement.
I have enclosed copies of our test programs. However, I believe that
there must be a another way fundamentally to do this (ex. worst case,
somehow push reference externally out to file, read,etc.).
We are open to any suggestions that do not increase complexity or
force us to implement messaging software.
Thank you very much,
jeff
Test Code follows:
===========================================
<File: CTGrabber.java>
package CI;
import CI.*;
public class CTGrabber
{
public CTGrabber() {}
public static void main(String[] args)
{
CTTest test = CTTest.getCTTestHandle();
System.out.println(test);
System.out.println(test.getName());
}
} // END Class CombatGrabber
=============================================
<File: CTTest.java>
package CI;
public class CTTest
{
public static CTTest com;
public String name;
public static void main(String[] args)
{
if (args.length < 1)
{
System.out.println("--- Error \n Usage: java CTTest
<name>");
System.exit(0);
}
com = new CTTest();
com.setName(args[0]);
System.out.println("name is " + com.name + ", waiting....");
try{
Thread.sleep(60000);
}
catch (Exception e){
System.out.println("Exception E caught.");
}
}
private CTTest()
{
com = this;
name = new String("THIS DIDN'T WORK");
}
public static CTTest getCTTestHandle()
{
if (com != null)
return com;
else
return new CTTest();
}
public String getName(){
return name;
}
public void setName(String namestr){
name = namestr;
}
} // END class CTTest
===========================================
Conditions: Both processes on same machine.
Process A - starts up independently, testfile CTGrabber.java
attempts to get the CTTest singleton object via class static method
and utilize accessor methods. Example could be a GUI process.
Process B - starts up independently, testfile CTTest.java starts up
on cmd line. Example could be a data gathering process.
Result: Process A is unable to get a handle to Process B object
(retrieveHandle function returns null).
Q: Is there a simple way of getting a handle to a object (in
another process) other than using RMI or ? The classfile is
accessible to both. We don't even have to control the creation, just
getting a handle is the main requirement.
I have enclosed copies of our test programs. However, I believe that
there must be a another way fundamentally to do this (ex. worst case,
somehow push reference externally out to file, read,etc.).
We are open to any suggestions that do not increase complexity or
force us to implement messaging software.
Thank you very much,
jeff
Test Code follows:
===========================================
<File: CTGrabber.java>
package CI;
import CI.*;
public class CTGrabber
{
public CTGrabber() {}
public static void main(String[] args)
{
CTTest test = CTTest.getCTTestHandle();
System.out.println(test);
System.out.println(test.getName());
}
} // END Class CombatGrabber
=============================================
<File: CTTest.java>
package CI;
public class CTTest
{
public static CTTest com;
public String name;
public static void main(String[] args)
{
if (args.length < 1)
{
System.out.println("--- Error \n Usage: java CTTest
<name>");
System.exit(0);
}
com = new CTTest();
com.setName(args[0]);
System.out.println("name is " + com.name + ", waiting....");
try{
Thread.sleep(60000);
}
catch (Exception e){
System.out.println("Exception E caught.");
}
}
private CTTest()
{
com = this;
name = new String("THIS DIDN'T WORK");
}
public static CTTest getCTTestHandle()
{
if (com != null)
return com;
else
return new CTTest();
}
public String getName(){
return name;
}
public void setName(String namestr){
name = namestr;
}
} // END class CTTest
===========================================