1 8 package org.codehaus.aspectwerkz.cflow; 9 10 import java.util.Stack ; 11 12 25 public abstract class AbstractCflowSystemAspect { 26 27 public ThreadLocal m_cflowStackLocal = new ThreadLocal () { 30 protected Object initialValue() { 31 return new Stack (); 32 } 33 }; 34 35 38 public void enter() { 39 ((Stack )m_cflowStackLocal.get()).push(Boolean.TRUE); 40 } 41 42 45 public void exit() { 46 ((Stack )m_cflowStackLocal.get()).pop(); 47 } 48 49 52 public boolean inCflow() { 53 return ((Stack )m_cflowStackLocal.get()).size() > 0; 54 } 55 56 63 private static class Cflow_sample extends AbstractCflowSystemAspect { 64 65 private static Cflow_sample INSTANCE = null; 66 67 private Cflow_sample() { 68 super(); 69 } 70 71 74 public static boolean isInCflow() { 75 if (INSTANCE == null) { 76 return false; 77 } 78 return INSTANCE.inCflow(); 79 } 80 81 84 public static Cflow_sample aspectOf() { 85 if (INSTANCE == null) { 86 INSTANCE = new Cflow_sample(); 87 } 88 return INSTANCE; 89 } 90 91 } 92 93 } 94 | Popular Tags |