[jboss-svn-commits] JBL Code SVN: r29664 - in labs/jbosstm/workspace/adinn/byteman/trunk: src/org/jboss/byteman/agent and 2 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Oct 19 09:56:36 EDT 2009


Author: adinn
Date: 2009-10-19 09:56:35 -0400 (Mon, 19 Oct 2009)
New Revision: 29664

Modified:
   labs/jbosstm/workspace/adinn/byteman/trunk/bin/submit.sh
   labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/agent/Retransformer.java
   labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/agent/RuleScript.java
   labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/agent/TransformListener.java
   labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/agent/Transformer.java
   labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/agent/submit/Submit.java
   labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/rule/Rule.java
Log:
added listener capability to uninstall rules  using -u flag -- fixes for BYTEMAN-33

Modified: labs/jbosstm/workspace/adinn/byteman/trunk/bin/submit.sh
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/trunk/bin/submit.sh	2009-10-19 13:46:16 UTC (rev 29663)
+++ labs/jbosstm/workspace/adinn/byteman/trunk/bin/submit.sh	2009-10-19 13:56:35 UTC (rev 29664)
@@ -22,8 +22,13 @@
 # @authors Andrew Dinn
 #
 # shell script which submits a request to the Byteman agent listener
+# either to list, install or uninstall rule scripts
 #
-# usage: submit [script1 . . . scriptN]
+# usage: submit [-l|-u] [script1 . . . scriptN]
+#   -l (default) install rules in script1 . . . scriptN
+       with no args list all installed rules
+#   -u uninstall rules in script1 . . . scriptN
+       with no args uninstall all installed rules
 #
 # use the root of the path to this file to locate the byteman jar
 BASE=${0%*bin/submit.sh}
@@ -34,29 +39,7 @@
 # hmm. the asm code should be bundled in the byteman jar?
 CP=${CP}:${BASE}ext/asm-all-3.0.jar
 
-SCRIPT_OPTS=""
-
-if [ $# -gt 0 -a ${1#-*} != ${1} ]; then
-   echo "${1#-*} ${1}"
-   echo "usage: submit [script1 . . . scriptN]"
-   exit
-fi
-
-error=0
-while [ $# -ne 0 ]
-do
-  if [ ! -f $1 -o ! -r $1 ] ; then
-    echo "$1 is not a readable file";
-    error=1
-  fi
-  FILES="${FILES} $1";
-  shift
-done
-
-if [ $error -ne 0 ] ; then
-  exit
-fi
-
 # allow for extra java opts via setting BYTEMAN_JAVA_OPTS
+# Submit class will validate arguments
 
-java ${BYTEMAN_JAVA_OPTS} -classpath ${CP} org.jboss.byteman.agent.submit.Submit $FILES
+java ${BYTEMAN_JAVA_OPTS} -classpath ${CP} org.jboss.byteman.agent.submit.Submit $*

Modified: labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/agent/Retransformer.java
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/agent/Retransformer.java	2009-10-19 13:46:16 UTC (rev 29663)
+++ labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/agent/Retransformer.java	2009-10-19 13:56:35 UTC (rev 29664)
@@ -45,7 +45,7 @@
         addTransformListener();
     }
 
-    protected void installScript(List<String> scriptTexts, List<String> scriptNames) throws Exception
+    protected void installScript(List<String> scriptTexts, List<String> scriptNames, PrintWriter out) throws Exception
     {
         int length = scriptTexts.size();
         List<RuleScript> toBeAdded = new LinkedList<RuleScript>();
@@ -70,15 +70,15 @@
 
             RuleScript previous;
 
-            synchronized (nameToScriptMap) {
-                previous = nameToScriptMap.get(name);
-                if (previous != null) {
-                    System.out.println("redefining rule " + name);
-                    toBeRemoved.add(previous);
-                    previous.setDeleted();
-                }
-                nameToScriptMap.put(name, ruleScript);
+            previous = nameToScriptMap.get(name);
+            if (previous != null) {
+                out.println("redefining rule " + name);
+                toBeRemoved.add(previous);
+                previous.setDeleted();
+            } else {
+                out.println("install rule " + name);
             }
+            nameToScriptMap.put(name, ruleScript);
 
             // remove any old scripts and install the new ones to ensure that
             // automatic loads do the right thing
@@ -112,6 +112,26 @@
         // ok, now that we have updated the maps we need to find all classes which match the scripts and
         // retransform them
 
+        // list all class names for the to be aded and to be removed scripts
+
+        List<String> affectedClassNames = new LinkedList<String>();
+
+        for (RuleScript ruleScript : toBeAdded) {
+            String targetClassName = ruleScript.getTargetClass();
+            if (!affectedClassNames.contains(targetClassName)) {
+                affectedClassNames.add(targetClassName);
+            }
+        }
+
+        for (RuleScript ruleScript : toBeRemoved) {
+            String targetClassName = ruleScript.getTargetClass();
+            if (!affectedClassNames.contains(targetClassName)) {
+                affectedClassNames.add(targetClassName);
+            }
+        }
+
+        // now look for loaded classes whose names are in the list
+
         List<Class<?>> transformed = new LinkedList<Class<?>>();
 
         for (Class clazz : inst.getAllLoadedClasses()) {
@@ -122,9 +142,10 @@
                 continue;
             }
 
-            if (targetToScriptMap.containsKey(name)) {
+            // TODO only retransform classes for which rules have been added or removed
+            if (affectedClassNames.contains(name)) {
                 transformed.add(clazz);
-            } else if (lastDot >= 0 && targetToScriptMap.containsKey(name.substring(lastDot+1))) {
+            } else if (lastDot >= 0 && affectedClassNames.contains(name.substring(lastDot+1))) {
                 transformed.add(clazz);
             }
         }
@@ -135,28 +156,32 @@
             Class<?>[] transformedArray = new Class<?>[transformed.size()];
             inst.retransformClasses(transformed.toArray(transformedArray));
         }
+
+        // now we can safely purge keys for all deleted scripts
+
+        for (RuleScript ruleScript : toBeRemoved) {
+            ruleScript.purge();
+        }
     }
 
 
     protected void listScripts(PrintWriter out)  throws Exception
     {
-        synchronized (nameToScriptMap) {
-            Iterator<RuleScript> iterator = nameToScriptMap.values().iterator();
+        Iterator<RuleScript> iterator = nameToScriptMap.values().iterator();
 
-            if (!iterator.hasNext()) {
-                out.println("no rules installed");
-            } else {
-                while (iterator.hasNext()) {
-                    RuleScript ruleScript = iterator.next();
-                    ruleScript.writeTo(out);
-                    synchronized (ruleScript) {
-                        List<Transform> transformed = ruleScript.getTransformed();
-                        if (transformed != null) {
-                            Iterator<Transform> iter = transformed.iterator();
-                            while (iter.hasNext()) {
-                                Transform transform = iter.next();
-                                transform.writeTo(out);
-                            }
+        if (!iterator.hasNext()) {
+            out.println("no rules installed");
+        } else {
+            while (iterator.hasNext()) {
+                RuleScript ruleScript = iterator.next();
+                ruleScript.writeTo(out);
+                synchronized (ruleScript) {
+                    List<Transform> transformed = ruleScript.getTransformed();
+                    if (transformed != null) {
+                        Iterator<Transform> iter = transformed.iterator();
+                        while (iter.hasNext()) {
+                            Transform transform = iter.next();
+                            transform.writeTo(out);
                         }
                     }
                 }
@@ -168,4 +193,129 @@
     {
         TransformListener.initialize(this);
     }
+
+    public void removeScripts(List<String> scriptTexts, PrintWriter out) throws Exception
+    {
+        List<RuleScript> toBeRemoved = new LinkedList<RuleScript>();
+
+        if (scriptTexts != null) {
+            int length = scriptTexts.size();
+            for (int i = 0; i < length ; i++) {
+                String scriptText = scriptTexts.get(i);
+                String[] lines = scriptText.split("\n");
+                for (int j = 0; j < lines.length; j++) {
+                    String line = lines[j].trim();
+                    if (line.startsWith("RULE ")) {
+                        String name = line.substring(5).trim();
+                        RuleScript ruleScript = nameToScriptMap.get(name);
+                        if (ruleScript ==  null) {
+                            out.print("ERROR failed to find loaded rule with name ");
+                            out.println(name);
+                        } else if (toBeRemoved.contains(ruleScript)) {
+                            out.print("WARNING duplicate occurence for rule name ");
+                            out.println(name);
+                        } else {
+                            toBeRemoved.add(ruleScript);
+                        }
+                    }
+                }
+            }
+        } else {
+            toBeRemoved.addAll(nameToScriptMap.values());
+        }
+
+        if (toBeRemoved.isEmpty()) {
+            out.println("ERROR No rule scripts to remove");
+            return;
+        }
+        
+        for (RuleScript ruleScript : toBeRemoved) {
+            String name = ruleScript.getName();
+            String targetClassName = ruleScript.getTargetClass();
+            String baseName = null;
+            int lastDotIdx = targetClassName.lastIndexOf('.');
+            if (lastDotIdx >= 0) {
+                baseName = targetClassName.substring(lastDotIdx + 1);
+            }
+
+            // update the name to script map to remove the entry for this rule
+
+            nameToScriptMap.remove(name);
+            
+            // invalidate the script first then delete it from the target map
+            // so it is no longer used to do any transformatuion of classes
+
+            ruleScript.setDeleted();
+            
+            synchronized(targetToScriptMap) {
+                List<RuleScript> list = targetToScriptMap.get(targetClassName);
+                if (list != null) {
+                    list.remove(ruleScript);
+                    if (list.isEmpty()) {
+                        targetToScriptMap.remove(targetClassName);
+                    }
+                }
+                if (baseName != null) {
+                    list = targetToScriptMap.get(baseName);
+                    if (list != null) {
+                        list.remove(ruleScript);
+                        if (list.isEmpty()) {
+                            targetToScriptMap.remove(baseName);
+                        }
+                    }
+                }
+            }
+        }
+
+        // ok, now that we have updated the maps we need to find all classes which match the scripts and
+        // retransform them
+
+        // list all class names for the to be removed scripts
+
+        List<String> affectedClassNames = new LinkedList<String>();
+
+        for (RuleScript ruleScript : toBeRemoved) {
+            String targetClassName = ruleScript.getTargetClass();
+            if (!affectedClassNames.contains(targetClassName)) {
+                affectedClassNames.add(targetClassName);
+            }
+        }
+
+        // now look for loaded classes whose names are in the list
+
+        List<Class<?>> transformed = new LinkedList<Class<?>>();
+
+        for (Class clazz : inst.getAllLoadedClasses()) {
+            String name = clazz.getName();
+            int lastDot = name.lastIndexOf('.');
+
+            if (isBytemanClass(name) || !isTransformable(name)) {
+                continue;
+            }
+
+            // retransform if this class has been affected by the delete
+
+            if (affectedClassNames.contains(name)) {
+                transformed.add(clazz);
+            } else if (lastDot >= 0 && affectedClassNames.contains(name.substring(lastDot+1))) {
+                transformed.add(clazz);
+            }
+        }
+
+        // retransform all classes affected by the change
+
+        if (!transformed.isEmpty()) {
+            Class<?>[] transformedArray = new Class<?>[transformed.size()];
+            inst.retransformClasses(transformed.toArray(transformedArray));
+        }
+
+        // now we can safely purge keys for all the deleted scripts -- we need to do this
+        // after the retransform because the latter removes the trigger code which uses
+        // the rule key
+
+        for (RuleScript ruleScript : toBeRemoved) {
+            ruleScript.purge();
+            out.println("uninstall RULE " + ruleScript.getName());
+        }
+    }
 }

Modified: labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/agent/RuleScript.java
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/agent/RuleScript.java	2009-10-19 13:46:16 UTC (rev 29663)
+++ labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/agent/RuleScript.java	2009-10-19 13:56:35 UTC (rev 29664)
@@ -206,16 +206,18 @@
      */
     public synchronized void purge()
     {
-        int count = transformed.size();
-        for (int i =  0; i < count; i++) {
-            Transform transform = transformed.get(i);
-            Rule rule = transform.getRule();
-            if (rule != null) {
-                rule.purge();
+        if (transformed != null) {
+            int count = transformed.size();
+            for (int i =  0; i < count; i++) {
+                Transform transform = transformed.get(i);
+                Rule rule = transform.getRule();
+                if (rule != null) {
+                    rule.purge();
+                }
             }
         }
     }
-
+    
     public String toString()
     {
         StringWriter stringWriter = new StringWriter();

Modified: labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/agent/TransformListener.java
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/agent/TransformListener.java	2009-10-19 13:46:16 UTC (rev 29663)
+++ labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/agent/TransformListener.java	2009-10-19 13:56:35 UTC (rev 29664)
@@ -77,7 +77,7 @@
         return true;
         } finally {
             if (enabled) {
-                Rule.disableTriggers();
+                Rule.enableTriggers();
             }
         }
     }
@@ -144,7 +144,7 @@
             return;
         }
 
-        BufferedReader in = new BufferedReader(new InputStreamReader(is));
+p        BufferedReader in = new BufferedReader(new InputStreamReader(is));
         PrintWriter out = new PrintWriter(new OutputStreamWriter(os));
 
         String line = null;
@@ -162,12 +162,17 @@
                 out.println("OK");
             } else if (line.equals("LOAD")) {
                 loadScripts(in, out);
+            } else if (line.equals("DELETE")) {
+                deleteScripts(in, out);
             } else if (line.equals("LIST")) {
                 listScripts(in, out);
+            } else if (line.equals("DELETEALL")) {
+                purgeScripts(in, out);
             } else {
                 out.println("ERROR");
                 out.println("Unexpected command " + line);
                 out.println("OK");
+                out.flush();
             }
         } catch (Exception e) {
             System.out.println("TransformListener.run : exception " + e + " processing command " + line);
@@ -183,6 +188,16 @@
 
     private void loadScripts(BufferedReader in, PrintWriter out) throws IOException
     {
+        handleScripts(in, out, false);
+    }
+
+    private void deleteScripts(BufferedReader in, PrintWriter out) throws IOException
+    {
+        handleScripts(in, out, true);
+    }
+
+    private void handleScripts(BufferedReader in, PrintWriter out, boolean doDelete) throws IOException
+    {
         List<String> scripts = new LinkedList<String>();
         List<String> scriptNames = new LinkedList<String>();
 
@@ -211,8 +226,9 @@
         }
 
         line = in.readLine();
-        
-        if (!line.equals("ENDLOAD")) {
+
+        if ((doDelete && !line.equals("ENDDELETE")) ||
+                (!doDelete && !line.equals("ENDLOAD"))) {
             out.append("ERROR ");
             out.append("Unexpected end of line reading script " + scriptName + "\n");
             out.println("OK");
@@ -221,7 +237,11 @@
         }
 
         try {
-            retransformer.installScript(scripts, scriptNames);
+            if (doDelete) {
+                retransformer.removeScripts(scripts, out);
+            } else {
+                retransformer.installScript(scripts, scriptNames, out);
+            }
             out.println("OK");
             out.flush();
         } catch (Exception e) {
@@ -234,6 +254,13 @@
         }
     }
 
+    private void purgeScripts(BufferedReader in, PrintWriter out) throws Exception
+    {
+        retransformer.removeScripts(null, out);
+        out.println("OK");
+        out.flush();
+    }
+
     private void listScripts(BufferedReader in, PrintWriter out) throws Exception
     {
         retransformer.listScripts(out);

Modified: labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/agent/Transformer.java
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/agent/Transformer.java	2009-10-19 13:46:16 UTC (rev 29663)
+++ labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/agent/Transformer.java	2009-10-19 13:56:35 UTC (rev 29664)
@@ -165,16 +165,14 @@
     {
         String name = ruleScript.getName();
 
-        synchronized (nameToScriptMap) {
-            RuleScript old = nameToScriptMap.get(name);
-            if (old != null) {
-                throw new Exception("duplicated rule name " + name +
-                        " at ruleScript " + old.getFile() + " line " + old.getLine() +
-                        " and ruleScript "  + ruleScript.getFile() + " line " + ruleScript.getLine());
-            }
+        RuleScript old = nameToScriptMap.get(name);
+        if (old != null) {
+            throw new Exception("duplicated rule name " + name +
+                    " at ruleScript " + old.getFile() + " line " + old.getLine() +
+                    " and ruleScript "  + ruleScript.getFile() + " line " + ruleScript.getLine());
+        }
 
-            nameToScriptMap.put(name, ruleScript);
-        }
+        nameToScriptMap.put(name, ruleScript);
     }
 
     protected void indexScriptByTarget(RuleScript ruleScript)
@@ -581,6 +579,45 @@
     }
 
     /**
+     * disable triggering of rules inside the current thread
+     * @return true if triggering was previously enabled and false if it was already disabled
+     */
+    public static boolean disableTriggers()
+    {
+        Boolean enabled = isEnabled.get();
+        if (enabled == null) {
+            isEnabled.set(Boolean.FALSE);
+            return true;
+        }
+
+        return false;
+    }
+
+    /**
+     * enable triggering of rules inside the current thread
+     * @return true if triggering was previously enabled and false if it was already disabled
+     */
+    public static boolean enableTriggers()
+    {
+        Boolean enabled = isEnabled.get();
+        if (enabled != null) {
+            isEnabled.remove();
+            return false;
+        }
+
+        return true;
+    }
+
+    /**
+     * check if triggering of rules is enabled inside the current thread
+     * @return true if triggering is enabled and false if it is disabled
+     */
+    public static boolean isTriggeringEnabled()
+    {
+        return isEnabled.get() == null;
+    }
+
+    /**
      * test whether a class with a given name is located in the byteman package
      * @param className
      * @return true if a class is located in the byteman package otherwise return false
@@ -786,4 +823,9 @@
             return file.mkdirs();
         }
     }
+    /**
+     * Thread local holding a per thread Boolean which is true if triggering is disabled and false if triggering is
+     * enabled
+     */
+    private static ThreadLocal<Boolean> isEnabled = new ThreadLocal<Boolean>();
 }

Modified: labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/agent/submit/Submit.java
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/agent/submit/Submit.java	2009-10-19 13:46:16 UTC (rev 29663)
+++ labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/agent/submit/Submit.java	2009-10-19 13:56:35 UTC (rev 29664)
@@ -6,8 +6,9 @@
 import java.net.Socket;
 
 /**
- * Provide a main routine for an app which submits a script to a byteman agent for installation in the JVM runtime
- * or, with no arguments, lists all currently installed scripts
+ * Provide a main routine for an app which communicates with the byteman agent at runtime allowing loading,
+ * reloading, unloading of rules and listing of the current rule set and any successful or failed attempts
+ * to inject, parse and typecheck the rules.
  */
 public class Submit
 {
@@ -15,27 +16,44 @@
      * main routine which submits a script to the byteman agent
      * @param args command line arguments specifying the script file(s) to be submitted and, optionally,
      * the byteman agent listener port to use.
-     * Submit [- port] [scriptfile . . .]
+     * Submit [-p port] [-l|-d] [scriptfile . . .]
+     * -p port specifies theport to use
+     * -l implies load/reload all rules found in supplied scripts
+     *    or list all current rules if no scriptfile
+     * -u implies unload all rules found in supplied scripts
+     *    or unload all rules if no scriptfile
      */
     public static void main(String[] args)
     {
         int port = TransformListener.DEFAULT_PORT;
         int startIdx = 0;
         int maxIdx = args.length;
+        boolean deleteRules = false;
 
-        if (maxIdx >= 2 && args[0].equals("-p")) {
-            try {
-                port = Integer.valueOf(args[1]);
-            } catch (NumberFormatException e) {
-                System.out.println("Submit : invalid port " + args[1]);
-                System.exit(1);
+        while (startIdx < maxIdx && args[startIdx].startsWith("-")) {
+            if (maxIdx >= startIdx + 2 && args[startIdx].equals("-p")) {
+                try {
+                    port = Integer.valueOf(args[1]);
+                } catch (NumberFormatException e) {
+                    System.out.println("Submit : invalid port " + args[1]);
+                    System.exit(1);
+                }
+                if (port <= 0) {
+                    System.out.println("Submit : invalid port " + args[1]);
+                    System.exit(1);
+                }
+                startIdx += 2;
+            } else if (args[startIdx].equals("-u")) {
+                deleteRules = true;
+                startIdx++;
+            } else if (args[startIdx].equals("-l")) {
+                deleteRules = false;
+                startIdx++;
+            } else {
+                break;
             }
-            if (port <= 0) {
-                System.out.println("Submit : invalid port " + args[1]);
-                System.exit(1);
-            }
-            startIdx = 2;
         }
+
         if (startIdx < maxIdx && args[startIdx].startsWith("-")) {
             usage(1);
         }
@@ -99,9 +117,12 @@
         char[] readBuffer = new char[READ_BUFFER_LENGTH];
 
         if (startIdx == maxIdx) {
-            // no args means list all current scripts;
-            // !!! TODO -- invoke list command
-            out.println("LIST");
+            // no args means list or delete all current scripts;
+            if (deleteRules) {
+                out.println("DELETEALL");
+            } else {
+                out.println("LIST");
+            }
             out.flush();
             try {
                 String line = in.readLine();
@@ -124,7 +145,11 @@
             }
         } else {
             StringBuffer stringBuffer = new StringBuffer();
-            stringBuffer.append("LOAD\n");
+            if (deleteRules) {
+                stringBuffer.append("DELETE\n");
+            } else {
+                stringBuffer.append("LOAD\n");
+            }
             for (int i = startIdx; i < maxIdx; i++) {
                 String name = args[i];
                 stringBuffer.append("SCRIPT " + name + "\n");
@@ -150,8 +175,11 @@
                     System.exit(1);
                 }
             }
-            stringBuffer.append("ENDLOAD\n");
-
+            if (deleteRules) {
+                stringBuffer.append("ENDDELETE\n");
+            } else {
+                stringBuffer.append("ENDLOAD\n");
+            }
             out.append(stringBuffer);
             out.flush();
 
@@ -178,9 +206,12 @@
 
     public static void usage(int exitCode)
     {
-        System.out.println("usage : Submit [-p port] [scriptfile . . .]");
+        System.out.println("usage : Submit [-p port] [-l|-u] [scriptfile . . .]");
         System.out.println("        -p specifies listener port");
-        System.out.println("        no args means list installed scripts");
+        System.out.println("        -l (default) with scriptfile(s) means load/reload all rules in scriptfile(s)");
+        System.out.println("                     with no scriptfile means list all currently loaded rules");
+        System.out.println("        -u with scriptfile(s) means unload all rules in scriptfile(s)");
+        System.out.println("           with no scriptfile means unload all currently loaded rules");
         System.exit(exitCode);
     }
 }

Modified: labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/rule/Rule.java
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/rule/Rule.java	2009-10-19 13:46:16 UTC (rev 29663)
+++ labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/rule/Rule.java	2009-10-19 13:56:35 UTC (rev 29664)
@@ -340,13 +340,7 @@
      */
     public static boolean disableTriggers()
     {
-        Boolean enabled = isEnabled.get();
-        if (enabled == null) {
-            isEnabled.set(Boolean.FALSE);
-            return true;
-        }
-
-        return false;
+        return Transformer.disableTriggers();
     }
 
     /**
@@ -355,13 +349,7 @@
      */
     public static boolean enableTriggers()
     {
-        Boolean enabled = isEnabled.get();
-        if (enabled != null) {
-            isEnabled.remove();
-            return false;
-        }
-
-        return true;
+        return Transformer.enableTriggers();
     }
 
     /**
@@ -370,7 +358,7 @@
      */
     public static boolean isTriggeringEnabled()
     {
-        return isEnabled.get() == null;
+        return Transformer.isTriggeringEnabled();
     }
 
     /**
@@ -745,10 +733,4 @@
      * flag true if debugging of rule parsing is desired and false if it should not be performed
      */
     private static boolean debugParse = (System.getProperty("org.jboss.byteman.rule.debug") != null ? true : false);
-
-    /**
-     * Thread local holding a per thread Boolean which is true if triggering is disabled and false if triggering is
-     * enabled
-     */
-    private static ThreadLocal<Boolean> isEnabled = new ThreadLocal<Boolean>();
 }



More information about the jboss-svn-commits mailing list