Author: shawkins
Date: 2010-04-21 11:51:54 -0400 (Wed, 21 Apr 2010)
New Revision: 2066
Added:
trunk/engine/src/main/java/com/metamatrix/common/log/JavaLogWriter.java
trunk/engine/src/main/java/com/metamatrix/common/log/LogListener.java
trunk/engine/src/main/java/com/metamatrix/common/log/LogMessage.java
trunk/engine/src/main/java/com/metamatrix/common/log/MessageLevel.java
trunk/runtime/src/main/java/org/teiid/logging/Log4jListener.java
Removed:
trunk/common-core/src/main/java/com/metamatrix/core/log/
trunk/common-core/src/test/java/com/metamatrix/core/log/
trunk/engine/src/main/java/com/metamatrix/common/log/LogConfiguration.java
trunk/engine/src/main/java/com/metamatrix/common/log/LogConfigurationImpl.java
trunk/runtime/src/main/java/org/teiid/logging/Log4JUtil.java
trunk/runtime/src/main/java/org/teiid/logging/LogConfigurationProvider.java
trunk/runtime/src/main/java/org/teiid/logging/LogListernerProvider.java
Modified:
trunk/connector-api/src/main/java/org/teiid/connector/basic/DefaultConnectorLogger.java
trunk/engine/src/main/java/com/metamatrix/common/buffer/TupleBuffer.java
trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/FileStorageManager.java
trunk/engine/src/main/java/com/metamatrix/common/log/LogConstants.java
trunk/engine/src/main/java/com/metamatrix/common/log/LogManager.java
trunk/engine/src/main/java/com/metamatrix/query/analysis/AnalysisRecord.java
trunk/engine/src/main/java/com/metamatrix/query/processor/QueryProcessor.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/RelationalNode.java
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SortUtility.java
trunk/engine/src/main/java/com/metamatrix/query/processor/xml/SAXDocumentInProgress.java
trunk/engine/src/main/java/com/metamatrix/query/processor/xml/XMLProcessorEnvironment.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/AuthorizationValidationVisitor.java
trunk/engine/src/test/java/com/metamatrix/common/log/TestLogManager.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
trunk/runtime/src/main/java/org/teiid/logging/CommonsLogManagerAdapter.java
trunk/runtime/src/main/java/org/teiid/transport/SocketClientInstance.java
trunk/runtime/src/main/java/org/teiid/transport/SocketListener.java
Log:
TEIID-1012 combining the log configuration and listener interfaces
Modified:
trunk/connector-api/src/main/java/org/teiid/connector/basic/DefaultConnectorLogger.java
===================================================================
---
trunk/connector-api/src/main/java/org/teiid/connector/basic/DefaultConnectorLogger.java 2010-04-21
00:35:51 UTC (rev 2065)
+++
trunk/connector-api/src/main/java/org/teiid/connector/basic/DefaultConnectorLogger.java 2010-04-21
15:51:54 UTC (rev 2066)
@@ -32,7 +32,6 @@
* DefaultConnectorLogger.
*/
public class DefaultConnectorLogger implements ConnectorLogger {
- public static final String CTX_CONNECTOR = "CONNECTOR"; //$NON-NLS-1$
@Override
public void logError(String message) {
//LogManager.logError(CTX_CONNECTOR, message);
Modified: trunk/engine/src/main/java/com/metamatrix/common/buffer/TupleBuffer.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/buffer/TupleBuffer.java 2010-04-21
00:35:51 UTC (rev 2065)
+++ trunk/engine/src/main/java/com/metamatrix/common/buffer/TupleBuffer.java 2010-04-21
15:51:54 UTC (rev 2066)
@@ -34,9 +34,9 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.log.LogConstants;
import com.metamatrix.common.log.LogManager;
+import com.metamatrix.common.log.MessageLevel;
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.common.types.Streamable;
-import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.core.util.Assertion;
import com.metamatrix.dqp.DQPPlugin;
import com.metamatrix.query.sql.symbol.Expression;
Modified:
trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/FileStorageManager.java
===================================================================
---
trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/FileStorageManager.java 2010-04-21
00:35:51 UTC (rev 2065)
+++
trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/FileStorageManager.java 2010-04-21
15:51:54 UTC (rev 2066)
@@ -35,7 +35,7 @@
import com.metamatrix.common.buffer.FileStore;
import com.metamatrix.common.buffer.StorageManager;
import com.metamatrix.common.log.LogManager;
-import com.metamatrix.core.log.MessageLevel;
+import com.metamatrix.common.log.MessageLevel;
import com.metamatrix.core.util.Assertion;
import com.metamatrix.query.execution.QueryExecPlugin;
Copied: trunk/engine/src/main/java/com/metamatrix/common/log/JavaLogWriter.java (from rev
2065, trunk/common-core/src/main/java/com/metamatrix/core/log/JavaLogWriter.java)
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/log/JavaLogWriter.java
(rev 0)
+++ trunk/engine/src/main/java/com/metamatrix/common/log/JavaLogWriter.java 2010-04-21
15:51:54 UTC (rev 2066)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library 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 library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.common.log;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Write to Java logging
+ */
+public class JavaLogWriter implements LogListener {
+
+ @Override
+ public boolean isEnabled(String context, int msgLevel) {
+ Logger logger = Logger.getLogger(context);
+
+ Level javaLevel = convertLevel(msgLevel);
+ return logger.isLoggable(javaLevel);
+ }
+
+ public void log(int level, String context, Object msg) {
+ Logger logger = Logger.getLogger(context);
+
+ Level javaLevel = convertLevel(level);
+ logger.log(javaLevel, msg.toString());
+ }
+
+ public void log(int level, String context, Throwable t, Object msg) {
+ Logger logger = Logger.getLogger(context);
+
+ Level javaLevel = convertLevel(level);
+ logger.log(javaLevel, msg.toString(), t);
+ }
+
+ public Level convertLevel(int level) {
+ switch (level) {
+ case MessageLevel.CRITICAL:
+ case MessageLevel.ERROR:
+ return Level.SEVERE;
+ case MessageLevel.WARNING:
+ return Level.WARNING;
+ case MessageLevel.INFO:
+ return Level.FINE;
+ case MessageLevel.DETAIL:
+ return Level.FINER;
+ case MessageLevel.TRACE:
+ return Level.FINEST;
+ }
+ return Level.ALL;
+ }
+
+ public void shutdown() {
+ }
+
+}
Property changes on:
trunk/engine/src/main/java/com/metamatrix/common/log/JavaLogWriter.java
___________________________________________________________________
Name: svn:mergeinfo
+
Deleted: trunk/engine/src/main/java/com/metamatrix/common/log/LogConfiguration.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/log/LogConfiguration.java 2010-04-21
00:35:51 UTC (rev 2065)
+++ trunk/engine/src/main/java/com/metamatrix/common/log/LogConfiguration.java 2010-04-21
15:51:54 UTC (rev 2066)
@@ -1,62 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library 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 library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.log;
-
-import java.util.Set;
-
-public interface LogConfiguration {
- public static final String ROOT_CONTEXT = "org.teiid."; //$NON-NLS-1$
-
- /**
- * Get the current configured Log Level for supplied context
- * @param context
- * @return int value
- * @see com.metamatrix.core.log.MessageLevel
- */
- int getLogLevel(String context);
-
- /**
- * Obtain the set of message contexts that are currently used.
- * @return the unmodifiable set of context Strings; never null
- */
- Set<String> getContexts();
-
- /**
- * Set the Log Level
- *
- * Note: Must call setLogConfiguration(LogConfiguration) for log level to take
- * affect on the server.
- *
- * @param context log context name
- * @param logLevel The logLevel to set.
- */
- public void setLogLevel(String context, int logLevel);
-
- /**
- * Is the logging for the given context at the specified message level enabled.
- * @param context
- * @param msgLevel
- * @return
- */
- boolean isEnabled(String context, int msgLevel);
-}
Deleted: trunk/engine/src/main/java/com/metamatrix/common/log/LogConfigurationImpl.java
===================================================================
---
trunk/engine/src/main/java/com/metamatrix/common/log/LogConfigurationImpl.java 2010-04-21
00:35:51 UTC (rev 2065)
+++
trunk/engine/src/main/java/com/metamatrix/common/log/LogConfigurationImpl.java 2010-04-21
15:51:54 UTC (rev 2066)
@@ -1,89 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library 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 library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.log;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-public class LogConfigurationImpl implements LogConfiguration, Serializable {
-
- private static final long serialVersionUID = 4626429149431532292L;
-
- Map<String, Integer> contextMap = null;
- private int defaultLevel;
-
- public LogConfigurationImpl(int defaultLevel) {
- this.defaultLevel = defaultLevel;
- this.contextMap = new HashMap<String, Integer>();
- }
-
- public LogConfigurationImpl(Map<String, Integer> contextMap) {
- this.contextMap = contextMap;
- }
-
- @Override
- public Set<String> getContexts() {
- return this.contextMap.keySet();
- }
-
- @Override
- public int getLogLevel(String context) {
- Integer level = this.contextMap.get(context);
- if (level == null) {
- context = fixContext(context);
- }
- level = this.contextMap.get(context);
- if (level != null) {
- return level;
- }
- return defaultLevel;
- }
-
- private String fixContext(String context) {
- if (context.indexOf('.') == -1) {
- context = ROOT_CONTEXT+context;
- }
- return context;
- }
-
- @Override
- public void setLogLevel(String context, int logLevel) {
- this.contextMap.put(context, logLevel);
- }
-
- @Override
- public boolean isEnabled(String context, int msgLevel) {
- int level = getLogLevel(context);
- return level >= msgLevel;
- }
-
- public static LogConfiguration makeCopy(LogConfiguration config) {
- Map<String, Integer> contextMap = new HashMap<String, Integer>();
- for(String context:config.getContexts()) {
- contextMap.put(context, config.getLogLevel(context));
- }
- return new LogConfigurationImpl(contextMap);
- }
-}
Modified: trunk/engine/src/main/java/com/metamatrix/common/log/LogConstants.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/log/LogConstants.java 2010-04-21
00:35:51 UTC (rev 2065)
+++ trunk/engine/src/main/java/com/metamatrix/common/log/LogConstants.java 2010-04-21
15:51:54 UTC (rev 2066)
@@ -22,21 +22,20 @@
package com.metamatrix.common.log;
-import org.teiid.connector.basic.DefaultConnectorLogger;
public interface LogConstants {
// add the new contexts to the Log4JUtil.java class, for configuration purpose
- public static final String CTX_SECURITY = "SECURITY"; //$NON-NLS-1$
- public static final String CTX_TRANSPORT = "TRANSPORT"; //$NON-NLS-1$
- public static final String CTX_QUERY_PLANNER = "PLANNER"; //$NON-NLS-1$
- public static final String CTX_DQP = "PROCESSOR"; //$NON-NLS-1$
- public static final String CTX_CONNECTOR = DefaultConnectorLogger.CTX_CONNECTOR;
- public static final String CTX_BUFFER_MGR = "BUFFER_MGR"; //$NON-NLS-1$
- public static final String CTX_TXN_LOG = "TXN_LOG"; //$NON-NLS-1$
- public static final String CTX_COMMANDLOGGING = "COMMAND_LOG"; //$NON-NLS-1$
- public static final String CTX_AUDITLOGGING = "AUDIT_LOG"; //$NON-NLS-1$
- public static final String CTX_ADMIN_API = "ADMIN_API"; //$NON-NLS-1$
- public static final String CTX_RUNTIME = "RUNTIME"; //$NON-NLS-1$
+ public static final String CTX_SECURITY = "org.teiid.SECURITY"; //$NON-NLS-1$
+ public static final String CTX_TRANSPORT = "org.teiid.TRANSPORT";
//$NON-NLS-1$
+ public static final String CTX_QUERY_PLANNER = "org.teiid.PLANNER";
//$NON-NLS-1$
+ public static final String CTX_DQP = "org.teiid.PROCESSOR"; //$NON-NLS-1$
+ public static final String CTX_CONNECTOR = "org.teiid.CONNECTOR";
//$NON-NLS-1$
+ public static final String CTX_BUFFER_MGR = "org.teiid.BUFFER_MGR";
//$NON-NLS-1$
+ public static final String CTX_TXN_LOG = "org.teiid.TXN_LOG"; //$NON-NLS-1$
+ public static final String CTX_COMMANDLOGGING = "org.teiid.COMMAND_LOG";
//$NON-NLS-1$
+ public static final String CTX_AUDITLOGGING = "org.teiid.AUDIT_LOG";
//$NON-NLS-1$
+ public static final String CTX_ADMIN_API = "org.teiid.ADMIN_API";
//$NON-NLS-1$
+ public static final String CTX_RUNTIME = "org.teiid.RUNTIME"; //$NON-NLS-1$
// Query contexts
public static final String CTX_FUNCTION_TREE = CTX_QUERY_PLANNER +
".FUNCTION_TREE"; //$NON-NLS-1$
public static final String CTX_QUERY_RESOLVER = CTX_QUERY_PLANNER +
".RESOLVER"; //$NON-NLS-1$
Copied: trunk/engine/src/main/java/com/metamatrix/common/log/LogListener.java (from rev
2065, trunk/common-core/src/main/java/com/metamatrix/core/log/LogListener.java)
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/log/LogListener.java
(rev 0)
+++ trunk/engine/src/main/java/com/metamatrix/common/log/LogListener.java 2010-04-21
15:51:54 UTC (rev 2066)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library 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 library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.common.log;
+
+
+/**
+ * LogListener
+ */
+public interface LogListener {
+
+ /**
+ * Is the logging for the given context at the specified message level enabled.
+ * @param context
+ * @param msgLevel
+ * @return
+ */
+ boolean isEnabled(String context, int msgLevel);
+
+ void log(int level, String context, Object msg);
+
+ void log(int level, String context, Throwable t, Object msg);
+
+ /**
+ * Shut down this listener, requesting it clean up and release any resources it
+ * may have acquired during its use. The listener is free to ignore this
+ * request if it is not responsible for managing the resources it uses or if
+ * there are no resources.
+ */
+ void shutdown();
+
+}
Modified: trunk/engine/src/main/java/com/metamatrix/common/log/LogManager.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/log/LogManager.java 2010-04-21
00:35:51 UTC (rev 2065)
+++ trunk/engine/src/main/java/com/metamatrix/common/log/LogManager.java 2010-04-21
15:51:54 UTC (rev 2066)
@@ -27,10 +27,6 @@
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
-import com.metamatrix.core.log.JavaLogWriter;
-import com.metamatrix.core.log.LogListener;
-import com.metamatrix.core.log.LogMessage;
-import com.metamatrix.core.log.MessageLevel;
/**
@@ -134,12 +130,8 @@
}
}
-
- static LogConfiguration configuration = new LogConfigurationImpl(MessageLevel.DETAIL);
// either injected or manually set using the set methods
-
static LogListener logListener = new JavaLogWriter(); // either injected or manually
set using the set methods
-
/**
* Send a critical message to the log. This level of message is generally
* used to record an event or error that must be recorded (if any logging
@@ -362,22 +354,6 @@
logListener.log(msgLevel, context, e, message);
}
- /**
- * Utility method to obtain the a modifiable log configuration for the LogManager.
- * <p>After modifying the log config, user must call {@link
#setLogConfiguration(LogConfiguration)} to
- * affect the logging configuration.</p>
- * @return a modifiable copy of the current log configuration
- */
- public static LogConfiguration getLogConfigurationCopy() {
- return LogConfigurationImpl.makeCopy(configuration);
- }
-
- public static void setLogConfiguration(LogConfiguration config ) {
- if ( config != null ) {
- configuration = LogConfigurationImpl.makeCopy(config);
- }
- }
-
public static void setLogListener(LogListener listener) {
logListener.shutdown();
if (listener != null) {
@@ -397,8 +373,8 @@
* or false if it would be discarded by the LogManager.
*/
public static boolean isMessageToBeRecorded(String context, int msgLevel) {
- if (configuration != null) {
- return configuration.isEnabled(context, msgLevel);
+ if (logListener != null) {
+ return logListener.isEnabled(context, msgLevel);
}
return true;
}
Copied: trunk/engine/src/main/java/com/metamatrix/common/log/LogMessage.java (from rev
2065, trunk/common-core/src/main/java/com/metamatrix/core/log/LogMessage.java)
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/log/LogMessage.java
(rev 0)
+++ trunk/engine/src/main/java/com/metamatrix/common/log/LogMessage.java 2010-04-21
15:51:54 UTC (rev 2066)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library 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 library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.common.log;
+
+import java.io.Serializable;
+
+
+public class LogMessage implements Serializable{
+
+ private Object[] msgParts;
+
+ public LogMessage(Object[] msgParts) {
+ this.msgParts = msgParts;
+ }
+
+ public Object[] getMessageParts() {
+ return this.msgParts;
+ }
+
+ public String getText() {
+ StringBuffer text = null;
+ if(msgParts != null) {
+ text = new StringBuffer();
+ for(int i=0; i<msgParts.length; i++) {
+ if (i>0) text.append(" "); //$NON-NLS-1$
+ Object omsg = msgParts[i];
+ if ( omsg != null ) {
+ text.append(omsg.toString());
+ }
+ }
+ }
+
+ if (text == null) {
+ return "NULL"; //$NON-NLS-1$
+ }
+ return text.toString();
+ }
+
+ public String toString() {
+ return getText();
+ }
+}
Copied: trunk/engine/src/main/java/com/metamatrix/common/log/MessageLevel.java (from rev
2065, trunk/common-core/src/main/java/com/metamatrix/core/log/MessageLevel.java)
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/log/MessageLevel.java
(rev 0)
+++ trunk/engine/src/main/java/com/metamatrix/common/log/MessageLevel.java 2010-04-21
15:51:54 UTC (rev 2066)
@@ -0,0 +1,230 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library 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 library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.common.log;
+
+import java.util.*;
+
+/**
+ * Constants that define the level of the messages that are to be recorded
+ * by the LogManager.
+ */
+public final class MessageLevel {
+
+ /**
+ * Message level value that specifies that no messages are to be recorded.
+ */
+ public static final int NONE = 0;
+
+ /**
+ * Message level value that specifies that critical messages are to be recorded.
+ */
+ public static final int CRITICAL = 1;
+
+ /**
+ * Message level value that specifies that error messages and critical
+ * messages are to be recorded.
+ */
+ public static final int ERROR = 2;
+
+ /**
+ * Message level value that specifies that warning, error and critical
+ * messages are to be recorded.
+ */
+ public static final int WARNING = 3;
+
+ /**
+ * Message level value that specifies that information, warning, error and critical
+ * messages are to be recorded.
+ */
+ public static final int INFO = 4;
+
+ /**
+ * Message level value that specifies that detailed, information, warning, error and
critical
+ * messages are to be recorded.
+ */
+ public static final int DETAIL = 5;
+
+ /**
+ * Message level value that specifies that all messages are to be recorded.
+ */
+ public static final int TRACE = 6;
+
+
+ /**
+ * The default message level is WARNING.
+ */
+ public static final int DEFAULT_MESSAGE_LEVEL = WARNING;
+
+ private static final int MINIMUM = NONE;
+ private static final int MAXIMUM = TRACE;
+
+ /**
+ * Constants that define the types of the messages that are to be recorded
+ * by the LogManager.
+ */
+ public static class Labels {
+ public static final String CRITICAL = "CRITICAL"; //$NON-NLS-1$
+ public static final String ERROR = "ERROR"; //$NON-NLS-1$
+ public static final String WARNING = "WARNING"; //$NON-NLS-1$
+ public static final String INFO = "INFO"; //$NON-NLS-1$
+ public static final String DETAIL = "DETAIL"; //$NON-NLS-1$
+ public static final String TRACE = "TRACE"; //$NON-NLS-1$
+ public static final String NONE = "NONE"; //$NON-NLS-1$
+ static final String UNKNOWN = "UNKNOWN"; //$NON-NLS-1$
+ }
+
+ /**
+ * Constants that define the types of the messages that are to be recorded
+ * by the LogManager.
+ */
+ public static class DisplayNames {
+ public static final String CRITICAL = "Critical"; //$NON-NLS-1$
+ public static final String ERROR = "Error"; //$NON-NLS-1$
+ public static final String WARNING = "Warning"; //$NON-NLS-1$
+ public static final String INFO = "Information"; //$NON-NLS-1$
+ public static final String DETAIL = "Detail"; //$NON-NLS-1$
+ public static final String TRACE = "Trace"; //$NON-NLS-1$
+ public static final String NONE = "None"; //$NON-NLS-1$
+ }
+
+ private static Map LABEL_TO_LEVEL_MAP = new HashMap();
+ private static Map DISPLAY_TO_LEVEL_MAP = new HashMap();
+ private static List LABELS = new ArrayList(MAXIMUM - MINIMUM + 1);
+ private static List DISPLAYS = new ArrayList(MAXIMUM - MINIMUM + 1);
+
+ static {
+ LABEL_TO_LEVEL_MAP.put(Labels.CRITICAL, new Integer(CRITICAL) );
+ LABEL_TO_LEVEL_MAP.put(Labels.ERROR, new Integer(ERROR) );
+ LABEL_TO_LEVEL_MAP.put(Labels.WARNING, new Integer(WARNING) );
+ LABEL_TO_LEVEL_MAP.put(Labels.INFO, new Integer(INFO) );
+ LABEL_TO_LEVEL_MAP.put(Labels.DETAIL, new Integer(DETAIL) );
+ LABEL_TO_LEVEL_MAP.put(Labels.TRACE, new Integer(TRACE) );
+ LABEL_TO_LEVEL_MAP.put(Labels.NONE, new Integer(NONE) );
+ DISPLAY_TO_LEVEL_MAP.put(DisplayNames.CRITICAL, new Integer(CRITICAL) );
+ DISPLAY_TO_LEVEL_MAP.put(DisplayNames.ERROR, new Integer(ERROR) );
+ DISPLAY_TO_LEVEL_MAP.put(DisplayNames.WARNING, new Integer(WARNING) );
+ DISPLAY_TO_LEVEL_MAP.put(DisplayNames.INFO, new Integer(INFO) );
+ DISPLAY_TO_LEVEL_MAP.put(DisplayNames.DETAIL, new Integer(DETAIL) );
+ DISPLAY_TO_LEVEL_MAP.put(DisplayNames.TRACE, new Integer(TRACE) );
+ DISPLAY_TO_LEVEL_MAP.put(DisplayNames.NONE, new Integer(NONE) );
+
+ // Do in the correct order so that the indexes match the levels
+ LABELS.add(Labels.NONE);
+ LABELS.add(Labels.CRITICAL);
+ LABELS.add(Labels.ERROR);
+ LABELS.add(Labels.WARNING);
+ LABELS.add(Labels.INFO);
+ LABELS.add(Labels.DETAIL);
+ LABELS.add(Labels.TRACE);
+ DISPLAYS.add(DisplayNames.NONE);
+ DISPLAYS.add(DisplayNames.CRITICAL);
+ DISPLAYS.add(DisplayNames.ERROR);
+ DISPLAYS.add(DisplayNames.WARNING);
+ DISPLAYS.add(DisplayNames.INFO);
+ DISPLAYS.add(DisplayNames.DETAIL);
+ DISPLAYS.add(DisplayNames.TRACE);
+ }
+
+ /**
+ * Utility method to set the level of messages that are recorded for this VM.
+ * @param newMessageLevel the new level; must be either
+ * <code>MessageLevel.NONE</code>,
+ * <code>MessageLevel.CRITICAL</code>,
+ * <code>MessageLevel.ERROR</code>,
+ * <code>MessageLevel.WARNING</code>,
+ * <code>MessageLevel.INFO</code>,
+ * <code>MessageLevel.DETAIL</code>, or
+ * <code>MessageLevel.TRACE.
+ * @throws IllegalArgumentException if the level is out of range.
+ */
+ public static boolean isMessageLevelValid( int newMessageLevel ) {
+ return !( newMessageLevel < MessageLevel.NONE || newMessageLevel >
MessageLevel.TRACE );
+ }
+
+ /**
+ * Utility method for knowing what is the lower boundary for
+ * a valid message level.
+ * @return int message level
+ * @see #validUpperMessageLevel
+ */
+ public static int getValidLowerMessageLevel() {
+ return MessageLevel.NONE;
+ }
+
+ /**
+ * Utility method for knowing what is the upper boundary for
+ * a valid message level.
+ * @return int message level
+ * @see #validLowerMessageLevel
+ */
+ public static int getValidUpperMessageLevel() {
+ return MessageLevel.TRACE;
+ }
+
+ public static String getLabelForLevel( int level ) {
+ switch ( level ) {
+ case MessageLevel.NONE:
+ return Labels.NONE;
+ case MessageLevel.CRITICAL:
+ return Labels.CRITICAL;
+ case MessageLevel.ERROR:
+ return Labels.ERROR;
+ case MessageLevel.WARNING:
+ return Labels.WARNING;
+ case MessageLevel.INFO:
+ return Labels.INFO;
+ case MessageLevel.DETAIL:
+ return Labels.DETAIL;
+ case MessageLevel.TRACE:
+ return Labels.TRACE;
+ }
+ return Labels.UNKNOWN;
+ //throw new IllegalArgumentException("The specified message level
\"" + level + "\" is invalid");
+ }
+
+ public static int getMinimumLevel() {
+ return MINIMUM;
+ }
+
+ public static int getMaximumLevel() {
+ return MAXIMUM;
+ }
+
+ public static Collection getDisplayNames() {
+ return DISPLAYS;
+ }
+
+
+ /**
+ * Utility method to get the labels for the levels, starting with the lowest
+ * level and ending with the highest level.
+ * @return an ordered list of String labels
+ */
+ public static List getLabels() {
+ return LABELS;
+ }
+
+
+
+}
+
Modified: trunk/engine/src/main/java/com/metamatrix/query/analysis/AnalysisRecord.java
===================================================================
---
trunk/engine/src/main/java/com/metamatrix/query/analysis/AnalysisRecord.java 2010-04-21
00:35:51 UTC (rev 2065)
+++
trunk/engine/src/main/java/com/metamatrix/query/analysis/AnalysisRecord.java 2010-04-21
15:51:54 UTC (rev 2066)
@@ -36,8 +36,8 @@
import com.metamatrix.common.log.LogConstants;
import com.metamatrix.common.log.LogManager;
+import com.metamatrix.common.log.MessageLevel;
import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.query.sql.LanguageObject;
import com.metamatrix.query.sql.lang.SubqueryContainer;
import com.metamatrix.query.sql.symbol.SingleElementSymbol;
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/QueryProcessor.java
===================================================================
---
trunk/engine/src/main/java/com/metamatrix/query/processor/QueryProcessor.java 2010-04-21
00:35:51 UTC (rev 2065)
+++
trunk/engine/src/main/java/com/metamatrix/query/processor/QueryProcessor.java 2010-04-21
15:51:54 UTC (rev 2066)
@@ -36,8 +36,8 @@
import com.metamatrix.common.buffer.BufferManager.TupleSourceType;
import com.metamatrix.common.log.LogConstants;
import com.metamatrix.common.log.LogManager;
+import com.metamatrix.common.log.MessageLevel;
import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.core.util.Assertion;
import com.metamatrix.query.execution.QueryExecPlugin;
import com.metamatrix.query.processor.BatchCollector.BatchProducer;
Modified:
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/RelationalNode.java
===================================================================
---
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/RelationalNode.java 2010-04-21
00:35:51 UTC (rev 2065)
+++
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/RelationalNode.java 2010-04-21
15:51:54 UTC (rev 2066)
@@ -38,7 +38,7 @@
import com.metamatrix.common.buffer.BufferManager;
import com.metamatrix.common.buffer.TupleBatch;
import com.metamatrix.common.log.LogManager;
-import com.metamatrix.core.log.MessageLevel;
+import com.metamatrix.common.log.MessageLevel;
import com.metamatrix.core.util.Assertion;
import com.metamatrix.query.analysis.AnalysisRecord;
import com.metamatrix.query.processor.ProcessorDataManager;
Modified:
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SortUtility.java
===================================================================
---
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SortUtility.java 2010-04-21
00:35:51 UTC (rev 2065)
+++
trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SortUtility.java 2010-04-21
15:51:54 UTC (rev 2066)
@@ -39,7 +39,7 @@
import com.metamatrix.common.buffer.BufferManager.BufferReserveMode;
import com.metamatrix.common.buffer.BufferManager.TupleSourceType;
import com.metamatrix.common.log.LogManager;
-import com.metamatrix.core.log.MessageLevel;
+import com.metamatrix.common.log.MessageLevel;
import com.metamatrix.core.util.Assertion;
import com.metamatrix.query.sql.lang.OrderBy;
import com.metamatrix.query.sql.symbol.SingleElementSymbol;
Modified:
trunk/engine/src/main/java/com/metamatrix/query/processor/xml/SAXDocumentInProgress.java
===================================================================
---
trunk/engine/src/main/java/com/metamatrix/query/processor/xml/SAXDocumentInProgress.java 2010-04-21
00:35:51 UTC (rev 2065)
+++
trunk/engine/src/main/java/com/metamatrix/query/processor/xml/SAXDocumentInProgress.java 2010-04-21
15:51:54 UTC (rev 2066)
@@ -37,7 +37,7 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.log.LogManager;
-import com.metamatrix.core.log.MessageLevel;
+import com.metamatrix.common.log.MessageLevel;
import com.metamatrix.query.mapping.xml.MappingNodeConstants;
/**
Modified:
trunk/engine/src/main/java/com/metamatrix/query/processor/xml/XMLProcessorEnvironment.java
===================================================================
---
trunk/engine/src/main/java/com/metamatrix/query/processor/xml/XMLProcessorEnvironment.java 2010-04-21
00:35:51 UTC (rev 2065)
+++
trunk/engine/src/main/java/com/metamatrix/query/processor/xml/XMLProcessorEnvironment.java 2010-04-21
15:51:54 UTC (rev 2066)
@@ -31,7 +31,7 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.buffer.BufferManager;
import com.metamatrix.common.log.LogManager;
-import com.metamatrix.core.log.MessageLevel;
+import com.metamatrix.common.log.MessageLevel;
import com.metamatrix.query.mapping.xml.ResultSetInfo;
import com.metamatrix.query.processor.ProcessorDataManager;
import com.metamatrix.query.processor.ProcessorPlan;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2010-04-21
00:35:51 UTC (rev 2065)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2010-04-21
15:51:54 UTC (rev 2066)
@@ -64,9 +64,9 @@
import com.metamatrix.common.buffer.BufferManager;
import com.metamatrix.common.log.LogConstants;
import com.metamatrix.common.log.LogManager;
+import com.metamatrix.common.log.MessageLevel;
import com.metamatrix.common.types.Streamable;
import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.core.util.Assertion;
import com.metamatrix.dqp.DQPPlugin;
import com.metamatrix.dqp.message.AtomicRequestMessage;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2010-04-21
00:35:51 UTC (rev 2065)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2010-04-21
15:51:54 UTC (rev 2066)
@@ -48,10 +48,10 @@
import com.metamatrix.common.buffer.BufferManager;
import com.metamatrix.common.log.LogConstants;
import com.metamatrix.common.log.LogManager;
+import com.metamatrix.common.log.MessageLevel;
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.core.id.IDGenerator;
import com.metamatrix.core.id.IntegerIDFactory;
-import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.core.util.Assertion;
import com.metamatrix.dqp.DQPPlugin;
import com.metamatrix.dqp.message.RequestID;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2010-04-21
00:35:51 UTC (rev 2065)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2010-04-21
15:51:54 UTC (rev 2066)
@@ -50,9 +50,9 @@
import com.metamatrix.common.buffer.TupleBuffer;
import com.metamatrix.common.log.LogConstants;
import com.metamatrix.common.log.LogManager;
+import com.metamatrix.common.log.MessageLevel;
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.core.MetaMatrixCoreException;
-import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.dqp.DQPPlugin;
import com.metamatrix.dqp.message.AtomicRequestID;
import com.metamatrix.dqp.message.RequestID;
Modified:
trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/AuthorizationValidationVisitor.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/AuthorizationValidationVisitor.java 2010-04-21
00:35:51 UTC (rev 2065)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/AuthorizationValidationVisitor.java 2010-04-21
15:51:54 UTC (rev 2066)
@@ -46,7 +46,7 @@
import com.metamatrix.api.exception.query.QueryMetadataException;
import com.metamatrix.common.log.LogConstants;
import com.metamatrix.common.log.LogManager;
-import com.metamatrix.core.log.MessageLevel;
+import com.metamatrix.common.log.MessageLevel;
import com.metamatrix.dqp.DQPPlugin;
import com.metamatrix.query.function.FunctionLibrary;
import com.metamatrix.query.metadata.TempMetadataID;
Modified: trunk/engine/src/test/java/com/metamatrix/common/log/TestLogManager.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/common/log/TestLogManager.java 2010-04-21
00:35:51 UTC (rev 2065)
+++ trunk/engine/src/test/java/com/metamatrix/common/log/TestLogManager.java 2010-04-21
15:51:54 UTC (rev 2066)
@@ -27,11 +27,10 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import junit.framework.TestCase;
-import com.metamatrix.core.log.LogListener;
-import com.metamatrix.core.log.MessageLevel;
/**
* This test case tests the LogManager.
@@ -50,9 +49,9 @@
@Override
protected void setUp() throws Exception {
- Map<String, Integer> contextMap = new HashMap<String, Integer>();
- contextMap.put(context, MessageLevel.DETAIL);
- LogManager.configuration = new LogConfigurationImpl(contextMap);
+ ListLogger logger = new ListLogger();
+ logger.setLogLevel(context, MessageLevel.DETAIL);
+ LogManager.logListener = logger;
}
// =========================================================================
@@ -65,9 +64,8 @@
public void testIsMessageToBeRecordedString() {
assertTrue(LogManager.isMessageToBeRecorded(context, MessageLevel.CRITICAL) );
- LogConfiguration cfg = LogManager.getLogConfigurationCopy();
+ ListLogger cfg = (ListLogger)LogManager.logListener;
cfg.setLogLevel(context, MessageLevel.NONE);
- LogManager.setLogConfiguration(cfg);
assertFalse(LogManager.isMessageToBeRecorded(context, MessageLevel.CRITICAL) );
}
@@ -75,14 +73,8 @@
* Test that all msgs logged are equal and output in same order.
*/
public void testLogMessage() throws Exception {
-
-
- LogConfiguration cfg = LogManager.getLogConfigurationCopy();
+ ListLogger cfg = (ListLogger)LogManager.logListener;
cfg.setLogLevel(context, MessageLevel.INFO );
- LogManager.setLogConfiguration(cfg);
-
- ListLogger listener = new ListLogger(6);
- LogManager.logListener = listener;
List<String> sentMsgList = new ArrayList<String>();
sentMsgList.add("A message 1"); //$NON-NLS-1$
@@ -97,51 +89,11 @@
LogManager.logInfo(context, msg);
}
- List recevedMsgList = listener.getLoggedMessages();
+ List recevedMsgList = cfg.getLoggedMessages();
assertEquals(sentMsgList.size(), recevedMsgList.size());
assertEquals(sentMsgList, recevedMsgList);
}
- public void testFilterMessage() {
- final LogConfiguration cfg = LogManager.getLogConfigurationCopy();
- cfg.setLogLevel(context, MessageLevel.INFO );
- LogManager.setLogConfiguration(cfg);
-
- LogListener listener = new LogListener() {
- @Override
- public void log(int level, String context, Object msg) {
- int setLevel = cfg.getLogLevel(context);
- assertTrue(level <= setLevel);
- }
-
- @Override
- public void log(int level, String context, Throwable t, Object msg) {
- int setLevel = cfg.getLogLevel(context);
- assertTrue(level <= setLevel);
- }
-
- @Override
- public void shutdown() {
- }
- };
- LogManager.logListener = listener;
-
- LogManager.logCritical(context, "message"); //$NON-NLS-1$
- LogManager.logDetail(context, "msgParts");//$NON-NLS-1$
- LogManager.logError(context, "message");//$NON-NLS-1$
- LogManager.logInfo(context, "message");//$NON-NLS-1$
- LogManager.logTrace(context, "msgParts");//$NON-NLS-1$
- LogManager.logWarning(context, "message");//$NON-NLS-1$
-
- Exception e = new Exception("test"); //$NON-NLS-1$
- LogManager.logCritical(context, e, "message"); //$NON-NLS-1$
- LogManager.logDetail(context, e, "msgParts");//$NON-NLS-1$
- LogManager.logError(context, e, "message");//$NON-NLS-1$
- LogManager.log(MessageLevel.INFO, context, e, "message");//$NON-NLS-1$
- LogManager.logTrace(context,e, "msgParts");//$NON-NLS-1$
- LogManager.logWarning(context, e, "message");//$NON-NLS-1$
- }
-
/**
*
* A log listener that saves messages (IStatus)s in a
@@ -149,27 +101,21 @@
*/
class ListLogger implements LogListener {
private List<String> messages = new ArrayList<String>();
- private int expectedMessages;
+ private Map<String, Integer> contextMap = new HashMap<String,
Integer>();
+ private int defaultLevel;
- public ListLogger(int expectedMessages) {
- this.expectedMessages = expectedMessages;
+ public ListLogger() {
}
-
+
/* (non-Javadoc)
* @see
com.metamatrix.core.log.LogListener#logMessage(org.eclipse.core.runtime.IStatus, long,
java.lang.String, java.lang.String)
*/
- public synchronized void log(int level, String context, Object msg){
+ public void log(int level, String context, Object msg){
this.messages.add(msg.toString());
- if (this.messages.size() == expectedMessages) {
- this.notifyAll();
- }
}
public void log(int level, String context, Throwable t, Object msg) {
this.messages.add(msg.toString());
- if (this.messages.size() == expectedMessages) {
- this.notifyAll();
- }
}
/* (non-Javadoc)
@@ -185,13 +131,31 @@
return this.messages.size();
}
- public synchronized List getLoggedMessages() throws InterruptedException {
- if (this.messages.size() < expectedMessages) {
- this.wait(1000);
- }
+ public List getLoggedMessages() {
return this.messages;
}
+
+ public Set<String> getContexts() {
+ return this.contextMap.keySet();
+ }
+ public int getLogLevel(String context) {
+ Integer level = this.contextMap.get(context);
+ if (level != null) {
+ return level;
+ }
+ return defaultLevel;
+ }
+
+ public void setLogLevel(String context, int logLevel) {
+ this.contextMap.put(context, logLevel);
+ }
+
+ @Override
+ public boolean isEnabled(String context, int msgLevel) {
+ int level = getLogLevel(context);
+ return level >= msgLevel;
+ }
}
}
Modified:
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
===================================================================
---
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2010-04-21
00:35:51 UTC (rev 2065)
+++
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2010-04-21
15:51:54 UTC (rev 2066)
@@ -59,8 +59,7 @@
import org.teiid.dqp.internal.process.DQPWorkContext;
import org.teiid.dqp.internal.transaction.TransactionServerImpl;
import org.teiid.jboss.IntegrationPlugin;
-import org.teiid.logging.LogConfigurationProvider;
-import org.teiid.logging.LogListernerProvider;
+import org.teiid.logging.Log4jListener;
import org.teiid.security.SecurityHelper;
import org.teiid.transport.ClientServiceRegistry;
import org.teiid.transport.ClientServiceRegistryImpl;
@@ -72,8 +71,8 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.log.LogConstants;
import com.metamatrix.common.log.LogManager;
+import com.metamatrix.common.log.MessageLevel;
import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.dqp.service.BufferService;
import com.metamatrix.dqp.service.SessionService;
import com.metamatrix.dqp.service.SessionServiceException;
@@ -98,8 +97,7 @@
public RuntimeEngineDeployer() {
// TODO: this does not belong here
- LogManager.setLogConfiguration(new LogConfigurationProvider().get());
- LogManager.setLogListener(new LogListernerProvider().get());
+ LogManager.setLogListener(new Log4jListener());
}
@Override
Modified: trunk/runtime/src/main/java/org/teiid/logging/CommonsLogManagerAdapter.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/logging/CommonsLogManagerAdapter.java 2010-04-21
00:35:51 UTC (rev 2065)
+++ trunk/runtime/src/main/java/org/teiid/logging/CommonsLogManagerAdapter.java 2010-04-21
15:51:54 UTC (rev 2066)
@@ -25,7 +25,7 @@
import org.apache.commons.logging.Log;
import com.metamatrix.common.log.LogManager;
-import com.metamatrix.core.log.MessageLevel;
+import com.metamatrix.common.log.MessageLevel;
/**
* This class is bridge for hooking LogManager into systems that use apache commons
logging. In the Teiid
Deleted: trunk/runtime/src/main/java/org/teiid/logging/Log4JUtil.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/logging/Log4JUtil.java 2010-04-21 00:35:51 UTC
(rev 2065)
+++ trunk/runtime/src/main/java/org/teiid/logging/Log4JUtil.java 2010-04-21 15:51:54 UTC
(rev 2066)
@@ -1,123 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library 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 library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.logging;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-
-import com.metamatrix.common.log.LogConfiguration;
-import com.metamatrix.core.log.MessageLevel;
-
-class Log4JUtil {
- private static final String ROOT_CONTEXT = LogConfiguration.ROOT_CONTEXT;
-
- /**
- * Convert {@link MessageLevel} to {@link Level}
- * @param level
- * @return
- */
- public static Level convert2Log4JLevel(int level) {
- switch (level) {
- case MessageLevel.CRITICAL:
- return Level.FATAL;
- case MessageLevel.ERROR:
- return Level.ERROR;
- case MessageLevel.WARNING:
- return Level.WARN;
- case MessageLevel.INFO:
- return Level.INFO;
- case MessageLevel.DETAIL:
- case MessageLevel.TRACE:
- return Level.DEBUG;
- case MessageLevel.NONE:
- return Level.OFF;
- }
- return Level.DEBUG;
- }
-
- /**
- * Convert {@link Level} to {@link MessageLevel}
- * @param level
- * @return
- */
- public static int convert2MessageLevel(Level level) {
- switch (level.toInt()) {
- case Level.FATAL_INT:
- return MessageLevel.CRITICAL;
- case Level.ERROR_INT:
- return MessageLevel.ERROR;
- case Level.WARN_INT:
- return MessageLevel.WARNING;
- case Level.INFO_INT:
- return MessageLevel.INFO;
- case Level.DEBUG_INT:
- return MessageLevel.DETAIL;
- case Level.OFF_INT:
- return MessageLevel.NONE;
- }
- return MessageLevel.DETAIL;
- }
-
- /**
- * Get the logger for the given context.
- * @param context
- * @return
- */
- public static Logger getLogger(String context) {
- Logger log4j = null;
- if (context.indexOf('.') == -1) {
- log4j = Logger.getLogger(ROOT_CONTEXT+context);
- }
- else {
- log4j = Logger.getLogger(context);
- }
- return log4j;
- }
-
- public static Set<String> getContexts(){
- HashSet<String> contexts = new HashSet<String>();
- contexts.add(ROOT_CONTEXT+com.metamatrix.common.log.LogConstants.CTX_DQP);
- contexts.add(ROOT_CONTEXT+com.metamatrix.common.log.LogConstants.CTX_CONNECTOR);
- contexts.add(ROOT_CONTEXT+com.metamatrix.common.log.LogConstants.CTX_BUFFER_MGR);
- contexts.add(ROOT_CONTEXT+com.metamatrix.common.log.LogConstants.CTX_TXN_LOG);
- contexts.add(ROOT_CONTEXT+com.metamatrix.common.log.LogConstants.CTX_COMMANDLOGGING);
- contexts.add(ROOT_CONTEXT+com.metamatrix.common.log.LogConstants.CTX_AUDITLOGGING);
- contexts.add(ROOT_CONTEXT+com.metamatrix.common.log.LogConstants.CTX_SECURITY);
- contexts.add(ROOT_CONTEXT+com.metamatrix.common.log.LogConstants.CTX_TRANSPORT);
- contexts.add(ROOT_CONTEXT+com.metamatrix.common.log.LogConstants.CTX_ADMIN_API);
- contexts.add(ROOT_CONTEXT+com.metamatrix.common.log.LogConstants.CTX_QUERY_PLANNER);
- contexts.add(ROOT_CONTEXT+com.metamatrix.common.log.LogConstants.CTX_RUNTIME);
-
- contexts.add(ROOT_CONTEXT+com.metamatrix.common.log.LogConstants.CTX_FUNCTION_TREE);
- contexts.add(ROOT_CONTEXT+com.metamatrix.common.log.LogConstants.CTX_QUERY_RESOLVER);
- contexts.add(ROOT_CONTEXT+com.metamatrix.common.log.LogConstants.CTX_XML_PLANNER);
- contexts.add(ROOT_CONTEXT+com.metamatrix.common.log.LogConstants.CTX_XML_PLAN);
-
- contexts.add("com.arjuna"); //$NON-NLS-1$
- contexts.add("org.jboss"); //$NON-NLS-1$
- contexts.add("org.teiid"); //$NON-NLS-1$
- return contexts;
- }
-}
Added: trunk/runtime/src/main/java/org/teiid/logging/Log4jListener.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/logging/Log4jListener.java
(rev 0)
+++ trunk/runtime/src/main/java/org/teiid/logging/Log4jListener.java 2010-04-21 15:51:54
UTC (rev 2066)
@@ -0,0 +1,120 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library 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 library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.logging;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+
+import com.metamatrix.common.log.LogListener;
+import com.metamatrix.common.log.MessageLevel;
+
+/**
+ * Log4J Listener
+ */
+public class Log4jListener implements LogListener{
+
+ @Override
+ public boolean isEnabled(String context, int level) {
+ if ( context == null ) {
+ return false;
+ }
+ Level logLevel = convert2Log4JLevel(level);
+ if ( logLevel == Level.OFF) {
+ return false;
+ }
+ Logger log = getLogger(context);
+ return log.isEnabledFor(logLevel);
+ }
+
+ @Override
+ public void log(int level, String context, Object msg) {
+ Logger log4j = getLogger(context);
+ log4j.log(convert2Log4JLevel(level), msg);
+ }
+
+ public void log(int level, String context, Throwable t, Object msg) {
+ Logger log4j = getLogger(context);
+ log4j.log(convert2Log4JLevel(level), msg, t);
+ }
+
+ /**
+ * Convert {@link MessageLevel} to {@link Level}
+ * @param level
+ * @return
+ */
+ public static Level convert2Log4JLevel(int level) {
+ switch (level) {
+ case MessageLevel.CRITICAL:
+ return Level.FATAL;
+ case MessageLevel.ERROR:
+ return Level.ERROR;
+ case MessageLevel.WARNING:
+ return Level.WARN;
+ case MessageLevel.INFO:
+ return Level.INFO;
+ case MessageLevel.DETAIL:
+ case MessageLevel.TRACE:
+ return Level.DEBUG;
+ case MessageLevel.NONE:
+ return Level.OFF;
+ }
+ return Level.DEBUG;
+ }
+
+ /**
+ * Convert {@link Level} to {@link MessageLevel}
+ * @param level
+ * @return
+ */
+ public static int convert2MessageLevel(Level level) {
+ switch (level.toInt()) {
+ case Level.FATAL_INT:
+ return MessageLevel.CRITICAL;
+ case Level.ERROR_INT:
+ return MessageLevel.ERROR;
+ case Level.WARN_INT:
+ return MessageLevel.WARNING;
+ case Level.INFO_INT:
+ return MessageLevel.INFO;
+ case Level.DEBUG_INT:
+ return MessageLevel.DETAIL;
+ case Level.OFF_INT:
+ return MessageLevel.NONE;
+ }
+ return MessageLevel.DETAIL;
+ }
+
+ /**
+ * Get the logger for the given context.
+ * @param context
+ * @return
+ */
+ public static Logger getLogger(String context) {
+ return Logger.getLogger(context);
+ }
+
+ @Override
+ public void shutdown() {
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/runtime/src/main/java/org/teiid/logging/Log4jListener.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: trunk/runtime/src/main/java/org/teiid/logging/LogConfigurationProvider.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/logging/LogConfigurationProvider.java 2010-04-21
00:35:51 UTC (rev 2065)
+++ trunk/runtime/src/main/java/org/teiid/logging/LogConfigurationProvider.java 2010-04-21
15:51:54 UTC (rev 2066)
@@ -1,79 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library 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 library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.logging;
-
-import java.util.Set;
-
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-
-import com.metamatrix.common.log.LogConfiguration;
-
-public class LogConfigurationProvider {
-
- public LogConfiguration get() {
- return new Log4JLogConfiguration();
- }
-
- static class Log4JLogConfiguration implements LogConfiguration {
-
- @Override
- public Set<String> getContexts() {
- return Log4JUtil.getContexts();
- }
-
- @Override
- public int getLogLevel(String context) {
- Logger log = Log4JUtil.getLogger(context);
- Level level = log.getLevel();
- while (level == null) {
- log = (Logger)log.getParent();
- if (log != null) {
- level = log.getLevel();
- }
- else {
- level = Level.ERROR;
- }
- }
- return Log4JUtil.convert2MessageLevel(level);
- }
-
- @Override
- public boolean isEnabled(String context, int level) {
- if ( context == null ) {
- return false;
- }
- Level logLevel = Log4JUtil.convert2Log4JLevel(level);
- if ( logLevel == Level.OFF) {
- return false;
- }
- Logger log = Log4JUtil.getLogger(context);
- return log.isEnabledFor(logLevel);
- }
-
- @Override
- public void setLogLevel(String context, int level) {
- Logger log = Log4JUtil.getLogger(context);
- log.setLevel(Log4JUtil.convert2Log4JLevel(level));
- }
- }
-}
Deleted: trunk/runtime/src/main/java/org/teiid/logging/LogListernerProvider.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/logging/LogListernerProvider.java 2010-04-21
00:35:51 UTC (rev 2065)
+++ trunk/runtime/src/main/java/org/teiid/logging/LogListernerProvider.java 2010-04-21
15:51:54 UTC (rev 2066)
@@ -1,56 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library 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 library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.logging;
-
-import org.apache.log4j.Logger;
-
-import com.metamatrix.core.log.LogListener;
-
-public class LogListernerProvider {
-
- public LogListener get() {
- return new Log4jListener();
- }
-
- /**
- * Log4J Listener
- */
- static class Log4jListener implements LogListener{
-
- @Override
- public void log(int level, String context, Object msg) {
- Logger log4j = Log4JUtil.getLogger(context);
- log4j.log(Log4JUtil.convert2Log4JLevel(level), msg);
- }
-
- public void log(int level, String context, Throwable t, Object msg) {
- Logger log4j = Log4JUtil.getLogger(context);
- log4j.log(Log4JUtil.convert2Log4JLevel(level), msg, t);
- }
-
- @Override
- public void shutdown() {
- }
-
- }
-}
Modified: trunk/runtime/src/main/java/org/teiid/transport/SocketClientInstance.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/SocketClientInstance.java 2010-04-21
00:35:51 UTC (rev 2065)
+++ trunk/runtime/src/main/java/org/teiid/transport/SocketClientInstance.java 2010-04-21
15:51:54 UTC (rev 2066)
@@ -36,11 +36,11 @@
import com.metamatrix.common.log.LogConstants;
import com.metamatrix.common.log.LogManager;
+import com.metamatrix.common.log.MessageLevel;
import com.metamatrix.common.util.crypto.CryptoException;
import com.metamatrix.common.util.crypto.Cryptor;
import com.metamatrix.common.util.crypto.DhKeyGenerator;
import com.metamatrix.common.util.crypto.NullCryptor;
-import com.metamatrix.core.log.MessageLevel;
/**
* Sockets implementation of the communication framework class representing the
server's view of a client connection.
Modified: trunk/runtime/src/main/java/org/teiid/transport/SocketListener.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/SocketListener.java 2010-04-21
00:35:51 UTC (rev 2065)
+++ trunk/runtime/src/main/java/org/teiid/transport/SocketListener.java 2010-04-21
15:51:54 UTC (rev 2066)
@@ -37,8 +37,8 @@
import com.metamatrix.common.buffer.StorageManager;
import com.metamatrix.common.log.LogConstants;
import com.metamatrix.common.log.LogManager;
+import com.metamatrix.common.log.MessageLevel;
import com.metamatrix.common.util.ApplicationInfo;
-import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.core.util.NamedThreadFactory;
/**