|
11 | 11 | package net.sf.j2s.ajax; |
12 | 12 |
|
13 | 13 | import java.lang.reflect.Method; |
| 14 | +import java.util.HashSet; |
14 | 15 | import java.util.Iterator; |
15 | 16 | import java.util.List; |
| 17 | +import java.util.Set; |
16 | 18 | import java.util.Vector; |
17 | 19 |
|
18 | 20 | import net.sf.j2s.ajax.SimpleRPCRunnable; |
@@ -75,6 +77,12 @@ public abstract class SimplePipeRunnable extends SimpleRPCRunnable { |
75 | 77 | @J2SIgnore |
76 | 78 | int pipeMode; |
77 | 79 |
|
| 80 | + @J2SIgnore |
| 81 | + Object dealMutex; |
| 82 | + |
| 83 | + @J2SIgnore |
| 84 | + Set<String> nonExistedDeals; |
| 85 | + |
78 | 86 | @J2SIgnore |
79 | 87 | public int getPipeMode() { |
80 | 88 | return pipeMode; |
@@ -131,6 +139,16 @@ public void setSequence(long sequence) { |
131 | 139 | pipeSequence = sequence; |
132 | 140 | } |
133 | 141 |
|
| 142 | + @J2SIgnore |
| 143 | + public boolean isMonitoringEvents() { |
| 144 | + return false; |
| 145 | + } |
| 146 | + |
| 147 | + @J2SIgnore |
| 148 | + public void pipeDataOK(SimpleSerializable ... evts) { |
| 149 | + |
| 150 | + } |
| 151 | + |
134 | 152 | @J2SIgnore |
135 | 153 | public void setPipeHelper(SimplePipeHelper.IPipeThrough helper) { |
136 | 154 | pipeManaged = true; |
@@ -444,16 +462,31 @@ public boolean deal(SimpleSerializable ss) { |
444 | 462 | Class<?> clzz = getClass(); |
445 | 463 | if (clzz != null) { |
446 | 464 | do { |
447 | | - try { |
448 | | - method = clzz.getMethod("deal", clazz); |
449 | | - } catch (Exception e) { |
450 | | - } |
451 | | - if (method != null) { |
452 | | - Class<?> returnType = method.getReturnType(); |
453 | | - if (returnType == boolean.class) { |
454 | | - method.setAccessible(true); |
455 | | - Object result = method.invoke(this, ss); |
456 | | - return ((Boolean) result).booleanValue(); |
| 465 | + if (nonExistedDeals == null || !nonExistedDeals.contains(clazz.getName())) { |
| 466 | + try { |
| 467 | + method = clzz.getMethod("deal", clazz); |
| 468 | + } catch (Exception e) { |
| 469 | + if (dealMutex == null) { |
| 470 | + synchronized (this) { |
| 471 | + if (dealMutex == null) { |
| 472 | + dealMutex = new Object(); |
| 473 | + } |
| 474 | + } |
| 475 | + } |
| 476 | + synchronized (dealMutex) { |
| 477 | + if (nonExistedDeals == null) { |
| 478 | + nonExistedDeals = new HashSet<String>(); |
| 479 | + } |
| 480 | + nonExistedDeals.add(clazz.getName()); |
| 481 | + } |
| 482 | + } |
| 483 | + if (method != null) { |
| 484 | + Class<?> returnType = method.getReturnType(); |
| 485 | + if (returnType == boolean.class) { |
| 486 | + method.setAccessible(true); |
| 487 | + Object result = method.invoke(this, ss); |
| 488 | + return ((Boolean) result).booleanValue(); |
| 489 | + } |
457 | 490 | } |
458 | 491 | } |
459 | 492 | clazz = clazz.getSuperclass(); |
|
0 commit comments