CounterJvn2.java

Go to the documentation of this file.
00001 
00008 package counter;
00009 
00010 import jvn.JvnException;
00011 import jvn.JvnServerImpl;
00012 
00017 public class CounterJvn2 {
00018 
00023         public static void main(String[] args) {
00024                 try {
00025                         // initialize JVN
00026                         JvnServerImpl js = JvnServerImpl.jvnGetServer();
00027                         
00028                         if (js == null) {
00029                                 System.out.println("Counter stress test problem : cannot create server!");
00030                         }
00031                         else {
00032                                 // look up the IRC object in the JVN server
00033                                 // if not found, create it, and register it in the JVN server
00034                                 
00035                                 JvnIntegerWrapper jo = (JvnIntegerWrapper)(js.jvnLookupObject("Counter",JvnIntegerWrapper.class));
00036                                 if (jo == null) {
00037                                         jo = new JvnIntegerWrapper();
00038                                         // after creation, I have a write lock on the object
00039                                         jo.jvnUnLock();
00040                                         js.jvnRegisterObject("Counter", jo);
00041                                 }
00042                                 while(true) {
00043                                         try {
00044                                                 int number = jo.read();
00045                                                 System.out.println("Current number is "+number+", next number shall be "+(++number));
00046                                                 jo.write(number);
00047                                         } catch (JvnException je) {
00048                                                 System.out.println("Counter stress test problem : " + je.getMessage());
00049                                         }
00050                                 }
00051                         }
00052                 } catch (JvnException je) {
00053                         System.out.println("Counter stress test problem : " + je.getMessage());
00054                 }
00055         }
00056 }

Generated on Wed Jan 2 10:15:54 2008 for Javanaise by  doxygen 1.5.4