dcsimg
RMI Server client App
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Rohit_Dhing
Posted On:   Tuesday, May 20, 2003 03:32 PM

Hello, I am currently developing an RMI Server/Client Application. To get to the main issue that I am having or what I need is some logic help. I basically want to be able to receive the output being thrown by the RMI server to be printed on the Client side without using sockets. The logic I came up with is by using a Vector that is populated with the outputstream of the RMI server. The Client basically forks off a thread and keeping requesting for the Vector from the RMI server. When the program intially starts the output retrieved from the vector is printed appropriately. But in the next run to retrieve the Vector is where I am facing a problem. The problem basically is the vector on t   More>>

Hello,


I am currently developing an RMI Server/Client Application. To get to the
main issue that I am having or what I need is some logic help. I basically want
to be able to receive the output being thrown by the RMI server to be printed on
the Client side without using sockets. The logic I came up with is by using a
Vector that is populated with the outputstream of the RMI server.


The Client basically forks off a thread and keeping requesting for the Vector
from the RMI server. When the program intially starts the output retrieved from
the vector is printed appropriately. But in the next run to retrieve the Vector
is where I am facing a problem. The problem basically is the vector on the RMI
server keeps getting populated with messages every second. My client needs keeps
requesting for the vector every second, and what happens is redundant
information gets printed. My logic is below :


Client Side:



private void startWriterTestThread(final int delay) {

new Thread(new Runnable() {

public void run() {

boolean flag = false;

String temp = null;  //This string stores the last line read from the
vector. Once the last line is read, the same line is

sent to the Server, which then looks it up on its vector and removes
everything before this line, since it has already been printed on the client
side

Vector v = null;

while(true){

try{

System.out.println("Temp --> " + temp);

if(temp == null || !(temp.equals("
"))) {

v = dm.getLogVector(temp);

//if(!(flag)){

Enumeration enum = v.elements();

while (enum.hasMoreElements()){

temp = enum.nextElement().toString();

if(!(temp.equals("
"))){ //The reason I look for /r/n is because for some
odd reason the the populated vector from the RMI server contains a carriage
return with a new line feed. And I don't want it to be printed!

System.out.println(temp);

//WriteToTextArea(temp + "
");

}

}

//Here is try to get the last element from the vector.  ...I am
sure I am wrong here.

temp = (String)v.lastElement();



}

else

{

try {

Thread.sleep(delay);

System.out.println("I am sleeping due to r n");

}

catch(InterruptedException e) {}

}

}

catch(java.rmi.RemoteException e){

System.out.println("Rmi Exception " + e);

}}}}).start();


Server Side:


public Vector getLogVector(String lastElement) throws RemoteException{

Vector newLogVector = (Vector) LogVector.clone();

if (newLogVector.indexOf(lastElement) != -1){

int i = 0;

int indx = newLogVector.indexOf(lastElement);

while (i < indx){

newLogVector.removeElementAt(i);

i++;

}

// System.out.println("Returning when object found ");

return newLogVector;

}

//System.out.println("Returning when either obj not found or null");

return LogVector;

}


 


I would really appreciate if someone could provide me some help in terms
of my logic or a better way to capture a output throw by remote rmi server
without the use of sockets!


 


 


 

   <<Less
About | Sitemap | Contact