Hi ULC Users,

I am trying to write a small program to check if a file exists on the
client. I have created server side and client side code. On the client side
I create a file object and check for file.exists(); I will eventually use
the File object for other purposes like canRead, canWrite etc.

The problem I am having is that the server thread and the client threads are
not synchronized. I get a response back from the server before the client
checks if the file exists. I need server to wait for the client thread to
finish before it returns. In my test program, the "file exists" test result
comes back as false (default boolean value) and gets printed to system.out.
Once the TestProxy.start() method finishes the client side method
checkIsExists(...) gets invoked and returns true back to the
ULCFileUtilties.setIsFileExists(..). But this response is not caught and
returned to the test program.

Any help is appreciated in helping me figure out how I can block the server
from proceeding until the client finishes checking. I have tried setUIState,
fireActionPerformedULC, but nothing seems to work.

Thank You for your help,
Vin




Here is my code :
--------- Test invocation code ---

import com.ulcjava.base.application.AbstractApplication;
import com.ulcjava.base.development.DevelopmentRunner;


public class TestProxy extends AbstractApplication {
   public void start() {
       ULCFileUtilities proxy = new ULCFileUtilities("c:\\test.txt");
       boolean test = proxy.checkIsExists();
       System.out.println("File exists result: " + test);
   }

   public static void main(String[] args) {
       DevelopmentRunner.setApplicationClass(TestProxy.class);
       DevelopmentRunner.run();
   }
}

---------Server Side Code -----------------
public class ULCFileUtilities extends ULCProxy {
   private String fileName;
   public Boolean isFileExists = false;

   public ULCFileUtilities(String fileName) {
       setEventDeliveryMode(UlcEventCategories.ACTION_EVENT_CATEGORY,
           UlcEventConstants.SYNCHRONOUS_MODE);
       this.fileName = fileName;
       markUncollectable();
       upload();
   }

   public boolean checkIsExists() {
       Object[] fileNames = new Object[] { fileName };
       invokeUI("checkIsExists", fileNames);

       return getIsFileExists();
   }

   protected String typeString() {
       return "UIFileUtilities";
   }

   public void setIsFileExists(Boolean isExists) {
       isFileExists = isExists;
   }

   public boolean getIsFileExists() {
       return isFileExists.booleanValue();
   }
}

------------------- Client side Code -------------------

iimport com.ulcjava.base.client.UIProxy;

import java.io.File;


public class UIFileUtilities extends UIProxy {
   public UIFileUtilities() {
   }

   public void checkIsExists(String fileName) {
       File file = new File(fileName);
       boolean isExists = file.exists();
       Object[] arguments = new Object[] { isExists };
       invokeULC("setIsFileExists", arguments);
   }
}

Reply via email to