c$ = Clazz.declareType (null, "HelloJ2SNative");c$.sayHello = Clazz.defineMethod (c$, "sayHello",function () {System.out.println ("Hello, Java");});c$.sayHei = Clazz.defineMethod (c$, "sayHei",function (name) {if (name != null) {System.out.println ("Hei, " + name + ", how are you?");} else {System.out.println ("Hei, how are you?");}}, "~S");c$.saySomething = Clazz.defineMethod (c$, "saySomething",function () {{}});c$.main = Clazz.defineMethod (c$, "main",function (args) {HelloJ2SNative.sayHi ();HelloJ2SNative.sayHello ();HelloJ2SNative.sayHei ("Josson");HelloJ2SNative.saySomething ();}, "~A");
@J2SIgnore
private static BlockingQueue<SimplePipeRunnable> toBeDestroyedPipes = new LinkedBlockingQueue<SimplePipeRunnable>();
@J2SIgnore
private SimplePipeHelper() {
//
}
/*
* Browser mode
*/
@J2SNative({
"if (key == null || pipe == null) return;",
"if (net.sf.j2s.ajax.SimplePipeHelper.pipes == null) {",
" net.sf.j2s.ajax.SimplePipeHelper.pipes = new Object ();",
"}",
"net.sf.j2s.ajax.SimplePipeHelper.pipes[key] = pipe;"
})
public static void registerPipe(String key, SimplePipeRunnable pipe) {
if (key == null || pipe == null) return;
if (pipes == null) {
pipes = Collections.synchronizedMap(new HashMap<String, SimplePipeRunnable>(50));
}
pipes.put(key, pipe);
}
/*
* Server side
*/
@J2SIgnore
synchronized static String registerPipe(SimplePipeRunnable pipe) {
if (pipe.pipeKey != null) {
System.out.println("ERROR!!! pipeKey should be null here! " + pipe.pipeKey);
}
// if (pipe == null) return null; // should never register null pipe!
if (pipes == null) {
pipes = Collections.synchronizedMap(new HashMap<String, SimplePipeRunnable>(50));
}
String key = nextPipeKey();
while (pipes.get(key) != null) {
key = nextPipeKey();;
}
pipes.put(key, pipe);
if (pipeMap == null) {
pipeMap = Collections.synchronizedMap(new HashMap<String, List<SimpleSerializable>>());
}
List<SimpleSerializable> list = pipeMap.get(key);
if (list == null) {
list = new Vector<SimpleSerializable>();
pipeMap.put(key, list);
}
return key;
}
--
You received this message because you are subscribed to the Google Groups "Java2Script" group.
To view this discussion on the web visit https://groups.google.com/d/msg/java2script/-/n_4p8N8pR70J.
To post to this group, send email to java2...@googlegroups.com.
To unsubscribe from this group, send email to java2script...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/java2script?hl=en.