1 4 package com.tc.aspectwerkz.cflow; 5 6 import java.util.Stack ; 7 8 21 public abstract class AbstractCflowSystemAspect { 22 23 public ThreadLocal m_cflowStackLocal = new ThreadLocal () { 26 protected Object initialValue() { 27 return new Stack (); 28 } 29 }; 30 31 34 public void enter() { 35 ((Stack ) m_cflowStackLocal.get()).push(Boolean.TRUE); 36 } 37 38 41 public void exit() { 42 ((Stack ) m_cflowStackLocal.get()).pop(); 43 } 44 45 48 public boolean inCflow() { 49 return ((Stack ) m_cflowStackLocal.get()).size() > 0; 50 } 51 52 59 private static class Cflow_sample extends AbstractCflowSystemAspect { 60 61 private static Cflow_sample INSTANCE = null; 62 63 private Cflow_sample() { 64 super(); 65 } 66 67 70 public static boolean isInCflow() { 71 if (INSTANCE == null) { 72 return false; 73 } 74 return INSTANCE.inCflow(); 75 } 76 77 80 public static Cflow_sample aspectOf() { 81 if (INSTANCE == null) { 82 INSTANCE = new Cflow_sample(); 83 } 84 return INSTANCE; 85 } 86 87 } 88 89 } 90 | Popular Tags |