[jboss-svn-commits] JBL Code SVN: r29149 - labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/agent.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Sep 2 10:32:56 EDT 2009


Author: adinn
Date: 2009-09-02 10:32:56 -0400 (Wed, 02 Sep 2009)
New Revision: 29149

Added:
   labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/agent/RuleScript.java
Removed:
   labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/agent/Script.java
Modified:
   labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/agent/Transformer.java
Log:
changed name of Script to RuleScript

Copied: labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/agent/RuleScript.java (from rev 29148, labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/agent/Script.java)
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/agent/RuleScript.java	                        (rev 0)
+++ labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/agent/RuleScript.java	2009-09-02 14:32:56 UTC (rev 29149)
@@ -0,0 +1,86 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*
+* @authors Andrew Dinn
+*/
+package org.jboss.byteman.agent;
+
+/**
+ * information about a single rule derived from a rule script
+ */
+
+public class RuleScript
+{
+    private String name;
+    private String targetClass;
+    private String targetMethod;
+    private String targetHelper;
+    private Location targetLocation;
+    private String ruleText;
+    int line;
+    String file;
+
+    RuleScript(String name, String targetClass, String targetMethod, String targetHelper, Location targetLocation, String ruleText, int line, String file)
+    {
+        this.name = name;
+        this.targetClass = targetClass;
+        this.targetMethod = targetMethod;
+        this.targetHelper = targetHelper;
+        this.targetLocation = targetLocation;
+        this.ruleText = ruleText;
+        this.line = line;
+        this.file = file;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public String getTargetClass() {
+        return targetClass;
+    }
+
+    public String getTargetHelper() {
+        return targetHelper;
+    }
+
+    public String getTargetMethod() {
+        return targetMethod;
+    }
+
+    public Location getTargetLocation() {
+        return targetLocation;
+    }
+
+    public String getRuleText() {
+        return ruleText;
+    }
+
+    public int getLine()
+    {
+        return line;
+    }
+
+    public String getFile()
+    {
+        return file;
+    }
+}

Deleted: labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/agent/Script.java
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/agent/Script.java	2009-09-02 13:20:48 UTC (rev 29148)
+++ labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/agent/Script.java	2009-09-02 14:32:56 UTC (rev 29149)
@@ -1,86 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*
-* @authors Andrew Dinn
-*/
-package org.jboss.byteman.agent;
-
-/**
- * information about a single rule derived from a rule script
- */
-
-public class Script
-{
-    private String name;
-    private String targetClass;
-    private String targetMethod;
-    private String targetHelper;
-    private Location targetLocation;
-    private String ruleText;
-    int line;
-    String file;
-
-    Script (String name, String targetClass, String targetMethod, String targetHelper, Location targetLocation, String ruleText, int line, String file)
-    {
-        this.name = name;
-        this.targetClass = targetClass;
-        this.targetMethod = targetMethod;
-        this.targetHelper = targetHelper;
-        this.targetLocation = targetLocation;
-        this.ruleText = ruleText;
-        this.line = line;
-        this.file = file;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public String getTargetClass() {
-        return targetClass;
-    }
-
-    public String getTargetHelper() {
-        return targetHelper;
-    }
-
-    public String getTargetMethod() {
-        return targetMethod;
-    }
-
-    public Location getTargetLocation() {
-        return targetLocation;
-    }
-
-    public String getRuleText() {
-        return ruleText;
-    }
-
-    public int getLine()
-    {
-        return line;
-    }
-
-    public String getFile()
-    {
-        return file;
-    }
-}

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-09-02 13:20:48 UTC (rev 29148)
+++ labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/agent/Transformer.java	2009-09-02 14:32:56 UTC (rev 29149)
@@ -66,7 +66,7 @@
     {
         theTransformer = this;
         this.inst = inst;
-        targetToScriptMap = new HashMap<String, List<Script>>();
+        targetToScriptMap = new HashMap<String, List<RuleScript>>();
 
         Iterator<String> iter = scriptTexts.iterator();
         int scriptIdx = 0;
@@ -125,29 +125,29 @@
                         } else if (targetMethod == null) {
                             throw new Exception("org.jboss.byteman.agent.Transformer : no METHOD for RULE  " + name + " in script " + scriptPaths.get(scriptIdx));
                         } else {
-                            List<Script> scripts = targetToScriptMap.get(targetClass);
-                            if (scripts == null) {
-                                scripts = new ArrayList<Script>();
-                                targetToScriptMap.put(targetClass, scripts);
+                            List<RuleScript> ruleScripts = targetToScriptMap.get(targetClass);
+                            if (ruleScripts == null) {
+                                ruleScripts = new ArrayList<RuleScript>();
+                                targetToScriptMap.put(targetClass, ruleScripts);
                             }
                             if (targetLocation == null) {
                                 targetLocation = Location.create(LocationType.ENTRY, "");
                             }
-                            Script script = new Script(name, targetClass, targetMethod, targetHelper, targetLocation, nextRule, startNumber, file);
-                            scripts.add(script);
+                            RuleScript ruleScript = new RuleScript(name, targetClass, targetMethod, targetHelper, targetLocation, nextRule, startNumber, file);
+                            ruleScripts.add(ruleScript);
                             if (isVerbose()) {
-                                System.out.println("RULE " + script.getName());
-                                System.out.println("CLASS " + script.getTargetClass());
-                                System.out.println("METHOD " + script.getTargetMethod());
-                                if (script.getTargetHelper() != null) {
-                                    System.out.println("HELPER " + script.getTargetHelper());
+                                System.out.println("RULE " + ruleScript.getName());
+                                System.out.println("CLASS " + ruleScript.getTargetClass());
+                                System.out.println("METHOD " + ruleScript.getTargetMethod());
+                                if (ruleScript.getTargetHelper() != null) {
+                                    System.out.println("HELPER " + ruleScript.getTargetHelper());
                                 }
                                 if (targetLocation != null) {
                                     System.out.println(targetLocation);
                                 } else {
                                     System.out.println("AT ENTRY");
                                 }
-                                System.out.println(script.getRuleText());
+                                System.out.println(ruleScript.getRuleText());
                                 System.out.println("ENDRULE");
                             }
                         }
@@ -247,12 +247,12 @@
         // ok, we need to check whether there are any scripts associated with this class and if so
         // we will consider transforming the byte code
 
-        List<Script> scripts = targetToScriptMap.get(internalClassName);
+        List<RuleScript> ruleScripts = targetToScriptMap.get(internalClassName);
 
-        if (scripts != null) {
-            for (Script script : scripts) {
+        if (ruleScripts != null) {
+            for (RuleScript ruleScript : ruleScripts) {
                 try {
-                    newBuffer = transform(script, loader, internalClassName,  classBeingRedefined, newBuffer);
+                    newBuffer = transform(ruleScript, loader, internalClassName,  classBeingRedefined, newBuffer);
                 } catch (Throwable th) {
                     System.err.println("Transformer.transform : caught throwable " + th);
                     th.printStackTrace(System.err);
@@ -260,18 +260,18 @@
             }
         }
 
-        // if the class is not in the default package then we also need to look for scripts
+        // if the class is not in the default package then we also need to look for ruleScripts
         // which specify the class without the package qualification
 
         int dotIdx = internalClassName.lastIndexOf('.');
 
         if (dotIdx >= 0) {
-            scripts = targetToScriptMap.get(internalClassName.substring(dotIdx + 1));
+            ruleScripts = targetToScriptMap.get(internalClassName.substring(dotIdx + 1));
 
-            if (scripts != null) {
-                for (Script script : scripts) {
+            if (ruleScripts != null) {
+                for (RuleScript ruleScript : ruleScripts) {
                     try {
-                        newBuffer = transform(script, loader, internalClassName,  classBeingRedefined, newBuffer);
+                        newBuffer = transform(ruleScript, loader, internalClassName,  classBeingRedefined, newBuffer);
                     } catch (Throwable th) {
                         System.err.println("Transformer.transform : caught throwable " + th);
                         th.printStackTrace(System.err);
@@ -359,20 +359,20 @@
      */
     public static final String DUMP_GENERATED_CLASSES_DIR = BYTEMAN_PACKAGE_PREFIX + "dump.generated.classes.directory";
 
-    private byte[] transform(Script script, ClassLoader loader, String className, Class classBeingRedefined, byte[] targetClassBytes)
+    private byte[] transform(RuleScript ruleScript, ClassLoader loader, String className, Class classBeingRedefined, byte[] targetClassBytes)
     {
-        final String handlerClass = script.getTargetClass();
-        final String handlerMethod = script.getTargetMethod();
-        final String helperName = script.getTargetHelper();
-        final Location handlerLocation = script.getTargetLocation();
-        final int lineNumber = script.getLine();
-        final String file = script.getFile();
+        final String handlerClass = ruleScript.getTargetClass();
+        final String handlerMethod = ruleScript.getTargetMethod();
+        final String helperName = ruleScript.getTargetHelper();
+        final Location handlerLocation = ruleScript.getTargetLocation();
+        final int lineNumber = ruleScript.getLine();
+        final String file = ruleScript.getFile();
         Class helperClass = null;
         if (helperName != null) {
             try {
                 helperClass = loader.loadClass(helperName);
             } catch (ClassNotFoundException e) {
-                System.out.println("org.jboss.byteman.agent.Transformer : unknown helper class " + helperName + " for rule " + script.getName());
+                System.out.println("org.jboss.byteman.agent.Transformer : unknown helper class " + helperName + " for rule " + ruleScript.getName());
             }
         }
         if (isVerbose()) {
@@ -382,9 +382,9 @@
             System.out.println("  " + handlerLocation);
         }
         final Rule rule;
-        String ruleName = script.getName();
+        String ruleName = ruleScript.getName();
         try {
-            rule = Rule.create(ruleName, handlerClass, handlerMethod, helperClass, handlerLocation, script.getRuleText(), lineNumber, file, loader);
+            rule = Rule.create(ruleName, handlerClass, handlerMethod, helperClass, handlerLocation, ruleScript.getRuleText(), lineNumber, file, loader);
         } catch (ParseException pe) {
             System.out.println("org.jboss.byteman.agent.Transformer : error parsing rule " + ruleName + " : " + pe);
             return targetClassBytes;
@@ -521,7 +521,7 @@
      * rule details
      */
 
-    private final HashMap<String, List<Script>> targetToScriptMap;
+    private final HashMap<String, List<RuleScript>> targetToScriptMap;
 
     /**
      *  switch to control verbose output during rule processing



More information about the jboss-svn-commits mailing list