gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r18729 - in gnunet-java: . src/org/gnunet/construct src/org


From: gnunet
Subject: [GNUnet-SVN] r18729 - in gnunet-java: . src/org/gnunet/construct src/org/gnunet/construct/parsers src/org/gnunet/messages src/org/gnunet/service src/org/gnunet/util src/org/grothoff test/org/gnunet
Date: Wed, 21 Dec 2011 09:58:15 +0100

Author: dold
Date: 2011-12-21 09:58:15 +0100 (Wed, 21 Dec 2011)
New Revision: 18729

Added:
   gnunet-java/src/org/gnunet/messages/MessageId.java
   gnunet-java/src/org/gnunet/messages/MessageIdAnnotationProcessor.java
   gnunet-java/src/org/gnunet/messages/MessageLoader.java
   gnunet-java/src/org/gnunet/messages/MsgMap.txt
   gnunet-java/src/org/gnunet/util/IOContinuation.java
   gnunet-java/src/org/gnunet/util/MessageReceiver.java
   gnunet-java/src/org/gnunet/util/MessageTransmitter.java
   gnunet-java/src/org/gnunet/util/RunaboutMessageReceiver.java
Removed:
   gnunet-java/build.xml
   gnunet-java/src/org/gnunet/construct/MessageId.java
   gnunet-java/src/org/gnunet/util/MessageHandler.java
   gnunet-java/src/org/gnunet/util/Receiver.java
   gnunet-java/src/org/gnunet/util/TransmitHandler.java
   gnunet-java/test/org/gnunet/util/
Modified:
   gnunet-java/ISSUES
   gnunet-java/gnunet-java.iml
   gnunet-java/src/org/gnunet/construct/Construct.java
   gnunet-java/src/org/gnunet/construct/UInt8.java
   gnunet-java/src/org/gnunet/construct/parsers/IntegerParser.java
   gnunet-java/src/org/gnunet/construct/parsers/StringParser.java
   gnunet-java/src/org/gnunet/messages/QueryMessage.java
   gnunet-java/src/org/gnunet/messages/SimpleTestMessage.java
   gnunet-java/src/org/gnunet/messages/SimpleTestMessage2.java
   gnunet-java/src/org/gnunet/messages/SizeTestMessage.java
   gnunet-java/src/org/gnunet/service/StatisticsService.java
   gnunet-java/src/org/gnunet/util/Client.java
   gnunet-java/src/org/gnunet/util/Configuration.java
   gnunet-java/src/org/gnunet/util/RelativeTime.java
   gnunet-java/src/org/gnunet/util/Scheduler.java
   gnunet-java/src/org/grothoff/Runabout.java
Log:
implemented annotation procesor for message IDs

Modified: gnunet-java/ISSUES
===================================================================
--- gnunet-java/ISSUES  2011-12-20 17:23:06 UTC (rev 18728)
+++ gnunet-java/ISSUES  2011-12-21 08:58:15 UTC (rev 18729)
@@ -52,8 +52,8 @@
 
 
 
-(* idea: gnunet-java uses a lot of reflection, should we use apt (annotation 
processing tool)
-  to do some basic static checks for runabouts and maybe construct 
annotations?) 
+(* idea: gnunet-java uses a lot of reflection, should we use apt (annotation 
processing too
+  to do some basic static checks for runabouts and maybe construct 
annotations?)
   
  
  
@@ -78,6 +78,27 @@
   * should work with ant and eclipse
   * dependencies: ann.proc <-> annotation classes
   
-  
- 
- 
\ No newline at end of file
+
+
+====
+
+(undocumented) issues with the Runabout: visit methods cannot access private 
properties/classes that are
+accessible from the scope of the visit method
+java.lang.IllegalAccessError: tried to access class 
org.gnunet.construct.Construct$ParserGenerator from class 
org.grothoff.GenCode00000003
+when Construct.ParserGenerator is declared private
+
+
+Runabout.java line 373: string comparison with "==" instead of .equals
+Does this rely on string interning?
+
+
+* Buffer sizes / buffer allocation in general
+
+
+why is there no receive_cancel in client.c (but in connection.c)
+
+
+notifyTransmitReady: how often do we know the exact size of the message we 
want to send, even if the message
+has not been constructed yet?
+
+when do we issue a transmit but cancel it?

Deleted: gnunet-java/build.xml
===================================================================
Modified: gnunet-java/gnunet-java.iml
===================================================================
--- gnunet-java/gnunet-java.iml 2011-12-20 17:23:06 UTC (rev 18728)
+++ gnunet-java/gnunet-java.iml 2011-12-21 08:58:15 UTC (rev 18729)
@@ -1,14 +1,14 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <module type="JAVA_MODULE" version="4">
   <component name="NewModuleRootManager" inherit-compiler-output="true">
-    <exclude-output />
     <content url="file://$MODULE_DIR$">
       <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
       <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
     </content>
-    <orderEntry type="inheritedJdk" />
+    <orderEntry type="jdk" jdkName="1.6" jdkType="JavaSDK" />
     <orderEntry type="sourceFolder" forTests="false" />
     <orderEntry type="library" name="lib" level="project" />
+    <orderEntry type="library" name="junit4" level="application" />
   </component>
 </module>
 

Modified: gnunet-java/src/org/gnunet/construct/Construct.java
===================================================================
--- gnunet-java/src/org/gnunet/construct/Construct.java 2011-12-20 17:23:06 UTC 
(rev 18728)
+++ gnunet-java/src/org/gnunet/construct/Construct.java 2011-12-21 08:58:15 UTC 
(rev 18729)
@@ -23,9 +23,8 @@
 
 /**
  * A version of Python's construct library for Java.
- * 
+ *
  * @author Christian Grothoff
- * 
  */
 public class Construct {
 
@@ -35,21 +34,18 @@
      * Given a byte array with a message, parse it into an object of type c. 
The
      * fields of the class are expected to be annotated with annotations from
      * the construct package.
-     * 
-     * @param data
-     *            serialized binary object data
-     * @param offset
-     *            where the message starts in data
-     * @param c
-     *            desired object type to return
+     *
+     * @param data   serialized binary object data
+     * @param offset where the message starts in data
+     * @param c      desired object type to return
      * @return instance of the desired object type
      */
     public static <T extends Message> T parseAs(byte[] data, int offset,
-            Class<T> c) {
+                                                Class<T> c) {
         T m;
 
         try {
-            m = (T) c.newInstance();
+            m = c.newInstance();
         } catch (InstantiationException e) {
             throw new InterfaceViolationException("Cannot instantiate 
Message");
         } catch (IllegalAccessException e) {
@@ -64,9 +60,9 @@
 
     /**
      * Create a Parser for a sub-class of Message. The result is always cached.
-     * 
-     * @param c
-     * @return
+     *
+     * @param c annotated sub-class of message
+     * @return a parser
      */
     public static Parser getParser(Class<? extends Message> c) {
 
@@ -82,7 +78,7 @@
     }
 
     private static Parser getParser(Class<? extends Message> c,
-            ParserGenerator pg) {
+                                    ParserGenerator pg) {
 
         SequenceParser parser = new SequenceParser();
         pg.c = c;
@@ -106,8 +102,11 @@
         return parser;
     }
 
-    private static class ParserGenerator extends Runabout {
+    // has to be public, accessed by Runabout (todo: can we do something about 
this scope issue?)
 
+    @SuppressWarnings("UnusedDeclaration")
+    public static class ParserGenerator extends Runabout {
+
         // the field we are currently generating a parser for
         Field field;
         // all annotations on the field
@@ -193,7 +192,9 @@
 
         public void visit(Nested n) {
 
-            Class<? extends Message> ct = (Class<? extends Message>) field
+            Class<? extends Message> ct;
+            //noinspection unchecked
+            ct = (Class<? extends Message>) field
                     .getType();
 
             Field old_f = field;
@@ -221,6 +222,7 @@
             Field f = field;
             int elemNumber = fsa.length();
 
+            //noinspection unchecked
             getParser((Class<? extends Message>) field.getType()
                     .getComponentType(), this);
 
@@ -231,6 +233,7 @@
             Field f = field;
             Class old_c = c;
 
+            //noinspection unchecked
             getParser((Class<? extends Message>) field.getType()
                     .getComponentType(), this);
 
@@ -256,13 +259,10 @@
      * Serialize a given message object to a binary byte array. The fields of
      * the object are expected to be annotated with annotations from the
      * construct package.
-     * 
-     * @param o
-     *            object to serialize
-     * @param data
-     *            where to write the binary object data
-     * @param offset
-     *            where to start writing data
+     *
+     * @param o      object to serialize
+     * @param data   where to write the binary object data
+     * @param offset where to start writing data
      * @return number of bytes written to data, -1 on error
      */
     public static int write(Message o, byte[] data, int offset) {
@@ -272,9 +272,8 @@
 
     /**
      * Compute the size of a serialized message.
-     * 
-     * @param o
-     *            object to serialize
+     *
+     * @param m object to serialize
      * @return number of bytes required, -1 on error
      */
     public static int getSize(Message m) {
@@ -306,9 +305,9 @@
 
         /**
          * Get the corresponding NumFieldType for a Field if possible
-         * 
-         * @param f
-         * @return
+         *
+         * @param f a field of numeric type
+         * @return the corresponding NumFieldType
          */
         public static NumFieldType getNumFieldType(Field f) {
             if (f.getType().equals(Long.TYPE)) {
@@ -332,24 +331,24 @@
         public static void setNumField(Object obj, NumFieldType ft, Field f, 
long val) {
             try {
                 switch (ft) {
-                case LONG_PRIM:
-                    f.setLong(obj, val);
-                    break;
-                case INT_PRIM:
-                    f.setInt(obj, (int) val);
-                    break;
-                case SHORT_PRIM:
-                    f.setShort(obj, (short) val);
-                    break;
-                case BYTE_PRIM:
-                    f.setByte(obj, (byte) val);
-                    break;
-                case CHAR_PRIM:
-                    f.setChar(obj, (char) val);
-                    break;
-                case BIGNUM:
-                    f.set(obj, BigInteger.valueOf(val));
-                    break;
+                    case LONG_PRIM:
+                        f.setLong(obj, val);
+                        break;
+                    case INT_PRIM:
+                        f.setInt(obj, (int) val);
+                        break;
+                    case SHORT_PRIM:
+                        f.setShort(obj, (short) val);
+                        break;
+                    case BYTE_PRIM:
+                        f.setByte(obj, (byte) val);
+                        break;
+                    case CHAR_PRIM:
+                        f.setChar(obj, (char) val);
+                        break;
+                    case BIGNUM:
+                        f.set(obj, BigInteger.valueOf(val));
+                        break;
                 }
             } catch (IllegalArgumentException e) {
                 throw new InterfaceViolationException("cannot access field");
@@ -359,7 +358,7 @@
         }
 
         public static Object followFieldPath(List<Field> fl, Object obj,
-                int depth) {
+                                             int depth) {
             for (int i = 0; i < depth; ++i) {
                 try {
                     obj = fl.get(i).get(obj);

Deleted: gnunet-java/src/org/gnunet/construct/MessageId.java
===================================================================
--- gnunet-java/src/org/gnunet/construct/MessageId.java 2011-12-20 17:23:06 UTC 
(rev 18728)
+++ gnunet-java/src/org/gnunet/construct/MessageId.java 2011-12-21 08:58:15 UTC 
(rev 18729)
@@ -1,18 +0,0 @@
-package org.gnunet.construct;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Assigns an id to a a message.
- * 
- * @author Florian Dold
- *
- */
address@hidden(RetentionPolicy.SOURCE)
address@hidden(ElementType.TYPE)
-public @interface MessageId {
-
-}

Modified: gnunet-java/src/org/gnunet/construct/UInt8.java
===================================================================
--- gnunet-java/src/org/gnunet/construct/UInt8.java     2011-12-20 17:23:06 UTC 
(rev 18728)
+++ gnunet-java/src/org/gnunet/construct/UInt8.java     2011-12-21 08:58:15 UTC 
(rev 18729)
@@ -1,3 +1,4 @@
+
 package org.gnunet.construct;
 
 import java.lang.annotation.ElementType;

Modified: gnunet-java/src/org/gnunet/construct/parsers/IntegerParser.java
===================================================================
--- gnunet-java/src/org/gnunet/construct/parsers/IntegerParser.java     
2011-12-20 17:23:06 UTC (rev 18728)
+++ gnunet-java/src/org/gnunet/construct/parsers/IntegerParser.java     
2011-12-21 08:58:15 UTC (rev 18729)
@@ -94,7 +94,6 @@
 
     @Override
     public void patchSizeFields(Message m, int frameSize) {
-        return;
     }
 
     public void writeByte(byte val, byte[] data, int offset) {

Modified: gnunet-java/src/org/gnunet/construct/parsers/StringParser.java
===================================================================
--- gnunet-java/src/org/gnunet/construct/parsers/StringParser.java      
2011-12-20 17:23:06 UTC (rev 18728)
+++ gnunet-java/src/org/gnunet/construct/parsers/StringParser.java      
2011-12-21 08:58:15 UTC (rev 18729)
@@ -59,7 +59,7 @@
         }
 
         System.arraycopy(b, 0, dstData, offset, b.length);
-        
+
         System.out.println(b.length);
 
         dstData[offset + b.length] = (byte) 0;
@@ -70,7 +70,6 @@
 
     @Override
     public void patchSizeFields(Message m, int frameSize) {
-        return;
     }
 
 }

Copied: gnunet-java/src/org/gnunet/messages/MessageId.java (from rev 18646, 
gnunet-java/src/org/gnunet/construct/MessageId.java)
===================================================================
--- gnunet-java/src/org/gnunet/messages/MessageId.java                          
(rev 0)
+++ gnunet-java/src/org/gnunet/messages/MessageId.java  2011-12-21 08:58:15 UTC 
(rev 18729)
@@ -0,0 +1,18 @@
+package org.gnunet.messages;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Assigns an id to a a message.
+ * 
+ * @author Florian Dold
+ *
+ */
address@hidden(RetentionPolicy.SOURCE)
address@hidden(ElementType.TYPE)
+public @interface MessageId {
+    int value();
+}

Added: gnunet-java/src/org/gnunet/messages/MessageIdAnnotationProcessor.java
===================================================================
--- gnunet-java/src/org/gnunet/messages/MessageIdAnnotationProcessor.java       
                        (rev 0)
+++ gnunet-java/src/org/gnunet/messages/MessageIdAnnotationProcessor.java       
2011-12-21 08:58:15 UTC (rev 18729)
@@ -0,0 +1,69 @@
+package org.gnunet.messages;
+
+import javax.annotation.processing.*;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.TypeElement;
+import javax.tools.Diagnostic;
+import javax.tools.FileObject;
+import javax.tools.StandardLocation;
+import java.io.IOException;
+import java.io.Writer;
+import java.lang.annotation.Annotation;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+
+/**
+ * Creates a resource file 'MsgMap.txt' in the package org.gnunet.messages.
+ */
address@hidden({"org.gnunet.messages.MessageId"})
address@hidden(SourceVersion.RELEASE_6)
+public class MessageIdAnnotationProcessor extends AbstractProcessor {
+    HashMap<Integer, String> msgmap = new HashMap<Integer, String>();
+
+    @Override
+    public boolean process(Set<? extends TypeElement> typeElements, 
RoundEnvironment roundEnvironment) {
+        if (roundEnvironment.processingOver()) {
+            Filer filer = processingEnv.getFiler();
+            FileObject outfile;
+            try {
+                outfile = filer.createResource(StandardLocation.SOURCE_OUTPUT, 
"org.gnunet.messages", "MsgMap.txt");
+            } catch (IOException e) {
+                
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "Could not 
create MsgMap2.txt");
+                return false;
+            }
+
+            try {
+                Writer w = outfile.openWriter();
+                for (Map.Entry<Integer, String> e : msgmap.entrySet()) {
+                    w.write("" + e.getKey() + "=" + e.getValue() + "\n");
+                }
+                w.close();
+            } catch (IOException e) {
+                
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "Could not 
write MsgMap.txt");
+            }
+
+            processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, 
"message map written to " + outfile.toUri());
+
+        } else {
+            for (Element e : roundEnvironment.getRootElements()) {
+                Annotation ann = e.getAnnotation(MessageId.class);
+                if (ann != null) {
+                    int id = ((MessageId) 
e.getAnnotation(MessageId.class)).value();
+                    String fqn = e.asType().toString();
+                    if (msgmap.containsKey(id)) {
+                        
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR,
+                                String.format("duplicate @MessageId(%s) in %s 
and %s found",
+                                        id, fqn, msgmap.get(id)));
+                    } else {
+                        msgmap.put(id, fqn);
+                    }
+                }
+            }
+        }
+
+        return false;
+    }
+}

Added: gnunet-java/src/org/gnunet/messages/MessageLoader.java
===================================================================
--- gnunet-java/src/org/gnunet/messages/MessageLoader.java                      
        (rev 0)
+++ gnunet-java/src/org/gnunet/messages/MessageLoader.java      2011-12-21 
08:58:15 UTC (rev 18729)
@@ -0,0 +1,60 @@
+/*
+ *
+ * This file is part of GNUnet.
+ * (C) 2011 Christian Grothoff (and other contributing authors)
+ *
+ * GNUnet is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * GNUnet is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNUnet; see the file COPYING.  If not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+package org.gnunet.messages;
+
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.HashMap;
+
+public class MessageLoader {
+    private static HashMap<Integer, String> msgmap;
+    static void loadMessageMap() {
+        URL loc = MessageLoader.class.getResource("MsgMap.txt");
+        if (loc == null) {
+            throw new RuntimeException("could not load message map");
+        }
+        BufferedReader in;
+        try {
+            in = new BufferedReader(new InputStreamReader(loc.openStream()));
+        } catch (IOException e) {
+            throw new RuntimeException("could not open message map");
+        }
+        String line;
+        try {
+            while((line = in.readLine()) != null) {
+                String[] m = line.split("=");
+                if (m.length != 2) {
+                    throw new RuntimeException("invalid message map format");
+                }
+                int id = Integer.parseInt(m[0].trim());
+                String fqn = m[1].trim();
+                msgmap.put(id, fqn);
+            }
+        } catch (IOException e) {
+            throw new RuntimeException("could not read message map");
+        }
+    }
+}

Added: gnunet-java/src/org/gnunet/messages/MsgMap.txt
===================================================================
--- gnunet-java/src/org/gnunet/messages/MsgMap.txt                              
(rev 0)
+++ gnunet-java/src/org/gnunet/messages/MsgMap.txt      2011-12-21 08:58:15 UTC 
(rev 18729)
@@ -0,0 +1,3 @@
+987=org.gnunet.messages.SizeTestMessage
+291=org.gnunet.messages.QueryMessage
+321=org.gnunet.messages.SimpleTestMessage

Modified: gnunet-java/src/org/gnunet/messages/QueryMessage.java
===================================================================
--- gnunet-java/src/org/gnunet/messages/QueryMessage.java       2011-12-20 
17:23:06 UTC (rev 18728)
+++ gnunet-java/src/org/gnunet/messages/QueryMessage.java       2011-12-21 
08:58:15 UTC (rev 18729)
@@ -1,12 +1,11 @@
 package org.gnunet.messages;
 
 import org.gnunet.construct.ByteFill;
-import org.gnunet.construct.MessageId;
 import org.gnunet.construct.Nested;
 import org.gnunet.construct.UInt8;
 
 
address@hidden
address@hidden(0x123)
 public class QueryMessage implements Message {
 
     @Nested

Modified: gnunet-java/src/org/gnunet/messages/SimpleTestMessage.java
===================================================================
--- gnunet-java/src/org/gnunet/messages/SimpleTestMessage.java  2011-12-20 
17:23:06 UTC (rev 18728)
+++ gnunet-java/src/org/gnunet/messages/SimpleTestMessage.java  2011-12-21 
08:58:15 UTC (rev 18729)
@@ -4,6 +4,8 @@
 import org.gnunet.construct.Nested;
 import org.gnunet.construct.UInt8;
 
address@hidden(321
+)
 public class SimpleTestMessage implements Message {
 
     @UInt8

Modified: gnunet-java/src/org/gnunet/messages/SimpleTestMessage2.java
===================================================================
--- gnunet-java/src/org/gnunet/messages/SimpleTestMessage2.java 2011-12-20 
17:23:06 UTC (rev 18728)
+++ gnunet-java/src/org/gnunet/messages/SimpleTestMessage2.java 2011-12-21 
08:58:15 UTC (rev 18729)
@@ -3,6 +3,8 @@
 import org.gnunet.construct.UInt32;
 import org.gnunet.construct.ZeroTerminatedString;
 
+
+//@MessageId(321)
 public class SimpleTestMessage2 implements Message {
 
     @UInt32

Modified: gnunet-java/src/org/gnunet/messages/SizeTestMessage.java
===================================================================
--- gnunet-java/src/org/gnunet/messages/SizeTestMessage.java    2011-12-20 
17:23:06 UTC (rev 18728)
+++ gnunet-java/src/org/gnunet/messages/SizeTestMessage.java    2011-12-21 
08:58:15 UTC (rev 18729)
@@ -4,6 +4,7 @@
 import org.gnunet.construct.FrameSize;
 import org.gnunet.construct.UInt16;
 
address@hidden(987)
 public class SizeTestMessage implements Message {
 
     @FrameSize

Modified: gnunet-java/src/org/gnunet/service/StatisticsService.java
===================================================================
--- gnunet-java/src/org/gnunet/service/StatisticsService.java   2011-12-20 
17:23:06 UTC (rev 18728)
+++ gnunet-java/src/org/gnunet/service/StatisticsService.java   2011-12-21 
08:58:15 UTC (rev 18729)
@@ -36,7 +36,7 @@
         void cancel() {
             throw new UnsupportedOperationException();
         }
-    };
+    }
 
     interface Iterator {
         public int call(String subsystem, String name, int value,

Modified: gnunet-java/src/org/gnunet/util/Client.java
===================================================================
--- gnunet-java/src/org/gnunet/util/Client.java 2011-12-20 17:23:06 UTC (rev 
18728)
+++ gnunet-java/src/org/gnunet/util/Client.java 2011-12-21 08:58:15 UTC (rev 
18729)
@@ -19,17 +19,25 @@
  */
 package org.gnunet.util;
 
+import org.gnunet.exceptions.InterfaceViolationException;
+import org.gnunet.messages.Message;
+import org.gnunet.util.Scheduler.Task;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.nio.ByteBuffer;
+import java.nio.MappedByteBuffer;
 import java.nio.channels.SocketChannel;
 import java.nio.channels.spi.SelectorProvider;
 
-import org.gnunet.messages.Message;
-import org.gnunet.util.Scheduler.Task;
 
 /**
  * Represents a connection to a service.
  */
 public class Client {
-    public static class TransmitHandle {
+
+
+    public class TransmitHandle {
         /**
          * Cancel a request for notification.
          */
@@ -38,73 +46,130 @@
         }
     }
 
-    public class Transmitter {
-        public void transmit(Message m) {
+    public class MessageSink {
 
+    }
+
+    private class ReceiveHelperTask implements Task {
+
+        private MessageReceiver receiver;
+
+        public ReceiveHelperTask(MessageReceiver receiver) {
+            this.receiver = receiver;
         }
+
+        @Override
+        public void run(Context ctx) {
+            if (ctx.reasons.contains(Scheduler.Reason.TIMEOUT)) {
+                receiver.handleTimeout();
+            } else if (ctx.reasons.contains(Scheduler.Reason.READ_READY)) {
+                //chan.read();
+                // recvBuffer.
+            } else {
+                // XXX: what to do here?
+                throw new RuntimeException();
+            }
+        }
     }
 
-    /**
-     * Wait until the service is running.
-     * 
-     * @param service
-     *            name of the service to wait for
-     * @param cfg
-     *            configuration to use
-     * @param timeout
-     *            how long to wait at most in ms
-     * @param task
-     *            task to run if service is running (reason will be
-     *            "PREREQ_DONE" (service running) or "TIMEOUT" (service not
-     *            known to be running))
-     */
+    private class TransmitHelperTask implements Task {
 
-    public static void serviceTest(final String service_name,
-            final Configuration cfg, final RelativeTime timeout, final Task t) 
{
-        throw new UnsupportedOperationException();
+        private MessageTransmitter transmitter;
+
+        public TransmitHelperTask(MessageTransmitter transmitter) {
+            this.transmitter = transmitter;
+        }
+
+        @Override
+        public void run(Context ctx) {
+        }
     }
 
+
+    private final int INITIAL_BUFFER_SIZE=128;
+    private SocketChannel chan;
+    boolean recvActive=false;
+    ByteBuffer recvBuffer = ByteBuffer.allocateDirect(INITIAL_BUFFER_SIZE);
+
+    Object transmitQueue;
+    Object transmitBuffer;
+
+
     /**
      * Get a connection with a service.
-     * 
-     * @param service_name
-     *            name of the service
-     * @param cfg
-     *            configuration to use
+     *
+     * @param serviceName name of the service
+     * @param cfg         configuration to use
      */
-    public Client(final String serviceName, final Configuration cfg) {
-
+    public Client(String serviceName, Configuration cfg) {
         // XXX: catch exn
-        long port = cfg.getValueNumer(serviceName, "PORT");
+        int port = (int) cfg.getValueNumer(serviceName, "PORT");
         if (port > 65535 || port <= 0) {
             // XXX: throw something else
             throw new RuntimeException("invalid port");
         }
         String hostname = cfg.getValueString(serviceName, "HOSTNAME");
-        
-        SocketChannel chan = SelectorProvider.provider().openSocketChannel();
+        try {
+            chan = SelectorProvider.provider().openSocketChannel();
+            chan.configureBlocking(false);
+        } catch (IOException e) {
+            throw new RuntimeException("fatal: non-blocking network IO 
unavailable");
+        }
 
-        // [...]
+        try {
+            // XXX: do we really want to connect here? is connect nonblocking?
+            chan.connect(new InetSocketAddress(hostname, port));
+        } catch (IOException e) {
+            // todo: correct exception handling
+            throw new RuntimeException("connect failed");
+        }
     }
 
     /**
-     * Read from the service.
-     * 
-     * @param handler
-     *            function to call with the message
-     * @param timeout
-     *            how long to wait until timing out
+     * Wait until the service is running.
+     *
+     * @param service_name name of the service to wait for
+     * @param cfg          configuration to use
+     * @param timeout      how long to wait at most in ms
+     * @param t            task to run if service is running (reason will be
+     *                     "PREREQ_DONE" (service running) or "TIMEOUT" 
(service not
+     *                     known to be running))
      */
-    public void receive(final MessageHandler handler, final RelativeTime 
timeout) {
+    public void serviceTest(String service_name,
+                            Configuration cfg, RelativeTime timeout, Task t) {
         throw new UnsupportedOperationException();
     }
 
+
+    /**
+     * Receive one message from the service.
+     *
+     * @param receiver MessageReceiver that is responsible for the received 
message
+     * @param timeout  how long to wait until timing out (timeout calls 
MessageReceiver.timeout)
+     */
+    public void receive(MessageReceiver receiver, RelativeTime timeout) {
+        if (recvActive) {
+            throw new InterfaceViolationException("receive must not be called 
while receiving");
+        }
+        ReceiveHelperTask task = new ReceiveHelperTask(receiver);
+        Scheduler.addRead(timeout, chan, task);
+    }
+
     public TransmitHandle notifyTransmitReady(int size, RelativeTime timeout,
-            boolean autoRetry, TransmitHandler cb) {
-        Scheduler.addWrite(timeout, chan, t);   
+                                              boolean autoRetry, 
MessageTransmitter transmitter) {
+        TransmitHelperTask task = new TransmitHelperTask(transmitter);
+        Scheduler.addWrite(timeout, chan, task);
+        return null;
     }
 
-    // public TransmitHandle transmit(Message m, RelativeTime timeout, boolean
-    // autoRetry, )
+    public void transmitAndGetResponse(Message msg, RelativeTime timeout, 
MessageReceiver receiver,
+                                       boolean autoRetry) {
 
+    }
+
+
+    public void transmit(Message m, RelativeTime timeout, boolean autoRetry, 
IOContinuation cont) {
+        // not implemented / wait for c api
+    }
+
 }

Modified: gnunet-java/src/org/gnunet/util/Configuration.java
===================================================================
--- gnunet-java/src/org/gnunet/util/Configuration.java  2011-12-20 17:23:06 UTC 
(rev 18728)
+++ gnunet-java/src/org/gnunet/util/Configuration.java  2011-12-21 08:58:15 UTC 
(rev 18729)
@@ -20,26 +20,16 @@
 
 package org.gnunet.util;
 
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Scanner;
-import java.util.Set;
-import java.util.regex.Pattern;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.*;
+import java.util.*;
+import java.util.regex.Pattern;
+
 /**
  * Configuration management.
- * 
+ *
  * @author Florian Dold
  */
 public class Configuration {
@@ -71,7 +61,7 @@
     }
 
     public boolean appendValueFilename(final String section,
-            final String option, final String value) {
+                                       final String option, final String 
value) {
         throw new UnsupportedOperationException();
     }
 
@@ -79,9 +69,8 @@
      * Expand an expression of the form "$FOO/BAR" to "DIRECTORY/BAR" where
      * either in the "PATHS" section or the environment "FOO" is set to
      * "DIRECTORY".
-     * 
-     * @param orig
-     *            string to $-expand
+     *
+     * @param orig string to $-expand
      * @return $-expanded string
      */
     public String expandDollar(String orig) {
@@ -101,9 +90,8 @@
 
     /**
      * Returns all configuration options in a section.
-     * 
-     * @param s
-     *            the section of interest
+     *
+     * @param s the section of interest
      * @return an unmodifiable view of the section.
      */
     public Map<String, String> getSection(final String s) {
@@ -116,7 +104,7 @@
 
     /**
      * Returns the names of all non-empty sections
-     * 
+     *
      * @return set of non-empty section names
      */
     public Set<String> getSections() {
@@ -125,18 +113,15 @@
 
     /**
      * Get a configuration value that should be in a set of predefined strings
-     * 
-     * @param section
-     *            section of interest
-     * @param option
-     *            option of interest
-     * @param choices
-     *            list of legal values
+     *
+     * @param section section of interest
+     * @param option  option of interest
+     * @param choices list of legal values
      * @return matching value from choices
      * @throws ParsingError
      */
     public String getValueChoice(final String section, final String option,
-            final Iterable<String> choices) {
+                                 final Iterable<String> choices) {
         final String value = getValueString(section, option);
         if (value == null) {
             throw new ParsingError(String.format(
@@ -157,13 +142,13 @@
     }
 
     public List<String> getValueFilenames(final String section,
-            final String option) {
+                                          final String option) {
         throw new UnsupportedOperationException();
     }
 
     /**
      * Get a configuration value that should be a number
-     * 
+     *
      * @param section
      * @param option
      * @return null if value not in configuration, the option's value otherwise
@@ -184,7 +169,7 @@
 
     /**
      * Set an option to a string value in a section.
-     * 
+     *
      * @param section
      * @param option
      * @throws ParsingError
@@ -200,7 +185,7 @@
 
     /**
      * XXX: how is the time stored?
-     * 
+     *
      * @param section
      * @param option
      * @return null if option not found
@@ -211,11 +196,9 @@
 
     /**
      * Gets a configuration value that should be in a set of {"YES","NO"}.
-     * 
-     * @param section
-     *            section of interest
-     * @param option
-     *            option of interest
+     *
+     * @param section section of interest
+     * @param option  option of interest
      * @return true, false, null
      */
     public boolean getValueYesNo(final String section, final String option) {
@@ -238,13 +221,10 @@
 
     /**
      * Tests if we have a value for a particular option.
-     * 
-     * @param section
-     *            section of interest
-     * @param option
-     *            option of interest
+     *
+     * @param section section of interest
+     * @param option  option of interest
      * @return true if so, false of not
-     * 
      */
     public boolean haveValue(final String section, final String option) {
         return sections.containsKey(section)
@@ -269,9 +249,8 @@
     /**
      * Parse a configuration file, add all of the options in the file to the
      * configuration environment.
-     * 
-     * @param filename
-     *            name of the configuration file
+     *
+     * @param filename name of the configuration file
      * @throws ParsingError
      */
     public void parse(final String filename) {
@@ -322,31 +301,31 @@
     }
 
     public boolean removeValueFilename(final String section,
-            final String option, final String value) {
+                                       final String option, final String 
value) {
         throw new UnsupportedOperationException();
     }
 
     /**
      * Set an option to a string value in a section.
-     * 
+     *
      * @param section
      * @param option
      * @param value
      */
     public void setValueNumber(final String section, final String option,
-            final long value) {
+                               final long value) {
         setValueString(section, option, "" + value);
     }
 
     /**
      * Set an option to a string value in a section.
-     * 
+     *
      * @param section
      * @param option
      * @param value
      */
     public void setValueString(final String section, final String option,
-            final String value) {
+                               final String value) {
         Map<String, String> table = sections.get(section);
         if (table == null) {
             table = new LinkedHashMap<String, String>();
@@ -357,9 +336,8 @@
 
     /**
      * Write configuration file.
-     * 
-     * @param filename
-     *            where to write the configuration
+     *
+     * @param filename where to write the configuration
      * @throws IOException
      */
     public void write(final String filename) throws IOException {
@@ -380,12 +358,9 @@
     /**
      * Write only configuration entries that have been changed to configuration
      * file.
-     * 
-     * @param cfgNew
-     *            new configuration
-     * 
-     * @param filename
-     *            where to write the configuration diff between default and new
+     *
+     * @param cfgNew   new configuration
+     * @param filename where to write the configuration diff between default 
and new
      */
     public void writeDiffs(final Configuration cfgNew, final String filename) {
         throw new UnsupportedOperationException();

Added: gnunet-java/src/org/gnunet/util/IOContinuation.java
===================================================================
--- gnunet-java/src/org/gnunet/util/IOContinuation.java                         
(rev 0)
+++ gnunet-java/src/org/gnunet/util/IOContinuation.java 2011-12-21 08:58:15 UTC 
(rev 18729)
@@ -0,0 +1,36 @@
+/*
+ *
+ * This file is part of GNUnet.
+ * (C) 2011 Christian Grothoff (and other contributing authors)
+ *
+ * GNUnet is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * GNUnet is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNUnet; see the file COPYING.  If not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+package org.gnunet.util;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: flodo
+ * Date: 12/19/11
+ * Time: 5:39 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public interface IOContinuation {
+    void handleSuccess();
+    void handleTimeout();
+
+}

Deleted: gnunet-java/src/org/gnunet/util/MessageHandler.java
===================================================================
--- gnunet-java/src/org/gnunet/util/MessageHandler.java 2011-12-20 17:23:06 UTC 
(rev 18728)
+++ gnunet-java/src/org/gnunet/util/MessageHandler.java 2011-12-21 08:58:15 UTC 
(rev 18729)
@@ -1,43 +0,0 @@
-/*
-     This file is part of GNUnet.
-     (C) 2009 Christian Grothoff (and other contributing authors)
-
-     GNUnet is free software; you can redistribute it and/or modify
-     it under the terms of the GNU General Public License as published
-     by the Free Software Foundation; either version 2, or (at your
-     option) any later version.
-
-     GNUnet is distributed in the hope that it will be useful, but
-     WITHOUT ANY WARRANTY; without even the implied warranty of
-     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-     General Public License for more details.
-
-     You should have received a copy of the GNU General Public License
-     along with GNUnet; see the file COPYING.  If not, write to the
-     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-     Boston, MA 02111-1307, USA.
- */
-
-package org.gnunet.util;
-
-import org.gnunet.messages.Message;
-import org.grothoff.Runabout;
-import org.grothoff.Runabout;
-
-/**
- * 
- * @author Florian Dold
- * 
- */
-public abstract class MessageHandler extends Runabout {
-
-    /**
-     * Method to call when we receive a message from the service.
-     * 
-     * @param msg
-     *            message received, NULL on timeout or fatal error
-     */
-    public void process(Message m) {
-        this.visitAppropriate(m);
-    }
-}

Copied: gnunet-java/src/org/gnunet/util/MessageReceiver.java (from rev 18646, 
gnunet-java/src/org/gnunet/util/MessageHandler.java)
===================================================================
--- gnunet-java/src/org/gnunet/util/MessageReceiver.java                        
        (rev 0)
+++ gnunet-java/src/org/gnunet/util/MessageReceiver.java        2011-12-21 
08:58:15 UTC (rev 18729)
@@ -0,0 +1,46 @@
+/*
+     This file is part of GNUnet.
+     (C) 2009 Christian Grothoff (and other contributing authors)
+
+     GNUnet is free software; you can redistribute it and/or modify
+     it under the terms of the GNU General Public License as published
+     by the Free Software Foundation; either version 2, or (at your
+     option) any later version.
+
+     GNUnet is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
+
+     You should have received a copy of the GNU General Public License
+     along with GNUnet; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+     Boston, MA 02111-1307, USA.
+ */
+
+package org.gnunet.util;
+
+import org.gnunet.messages.Message;
+import org.grothoff.Runabout;
+import org.grothoff.Runabout;
+
+/**
+ * 
+ * @author Florian Dold
+ * 
+ */
+interface MessageReceiver {
+
+    /**
+     * Method to call when we receive a message from the service.
+     * 
+     * @param msg
+     *            message received, NULL on timeout or fatal error
+     */
+    public void process(Message msg);
+
+    /**
+     * Method to call on timeout.
+     */
+    public void handleTimeout();
+}

Copied: gnunet-java/src/org/gnunet/util/MessageTransmitter.java (from rev 
18646, gnunet-java/src/org/gnunet/util/TransmitHandler.java)
===================================================================
--- gnunet-java/src/org/gnunet/util/MessageTransmitter.java                     
        (rev 0)
+++ gnunet-java/src/org/gnunet/util/MessageTransmitter.java     2011-12-21 
08:58:15 UTC (rev 18729)
@@ -0,0 +1,7 @@
+package org.gnunet.util;
+
+public interface MessageTransmitter {
+    public void transmit(Client.MessageSink sink);
+
+    public void handleTimeout();
+}

Deleted: gnunet-java/src/org/gnunet/util/Receiver.java
===================================================================
--- gnunet-java/src/org/gnunet/util/Receiver.java       2011-12-20 17:23:06 UTC 
(rev 18728)
+++ gnunet-java/src/org/gnunet/util/Receiver.java       2011-12-21 08:58:15 UTC 
(rev 18729)
@@ -1,38 +0,0 @@
-/*
-     This file is part of GNUnet.
-     (C) 2009 Christian Grothoff (and other contributing authors)
-
-     GNUnet is free software; you can redistribute it and/or modify
-     it under the terms of the GNU General Public License as published
-     by the Free Software Foundation; either version 2, or (at your
-     option) any later version.
-
-     GNUnet is distributed in the hope that it will be useful, but
-     WITHOUT ANY WARRANTY; without even the implied warranty of
-     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-     General Public License for more details.
-
-     You should have received a copy of the GNU General Public License
-     along with GNUnet; see the file COPYING.  If not, write to the
-     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-     Boston, MA 02111-1307, USA.
- */
-
-package org.gnunet.util;
-
-import java.net.SocketAddress;
-
-public interface Receiver {
-    /**
-     * Callback function for data received from the network.
-     * 
-     * @param buf
-     *            received data
-     * @param sockaddr
-     *            address of the sender
-     * @param errCode
-     *            XXX errno? really?! should this be an IO exception?
-     */
-    public void receive(byte[] buf, SocketAddress sockaddr, int errCode);
-
-}

Modified: gnunet-java/src/org/gnunet/util/RelativeTime.java
===================================================================
--- gnunet-java/src/org/gnunet/util/RelativeTime.java   2011-12-20 17:23:06 UTC 
(rev 18728)
+++ gnunet-java/src/org/gnunet/util/RelativeTime.java   2011-12-21 08:58:15 UTC 
(rev 18729)
@@ -75,9 +75,7 @@
 
     /**
      * Divide relative time by a given factor.
-     * 
-     * @param rel
-     *            some duration
+     *
      * @param factor
      *            integer to divide by
      * @return FOREVER if this=FOREVER or factor=0; otherwise this/factor

Added: gnunet-java/src/org/gnunet/util/RunaboutMessageReceiver.java
===================================================================
--- gnunet-java/src/org/gnunet/util/RunaboutMessageReceiver.java                
                (rev 0)
+++ gnunet-java/src/org/gnunet/util/RunaboutMessageReceiver.java        
2011-12-21 08:58:15 UTC (rev 18729)
@@ -0,0 +1,17 @@
+package org.gnunet.util;
+
+import org.gnunet.messages.Message;
+import org.grothoff.Runabout;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: flodo
+ * Date: 12/19/11
+ * Time: 3:08 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public abstract class RunaboutMessageReceiver extends Runabout implements 
MessageReceiver  {
+    public void process(Message msg) {
+        this.visitAppropriate(msg);
+    }
+}

Modified: gnunet-java/src/org/gnunet/util/Scheduler.java
===================================================================
--- gnunet-java/src/org/gnunet/util/Scheduler.java      2011-12-20 17:23:06 UTC 
(rev 18728)
+++ gnunet-java/src/org/gnunet/util/Scheduler.java      2011-12-21 08:58:15 UTC 
(rev 18729)
@@ -20,28 +20,17 @@
 
 package org.gnunet.util;
 
-import java.io.IOException;
-import java.nio.channels.Channel;
-import java.nio.channels.ClosedChannelException;
-import java.nio.channels.SelectableChannel;
-import java.nio.channels.SelectionKey;
-import java.nio.channels.Selector;
-import java.nio.channels.spi.SelectorProvider;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.EnumSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.PriorityQueue;
-import java.util.Queue;
-import java.util.Set;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.IOException;
+import java.nio.channels.*;
+import java.nio.channels.spi.SelectorProvider;
+import java.util.*;
+
 /**
  * Schedule computations using CPS
- * 
+ *
  * @author Florian Dold
  */
 public class Scheduler {
@@ -74,7 +63,7 @@
         Priority priority;
 
         TaskIdentifier(final Task t, final Priority priority,
-                final boolean liveness, final TaskIdentifier prereq) {
+                       final boolean liveness, final TaskIdentifier prereq) {
             this.task = t;
             this.priority = priority == null ? active_task.priority : priority;
             this.liveness = liveness;
@@ -97,7 +86,7 @@
         boolean selected = false;
 
         TimeoutTask(final Task t, final Priority p, final boolean liveness,
-                final TaskIdentifier prereq, final RelativeTime delay) {
+                    final TaskIdentifier prereq, final RelativeTime delay) {
             super(t, p, liveness, prereq);
             timeout = delay.toAbsolute();
         }
@@ -162,7 +151,7 @@
     };
 
     public static TaskIdentifier addAfter(final TaskIdentifier prereq,
-            final Task t) {
+                                          final Task t) {
         return addSelect(Priority.KEEP, prereq, RelativeTime.ZERO, null, null,
                 t);
     }
@@ -172,7 +161,7 @@
      * the same priority.
      */
     public static void addContinuation(final Task task,
-            final EnumSet<Reason> reason) {
+                                       final EnumSet<Reason> reason) {
         assert active_task == null || active_task.priority != null;
         final TaskIdentifier tid = new TaskIdentifier(task, Priority.KEEP,
                 current_liveness, null);
@@ -180,18 +169,15 @@
     }
 
     public static TaskIdentifier addDelayed(final RelativeTime delay,
-            final Task task) {
+                                            final Task task) {
         return addSelect(Priority.KEEP, null, delay, null, null, task);
     }
 
     /**
      * Schedule a new task to be run as soon as possible. The task will be run
      * with the priority of the calling task.
-     * 
-     * @param task
-     *            main function of the task
-     * @param task_cls
-     *            closure of task
+     *
+     * @param task main function of the task
      * @return unique task identifier for the job only valid until "task" is
      *         started!
      */
@@ -201,10 +187,10 @@
     }
 
     // should register the channels with the selector
-    public static TaskIdentifier addSelect(final Priority p,
-            final TaskIdentifier prereq, final RelativeTime delay,
-            final Set<SelectableChannel> rs, final Set<SelectableChannel> ws,
-            final Task t) {
+    public static TaskIdentifier addSelect(Priority p,
+                                           TaskIdentifier prereq, RelativeTime 
delay,
+                                           Set<SelectableChannel> rs, 
Set<SelectableChannel> ws,
+                                           Task t) {
         if (rs != null) {
             for (final SelectableChannel s : rs) {
                 try {
@@ -228,28 +214,32 @@
 
         }
 
-        final TimeoutTask tid = new TimeoutTask(t, p, active_task.liveness,
+        return new TimeoutTask(t, p, active_task.liveness,
                 prereq, delay);
 
-        return tid;
-
     }
 
-    public static TaskIdentifier addWrite(RelativeTime timeout,
-            SelectableChannel chan, Task t) {
+    public static TaskIdentifier addRead(RelativeTime timeout,
+                                         SelectableChannel chan, Task t) {
         return Scheduler.addSelect(Priority.KEEP, null, timeout,
                 Collections.singleton(chan), Collections.EMPTY_SET, t);
     }
 
-    public static TaskIdentifier addWithPriority(final Priority prio,
-            final Task t) {
+    public static TaskIdentifier addWrite(RelativeTime timeout,
+                                          SelectableChannel chan, Task t) {
+        return Scheduler.addSelect(Priority.KEEP, null, timeout, 
Collections.EMPTY_SET,
+                Collections.singleton(chan), t);
+    }
+
+    public static TaskIdentifier addWithPriority(Priority prio,
+                                                 Task t) {
         return addSelect(prio, null, RelativeTime.ZERO, null, null, t);
     }
 
     /**
      * Check if the system is still life. Trigger shutdown if we have tasks, 
but
      * none of them give us lifeness.
-     * 
+     *
      * @return true to continue the main loop, false to exit
      */
     private static boolean checkLiveness() {
@@ -257,13 +247,13 @@
             return true;
         }
 
-        for (final TaskIdentifier t : pending) {
+        for (TaskIdentifier t : pending) {
             if (t.liveness) {
                 return true;
             }
         }
 
-        for (final TaskIdentifier t : pending_timeout) {
+        for (TaskIdentifier t : pending_timeout) {
             if (t.liveness) {
                 return true;
             }
@@ -277,13 +267,13 @@
         return false;
     }
 
-    private static void queueReady(final TaskIdentifier tid) {
+    private static void queueReady(TaskIdentifier tid) {
         assert tid.priority != null;
         ready.get(tid.priority.ordinal()).add(tid);
         ready_count++;
     }
 
-    private static void register(final TimeoutTask t) {
+    private static void register(TimeoutTask t) {
         // register with selector
         throw new UnsupportedOperationException();
 
@@ -298,12 +288,11 @@
      * tasks added afterwards will execute normally!). Note that any particular
      * signal will only shut down one scheduler; applications should always 
only
      * create a single scheduler.
-     * 
-     * @param task
-     *            task to run immediately
+     *
+     * @param task task to run immediately
      * @throws IOException
      */
-    public static void run(final Task task) throws IOException {
+    public static void run(Task task) throws IOException {
         current_priority = Priority.DEFAULT;
         current_liveness = true;
 
@@ -319,10 +308,10 @@
                 timeout = RelativeTime.FOREVER;
             }
 
-            final AbsoluteTime now = AbsoluteTime.now();
+            AbsoluteTime now = AbsoluteTime.now();
 
             while (true) {
-                final TimeoutTask t = pending_timeout.peek();
+                TimeoutTask t = pending_timeout.peek();
 
                 if (t == null || t.timeout.compareTo(now) < 0) {
                     break;
@@ -335,9 +324,9 @@
 
             selector.select(timeout.getMilliseconds());
 
-            for (final SelectionKey sk : selector.selectedKeys()) {
+            for (SelectionKey sk : selector.selectedKeys()) {
                 sk.cancel();
-                final TimeoutTask tid = (TimeoutTask) sk.attachment();
+                TimeoutTask tid = (TimeoutTask) sk.attachment();
                 if (!tid.selected) {
                     queueReady(tid);
                 } else {
@@ -362,7 +351,7 @@
 
             // in contrast to the c implementation, p<=0 right here
             for (int p = Priority._COUNT.ordinal(); p <= 0; p--) {
-                final TaskIdentifier tid = ready.get(p).pollFirst();
+                TaskIdentifier tid = ready.get(p).pollFirst();
                 if (tid == null) {
                     break;
                 } else {
@@ -389,20 +378,20 @@
      * function to determine if an elective task should be added or simply
      * dropped (if the decision should be made based on the number of tasks
      * ready to run).
-     * 
+     * <p/>
      * * @param p priority-level to query, use KEEP to query the level of the
      * current task, use COUNT to get the sum over all priority levels
-     * 
+     *
      * @return number of tasks pending right now
      */
-    public int getLoad(final Priority p) {
+    public int getLoad(Priority p) {
         throw new UnsupportedOperationException();
     }
 
     /**
      * Obtain the reason code for why the current task was started. Will return
      * the same value as the GNUNET_SCHEDULER_TaskContext's reason field.
-     * 
+     * <p/>
      * * @return reason(s) why the current task is run
      */
     public EnumSet<Reason> getReason() {

Deleted: gnunet-java/src/org/gnunet/util/TransmitHandler.java
===================================================================
--- gnunet-java/src/org/gnunet/util/TransmitHandler.java        2011-12-20 
17:23:06 UTC (rev 18728)
+++ gnunet-java/src/org/gnunet/util/TransmitHandler.java        2011-12-21 
08:58:15 UTC (rev 18729)
@@ -1,6 +0,0 @@
-package org.gnunet.util;
-
-public interface TransmitHandler {
-    public void handle(Client.Transmitter t);
-
-}

Modified: gnunet-java/src/org/grothoff/Runabout.java
===================================================================
--- gnunet-java/src/org/grothoff/Runabout.java  2011-12-20 17:23:06 UTC (rev 
18728)
+++ gnunet-java/src/org/grothoff/Runabout.java  2011-12-21 08:58:15 UTC (rev 
18729)
@@ -251,8 +251,7 @@
 
     /**
      * Create the code to invoke a visit method.
-     * 
-     * @param cache the cache to use (for dynamic loading)
+     *
      * @param c the type of the argument to the visit method
      */
     private Code makeCode(Class c) {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]