Added:
trunk/connector-mxj/lib/
trunk/connector-mxj/lib/aspectjrt.jar
trunk/connector-mxj/lib/aspectjtools.jar
trunk/connector-mxj/src/com/mysql/management/trace/
trunk/connector-mxj/src/com/mysql/management/trace/Tracer.aj
Modified:
trunk/connector-mxj/build.xml
trunk/connector-mxj/src/com/mysql/management/HelpOptionsParser.java
trunk/connector-mxj/src/com/mysql/management/jmx/MysqldDynamicMBeanTestAgent.java
trunk/connector-mxj/src/com/mysql/management/util/Files.java
Log:
Added Aspect/J Logging with com.mysql.management.trace.Tracer (Class see Tracer.aj)
Modified: trunk/connector-mxj/build.xml
===================================================================
--- trunk/connector-mxj/build.xml 2006-05-08 19:09:31 UTC (rev 45)
+++ trunk/connector-mxj/build.xml 2006-05-12 00:21:19 UTC (rev 46)
@@ -51,6 +51,9 @@
<path id="project.build.classpath">
+ <fileset dir="lib">
+ <include name="**/*.jar" />
+ </fileset>
<fileset dir="lib-nodist">
<include name="**/*.jar" />
</fileset>
@@ -171,6 +174,25 @@
</javac>
<antcall target="-compile-tests" />
<antcall target="-skip-compile-tests" />
+
+ <!-- <taskdef resource="org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties"/> -->
+ <taskdef resource="org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties">
+ <classpath>
+ <pathelement location="lib/aspectjtools.jar"/>
+ <pathelement location="lib/aspectjrt.jar"/>
+ </classpath>
+ </taskdef>
+
+ <iajc destDir="${build}">
+ <sourceroots>
+ <pathelement location="${src}"/>
+ </sourceroots>
+ <classpath refid="project.build.classpath"/>
+ <classpath>
+ <pathelement location="lib/aspectjtools.jar"/>
+ </classpath>
+ </iajc>
+
<mkdir dir="${stage-cmxj}" />
<jar destfile="${stage-cmxj}/connector-mxj.jar">
<fileset dir="${build}" />
@@ -206,7 +228,7 @@
<classpath refid="project.build.classpath" />
</javac>
</target>
-
+
<target name="-makePackages">
<delete file="${dist}/${fullProdName}.tar.gz" />
@@ -264,9 +286,12 @@
<copy file="index.jsp" todir="${stage-cmxj}" />
<copy file="README.1st" todir="${stage-cmxj}" />
<copy file="CHANGES" todir="${stage-cmxj}" />
+ <mkdir dir="${stage-cmxj}/lib" />
+ <copy todir="${stage-cmxj}/lib">
+ <fileset dir="lib" />
+ </copy>
</target>
-
<target name="-stage-commercial-common">
<antcall target="-stage-common" />
<copy file="${misc}/MySQLEULA.txt" tofile="${stage-cmxj}/MySQLEULA.txt" />
@@ -293,7 +318,7 @@
<antcall target="-compile" />
</target>
-
+
<target name="styleDocs" depends="-doc-init, -copyDocs, -styleDocsHtmlTop, -styleDocsFopTop" if="${com.mysql.jdbc.docs.sourcesPresent}" />
Added: trunk/connector-mxj/lib/aspectjrt.jar
===================================================================
(Binary files differ)
Property changes on: trunk/connector-mxj/lib/aspectjrt.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/connector-mxj/lib/aspectjtools.jar
===================================================================
(Binary files differ)
Property changes on: trunk/connector-mxj/lib/aspectjtools.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/connector-mxj/src/com/mysql/management/HelpOptionsParser.java
===================================================================
--- trunk/connector-mxj/src/com/mysql/management/HelpOptionsParser.java 2006-05-08 19:09:31 UTC (rev 45)
+++ trunk/connector-mxj/src/com/mysql/management/HelpOptionsParser.java 2006-05-12 00:21:19 UTC (rev 46)
@@ -105,6 +105,9 @@
printMsg(err, "Start Position:" + start);
printMsg(err, "End Text=\"" + END_TEXT + "\"");
printMsg(err, "found at: " + stop);
+ printMsg(err, "HELP TEXT BEGIN");
+ printMsg(err, help);
+ printMsg(err, "HELP TEXT END");
}
throw new RuntimeException("could not parse help text");
}
Modified: trunk/connector-mxj/src/com/mysql/management/jmx/MysqldDynamicMBeanTestAgent.java
===================================================================
--- trunk/connector-mxj/src/com/mysql/management/jmx/MysqldDynamicMBeanTestAgent.java 2006-05-08 19:09:31 UTC (rev 45)
+++ trunk/connector-mxj/src/com/mysql/management/jmx/MysqldDynamicMBeanTestAgent.java 2006-05-12 00:21:19 UTC (rev 46)
@@ -18,13 +18,9 @@
package com.mysql.management.jmx;
import javax.management.DynamicMBean;
-import javax.management.InstanceAlreadyExistsException;
import javax.management.JMException;
-import javax.management.MBeanRegistrationException;
import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
-import javax.management.MalformedObjectNameException;
-import javax.management.NotCompliantMBeanException;
import javax.management.ObjectName;
/**
@@ -53,10 +49,6 @@
* @param domain
* @param name
* @param bean
- * @throws MalformedObjectNameException
- * @throws InstanceAlreadyExistsException
- * @throws MBeanRegistrationException
- * @throws NotCompliantMBeanException
*/
public void addBean(String domain, String name, DynamicMBean bean)
throws JMException {
Added: trunk/connector-mxj/src/com/mysql/management/trace/Tracer.aj
===================================================================
--- trunk/connector-mxj/src/com/mysql/management/trace/Tracer.aj 2006-05-08 19:09:31 UTC (rev 45)
+++ trunk/connector-mxj/src/com/mysql/management/trace/Tracer.aj 2006-05-12 00:21:19 UTC (rev 46)
@@ -0,0 +1,203 @@
+/*
+ Copyright (C) 2005 MySQL AB
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License as
+ published by the Free Software Foundation.
+
+ There are special exceptions to the terms and conditions of the GPL
+ as it is applied to this software. View the full text of the
+ exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
+ software distribution.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+package com.mysql.management.trace;
+
+import java.io.PrintStream;
+import java.sql.SQLException;
+
+import com.mysql.jdbc.log.LogUtils;
+
+import org.aspectj.lang.JoinPoint;
+
+public aspect Tracer {
+
+ public static final String TRACE_PROPERTY = "c-mxj_trace";
+
+ private static boolean skipLogging = !Boolean.valueOf(System.getProperty(
+ TRACE_PROPERTY, Boolean.FALSE.toString())).booleanValue();
+
+ private static PrintStream logErr = System.err;
+
+ private static void setErrStream(PrintStream printStream) {
+ logErr = printStream;
+ }
+
+ public static void setLogging(boolean b) {
+ skipLogging = !b;
+ }
+
+ // ---------------------------------------------------------------------
+
+ pointcut constructors(): execution(* *(..))
+ && within(com.mysql.management.* )
+ && within(!com.mysql.management.trace.*);
+
+ pointcut methods(): execution(* *(..)) && within(com.mysql.management.* )
+ && within(!com.mysql.management.trace.*);
+
+ before(): constructors() && methods() {
+ entry(thisJoinPoint, false);
+ }
+
+ after() returning (Object o): constructors() && methods() {
+ exit(thisJoinPoint, false, o);
+ }
+
+ private ThreadLocal callDepth = new ThreadLocal() {
+ protected Object initialValue() {
+ return new Integer(0);
+ }
+ };
+
+ private int getCallDepth() {
+ return ((Integer)(callDepth.get())).intValue();
+ }
+
+ private void setCallDepth(int n) {
+ callDepth.set(new Integer(n));
+ }
+
+ private void entry(JoinPoint jp, boolean isConstructor) {
+ setCallDepth(getCallDepth() + 1);
+ printEntering(jp, isConstructor);
+ }
+
+ private void exit(JoinPoint jp, boolean isConstructor,
+ Object returnValue) {
+ printExiting(jp, isConstructor, returnValue);
+ setCallDepth(getCallDepth() - 1);
+ }
+
+ private void printEntering (JoinPoint jp, boolean isConstructor) {
+ if( skipLogging ){
+ return;
+ }
+ StringBuffer buf = new StringBuffer(80);
+ printCalledFromIfNotMySQL(buf);
+ printIndent(buf);
+ buf.append("--> ");
+
+ buf.append(jp.getSourceLocation().getFileName());
+ buf.append(":");
+ buf.append(jp.getSourceLocation().getLine());
+ buf.append(" ");
+ buf.append(jp.getSignature().getDeclaringTypeName());
+ buf.append(".");
+ buf.append(jp.getSignature().getName());
+ printParameters(jp, buf);
+
+ logErr.println(buf.toString());
+ }
+
+ private void printExiting (JoinPoint jp, boolean isConstructor,
+ Object returnValue) {
+ if( skipLogging ){
+ return;
+ }
+ StringBuffer buf = new StringBuffer(80);
+ printIndent(buf);
+
+ buf.append("<-- ");
+ buf.append(jp.getSourceLocation().getFileName());
+ buf.append(":");
+ buf.append(jp.getSourceLocation().getLine());
+ buf.append(" ");
+ buf.append(jp.getSignature().getDeclaringTypeName());
+ buf.append(".");
+ buf.append(jp.getSignature().getName());
+ buf.append("(..) returning ");
+
+ boolean isString = returnValue instanceof String;
+
+ if (isString) {
+ buf.append("\"");
+ }
+
+ buf.append(returnValue);
+
+ if (isString) {
+ buf.append("\"");
+ }
+
+ logErr.println(buf.toString());
+ }
+
+
+
+ private void printIndent(StringBuffer buf) {
+ buf.append("[mxj-trace]");
+ for (int i = 0; i < getCallDepth(); i++) {
+ buf.append(" ");
+ }
+ }
+
+ private void printCalledFromIfNotMySQL(StringBuffer buf) {
+ String callingClassAndMethod =
+ LogUtils.findCallingClassAndMethod(new Throwable());
+
+ if (callingClassAndMethod.startsWith("com.mysql.managment")) {
+ return;
+ }
+ if (callingClassAndMethod
+ .indexOf("Caller information not available") >= 0) {
+ return;
+ }
+
+ printIndent(buf);
+ buf.append("Caller ");
+ buf.append(callingClassAndMethod);
+ buf.append(System.getProperty("line.separator"));
+ }
+
+ private void printParameters(JoinPoint jp, StringBuffer buf) {
+ Object[] params = jp.getArgs();
+
+ buf.append("(");
+
+ for (int i = 0; i < params.length; i++) {
+ boolean isString = params[i] instanceof String;
+
+ if (isString) {
+ buf.append("\"");
+ }
+
+ if (params[i] != null) {
+ buf.append(params[i]);
+ } else {
+ buf.append("null");
+ }
+
+ if (isString) {
+ buf.append("\"");
+ }
+
+ if (i < params.length - 1) {
+ buf.append(", ");
+ }
+ }
+
+ buf.append(")");
+ }
+
+}
+
Modified: trunk/connector-mxj/src/com/mysql/management/util/Files.java
===================================================================
--- trunk/connector-mxj/src/com/mysql/management/util/Files.java 2006-05-08 19:09:31 UTC (rev 45)
+++ trunk/connector-mxj/src/com/mysql/management/util/Files.java 2006-05-12 00:21:19 UTC (rev 46)
@@ -30,7 +30,7 @@
public static final String JAVA_IO_TMPDIR = "java.io.tmpdir";
- public static final String USE_TEST_DIR = "cmxj.files.use-test-dir";
+ public static final String USE_TEST_DIR = "c-mxj.files.use-test-dir";
private Shell.Factory shellFactory;
| Thread |
|---|
| • Connector/MXJ commit: r46 - in trunk/connector-mxj: . lib src/com/mysql/management src/com/mysql/management/jmx src/com/mysql/management/trace src/com... | eherman | 12 May |