Author: bback
Date: 2006-02-12 13:57:03 +0000 (Sun, 12 Feb 2006)
New Revision: 8023

Modified:
   trunk/apps/frost-0.7/source/frost/fcp/FcpConnection.java
Log:
fixes to allow compile on Java 1.4 too

Modified: trunk/apps/frost-0.7/source/frost/fcp/FcpConnection.java
===================================================================
--- trunk/apps/frost-0.7/source/frost/fcp/FcpConnection.java    2006-02-12 
13:36:40 UTC (rev 8022)
+++ trunk/apps/frost-0.7/source/frost/fcp/FcpConnection.java    2006-02-12 
13:57:03 UTC (rev 8023)
@@ -48,6 +48,9 @@
     private BufferedInputStream fcpIn;
     private PrintStream fcpOut;

+    private long fcpConnectionId;
+    
+    private static long staticFcpConnectionId = 0;

     /**
      * Create a default connection to localhost using FCP
@@ -57,9 +60,9 @@
      * @exception IOException if there is a problem with the connection
      * to the FCP host.
      */
-    public FcpConnection() throws UnknownHostException, IOException, 
FcpToolsException {
-        this("127.0.0.1", 26000);
-    }
+//    public FcpConnection() throws UnknownHostException, IOException, 
FcpToolsException {
+//        this("127.0.0.1", 26000);
+//    }

     public FcpConnection(String host, String port) throws 
UnknownHostException, IOException, FcpToolsException {
         this(host, Integer.parseInt(port));
@@ -74,14 +77,20 @@
      * @exception IOException if there is a problem with the connection
      * to the FCP host.
      */
-    public FcpConnection(String host, int port) throws UnknownHostException, 
IOException, FcpToolsException {
+    private FcpConnection(String host, int port) throws UnknownHostException, 
IOException, FcpToolsException {
         this.host = InetAddress.getByName(host);
         this.port = port;
         fcpSock = new Socket(host,port);
         fcpSock.setSoTimeout(TIMEOUT);
         doHandshake(fcpSock);
         fcpSock.close();
+        
+        fcpConnectionId = getNextId();
     }
+    
+    private static synchronized long getNextId() {
+        return staticFcpConnectionId++;
+    }

     //needs reimplementation, fetches data from hallo
     public String[] getInfo() throws IOException, FcpToolsException {
@@ -176,7 +185,7 @@

         fcpOut.println("Verbosity=0");
         System.out.println("Verbosity=0");
-        fcpOut.println("Identifier=get-" + Thread.currentThread().getId() );
+        fcpOut.println("Identifier=get-" + fcpConnectionId );
         System.out.println("Identifier=get");
         fcpOut.println("ReturnType=direct");
         System.out.println("ReturnType=direct");
@@ -404,8 +413,8 @@
                fcpOut.println("DataLength=" + Integer.toString(dataLength));
                System.out.println("DataLength="+ Integer.toString(dataLength));

-               fcpOut.println("Identifier=put-" + 
Thread.currentThread().getId() );
-               System.out.println("Identifier=put-" + 
Thread.currentThread().getId());
+               fcpOut.println("Identifier=put-" + fcpConnectionId );
+               System.out.println("Identifier=put-" + fcpConnectionId );
                fcpOut.println("Verbosity=0");
                System.out.println("Verbosity=0");
                fcpOut.println("MaxRetries=3");
@@ -461,9 +470,9 @@
         fcpOut.println("ClientHello");
         logger.fine("ClientHello");
         System.out.println("ClientHello");
-        fcpOut.println("Name=hello-"+ Thread.currentThread().getId());
-        logger.fine("Name=hello-"+ Thread.currentThread().getId());
-        System.out.println("Name=hello-"+ Thread.currentThread().getId());
+        fcpOut.println("Name=hello-"+ fcpConnectionId);
+        logger.fine("Name=hello-"+ fcpConnectionId);
+        System.out.println("Name=hello-"+ fcpConnectionId);
         fcpOut.println("ExpectedVersion=0.7.0");
         logger.fine("ExpectedVersion=0.7.0");
         System.out.println("ExpectedVersion=0.7.0");


Reply via email to