[teiid-commits] teiid SVN: r1056 - in trunk: common-core/src/main/java/com/metamatrix/internal/core and 12 other directories.
teiid-commits at lists.jboss.org
teiid-commits at lists.jboss.org
Tue Jun 16 14:05:23 EDT 2009
Author: rareddy
Date: 2009-06-16 14:05:22 -0400 (Tue, 16 Jun 2009)
New Revision: 1056
Removed:
trunk/common-core/src/main/java/com/metamatrix/core/log/FileLimitSizeLogWriter.java
trunk/common-core/src/main/java/com/metamatrix/core/log/FileLogWriter.java
trunk/common-core/src/main/java/com/metamatrix/core/log/NullLogger.java
trunk/common-core/src/main/java/com/metamatrix/core/log/SystemLogWriter.java
trunk/common-core/src/main/java/com/metamatrix/internal/core/log/
trunk/server/src/main/java/com/metamatrix/server/ServerLogListernerProvider.java
trunk/soap/src/main/java/com/metamatrix/soap/log/MMSOAPLog.java
Modified:
trunk/common-core/src/main/java/com/metamatrix/core/log/JavaLogWriter.java
trunk/common-core/src/main/java/com/metamatrix/core/log/LogListener.java
trunk/common-core/src/main/java/com/metamatrix/core/log/LogMessage.java
trunk/common-internal/src/main/java/com/metamatrix/common/log/LogManager.java
trunk/common-internal/src/test/java/com/metamatrix/common/log/TestLogManager.java
trunk/connector-sdk/src/main/java/com/metamatrix/core/commandshell/CommandShell.java
trunk/embedded/pom.xml
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/DQPLogListener.java
trunk/embedded/src/main/java/com/metamatrix/jdbc/LogListernerProvider.java
trunk/engine/src/test/java/com/metamatrix/dqp/config/TestDQPLauncher.java
trunk/server/src/main/java/com/metamatrix/common/log/DbLogListener.java
trunk/server/src/main/java/com/metamatrix/common/log/DbLogWriter.java
trunk/server/src/main/java/com/metamatrix/server/FileLogListenerProvider.java
trunk/server/src/main/java/com/metamatrix/server/Main.java
trunk/server/src/main/java/com/metamatrix/server/ServerGuiceModule.java
trunk/soap/src/main/java/com/metamatrix/soap/servlet/MMDiscoverWSDLServlet.java
trunk/soap/src/main/java/com/metamatrix/soap/servlet/MMGetVDBResourceServlet.java
trunk/soap/src/main/java/com/metamatrix/soap/servlet/MMGetWSDLServlet.java
trunk/soap/src/main/java/com/metamatrix/soap/servlet/WSDLURLGenerator.java
trunk/soap/src/main/java/com/metamatrix/soap/sqlquerywebservice/log/LogUtil.java
Log:
TEIID-672: Removed the all the platform logging framework implementation, and supplied the Embedded with Log4J LogListener.
Deleted: trunk/common-core/src/main/java/com/metamatrix/core/log/FileLimitSizeLogWriter.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/core/log/FileLimitSizeLogWriter.java 2009-06-16 17:20:38 UTC (rev 1055)
+++ trunk/common-core/src/main/java/com/metamatrix/core/log/FileLimitSizeLogWriter.java 2009-06-16 18:05:22 UTC (rev 1056)
@@ -1,427 +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.core.log;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.Properties;
-import java.util.concurrent.locks.ReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-
-import com.metamatrix.core.CorePlugin;
-import com.metamatrix.core.util.FileUtils;
-import com.metamatrix.internal.core.log.PlatformLimitSizeLogWriter;
-
-/**
- * The FileLogWriter is a {@link LogListener} that writes (appends) to a supplied file.
- *
- */
-public class FileLimitSizeLogWriter implements LogListener {
-
- /**
- * The FILE_SIZE_LIMIT controls the file size limit at which the
- * file will rolled-over (i.e., when it closed and renamed due
- * to size). The default size limit will be 5 Mbs.
- * {@see #FILE_GROUP_NAME}
- */
- public static final String FILE_SIZE_LIMIT = "metamatrix.log.size.limit.kbs"; //$NON-NLS-1$
- /**
- * the FILE_SIZE_MONITOR_TIME interval is in minutes and
- * controls when the monitoring thread will determine if the
- * file has reach the
- * {@see #FILE_SIZE_LIMIT LIMIT} to be swapped out.
- */
- public static final String FILE_SIZE_MONITOR_TIME = "metamatrix.log.size.monitor.mins"; //$NON-NLS-1$
-
- /**
- * The ARCHIVE_PREFIX is a prefixed value to the renamed log file.
- * This is used so that the savelogs.cmd - .sh scripts can
- * find the archived files, zip them up and then delete
- */
- public static final String ARCHIVE_PREFIX = "a_"; //$NON-NLS-1$
-
- // defaults for the file size limit and interval
- private static final long DEFUALT_ROLLOVER_SIZE = 1000; // in kbs in size
- private static final int DEFAULT_WAIT_TIME = 60; // 60 secs or 1 min
-
- // these are the muliplier applied to the parameter values
- // for FILE_SIZE_LIMIT and FILE_SIZE_MONITOR_TIME
- private static final long SIZE_MULTIPLIER = 1000;
- private static final long MIN_MULTIPLIER = 60000;
-
- // the formatted date used in the naming of the
- // swapped out file
- public static final String TIMESTAMP_FORMAT = "yyyy-MM-dd_HH-mm"; //$NON-NLS-1$
-
- static DateFormat DATE_FORMATTER = new SimpleDateFormat(TIMESTAMP_FORMAT);
-
- // monitoring thread
- private FileSizeMonitorThread rollOverThread = null;
- // the primary log file written to
- private File currentLogFile = null;
- private PlatformLimitSizeLogWriter limitwriter = null;
-
-
- private String prefixName = null;
- private String suffixName = null;
- private File parentFile = null;
- private long filecnt = 1;
- private Properties props;
- // List locking
- private ReadWriteLock rwlock = new ReentrantReadWriteLock();
-
-
- public FileLimitSizeLogWriter( final File file ) {
- if (file == null) {
- final String msg = CorePlugin.Util.getString("FileLogWriter.The_File_reference_may_not_be_null"); //$NON-NLS-1$
- throw new IllegalArgumentException(msg);
- }
-
- currentLogFile = file;
- rolloverPreviousLogFile(currentLogFile);
- createPlatformLogWriter(currentLogFile) ;
- init();
- }
-
- // For use in DQP - allows the user to pass a parameter through to reset the System output streams
- public FileLimitSizeLogWriter( final File file, boolean resetSystemStreams) {
- if (file == null) {
- final String msg = CorePlugin.Util.getString("FileLogWriter.The_File_reference_may_not_be_null"); //$NON-NLS-1$
- throw new IllegalArgumentException(msg);
- }
-
- currentLogFile = file;
- rolloverPreviousLogFile(currentLogFile);
- createPlatformLogWriter(currentLogFile, resetSystemStreams) ;
- init();
- }
-
- public FileLimitSizeLogWriter( final File file, Properties properties ) {
- if (file == null) {
- final String msg = CorePlugin.Util.getString("FileLogWriter.The_File_reference_may_not_be_null"); //$NON-NLS-1$
- throw new IllegalArgumentException(msg);
- }
- props = properties;
- currentLogFile = file;
- rolloverPreviousLogFile(currentLogFile);
- createPlatformLogWriter(currentLogFile) ;
- init();
- }
-
- public FileLimitSizeLogWriter( final File file, Properties properties, boolean rollover ) {
- if (file == null) {
- final String msg = CorePlugin.Util.getString("FileLogWriter.The_File_reference_may_not_be_null"); //$NON-NLS-1$
- throw new IllegalArgumentException(msg);
- }
- props = properties;
- currentLogFile = file;
- if (rollover) {
- rolloverPreviousLogFile(currentLogFile);
- }
- createPlatformLogWriter(currentLogFile) ;
- init();
- }
-
- /**
- * initialize the variables used to keep track and
- * assign the next log file name
- *
- */
- private void init() {
-
- parentFile = currentLogFile.getParentFile();
- String name = currentLogFile.getName();
-
- int pos = name.lastIndexOf(PERIOD);
- String first = null;
- String ext = null;
- String period = EMPTY;
- if (pos > 0) {
- ext = name.substring(pos + 1);
- first = name.substring(0, pos);
- period = PERIOD;
- } else {
- first = name;
- ext = EMPTY;
- }
- long fileSizeLimit = DEFUALT_ROLLOVER_SIZE;
- long timeLimit = DEFAULT_WAIT_TIME;
- if (props != null) {
-
- String limit = props.getProperty(FILE_SIZE_LIMIT);
- try {
- if (limit != null) {
- fileSizeLimit = Long.parseLong(limit);
- }
- } catch(Throwable t) {
- fileSizeLimit = DEFUALT_ROLLOVER_SIZE;
- }
-
- String time = props.getProperty(FILE_SIZE_MONITOR_TIME);
- try {
- if (time != null) {
- timeLimit = Long.parseLong(time);
- }
- } catch(Throwable t) {
- timeLimit = DEFAULT_WAIT_TIME;
- }
- }
-
- prefixName = first;
-
- StringBuffer suffix = new StringBuffer(period);
- suffix.append(ext);
- suffixName = suffix.toString();
-
- rollOverThread = new FileSizeMonitorThread(fileSizeLimit, timeLimit, this );
- rollOverThread.start();
-
- }
-
-
- protected File getLogFile() {
- return this.currentLogFile;
- }
-
-
- protected void createPlatformLogWriter(File file) {
- limitwriter = new PlatformLimitSizeLogWriter(file);
- }
-
- protected void createPlatformLogWriter(File file, boolean resetSystemStreams) {
- limitwriter = new PlatformLimitSizeLogWriter(file, resetSystemStreams);
- }
-
- protected PlatformLimitSizeLogWriter getPlatformLogWriter() {
- return this.limitwriter;
- }
-
-
- public void logMessage(LogMessage msg) {
- rwlock.readLock().lock();
- try {
- if (getPlatformLogWriter() != null) {
- getPlatformLogWriter().logMessage(msg);
- }
-
- } finally {
- rwlock.readLock().unlock();
- }
- }
- /**
- * perform the file rollover process
- *
- */
- protected void performRollOver() {
- rwlock.writeLock().lock();
- try {
- File rf = getNextRolloverFile();
- rolloverFile(rf);
-
- } finally {
- rwlock.writeLock().unlock();
- }
-
- }
-
- /**
- * Close the stream to the file.
- */
- public void shutdown() {
- rollOverThread.stopThread();
- if (limitwriter != null) {
- limitwriter.shutdown();
- }
- limitwriter = null;
- }
-
- private static final String PERIOD = "."; //$NON-NLS-1$
- private static final String UNDERSCORE = "_"; //$NON-NLS-1$
- private static final String EMPTY = ""; //$NON-NLS-1$
-
- /**
- * create the name to call the newly created swapped file
- * @return
- */
-
- private File getNextRolloverFile() {
-
-// String mmdd = FileLimitSizeLogWriter.getDate();
-//
-// StringBuffer fileName = new StringBuffer(ARCHIVE_PREFIX);
-// fileName.append(prefixName);
-// fileName.append(mmdd);
-// fileName.append(UNDERSCORE);
-//
-// fileName.append(filecnt);
-// fileName.append(suffixName);
-
- String suffix = String.valueOf(filecnt) + suffixName;
- String archiveName = buildArchiveFileName(prefixName, suffix);
- File f = new File(parentFile, archiveName);
-
- ++filecnt;
- if (f.exists()) {
- return getNextRolloverFile();
- }
-
- return f;
-
- }
-
-
- // This only occurs at the creation of the log file. We check to see if a log file from a
- // previous execution exist and we roll it over.
- private void rolloverPreviousLogFile(File logFile) {
- if (logFile.exists()) {
- String path = logFile.getAbsolutePath();
- String logFileName = logFile.getName();
- path = path.substring(0, path.indexOf(logFileName));
- int index = logFileName.lastIndexOf("."); //$NON-NLS-1$
- String logFile_begin = logFileName.substring(0, index);
- String logFile_end = logFileName.substring(index);
-
- String archiveName = buildArchiveFileName(logFile_begin, logFile_end);
-
- // tmpFile.renameTo(new File(logFile_begin + logFile_date + logFile_end));
- logFile.renameTo(new File(path+archiveName));
- }
- }
-
- protected void rolloverFile(final File rollToFile) {
-
- try {
-
- if (this.getPlatformLogWriter() != null) {
- this.getPlatformLogWriter().shutdown();
- }
-
- FileInputStream fis = null;
- try {
-
- fis = new FileInputStream(currentLogFile);
- FileUtils.write(fis, rollToFile);
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- fis.close();
- }
-
- boolean deleted = currentLogFile.delete();
- if (!deleted) {
- Exception e = new Exception("File " + currentLogFile + " was not DELETED"); //$NON-NLS-1$ //$NON-NLS-2$
- e.printStackTrace();
- }
- createPlatformLogWriter(this.currentLogFile);
-
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- public static String buildArchiveFileName(String prefix, String suffix) {
- String mmdd = FileLimitSizeLogWriter.getDate();
-
- StringBuffer fileName = new StringBuffer(ARCHIVE_PREFIX);
- fileName.append(prefix);
- fileName.append(mmdd);
- fileName.append(UNDERSCORE);
-
- fileName.append(suffix);
- return fileName.toString();
- }
-
- public synchronized static String getDate( ) {
- try {
- Date d = Calendar.getInstance().getTime();
- return DATE_FORMATTER.format(d);
- } catch (Exception e) {
- return ""; //$NON-NLS-1$
- // If there were problems writing out the date, ignore and
- // continue since that shouldn't stop us from losing the rest
- // of the information
- }
- }
-
-
- class FileSizeMonitorThread extends Thread
- {
- private volatile boolean go = true;
- private FileLimitSizeLogWriter writer;
- private long max;
- private long time;
-
-
-
- public FileSizeMonitorThread(long maxSize, long waitTime, FileLimitSizeLogWriter logwriter )
- {
- super("LogFileSizeMonitor"); //$NON-NLS-1$
- writer = logwriter;
- max = maxSize;
- time = waitTime;
- this.setDaemon(true);
- }
-
- public void run()
- {
- long max_size = max * SIZE_MULTIPLIER;
- long monitor_time = time * MIN_MULTIPLIER;
-
- while (go) {
- try {
- Thread.sleep(monitor_time);
- }catch(Exception e) {
-
- }
- try {
- File f = writer.getLogFile();
- if (f != null && f.exists()) {
- long l = f.length();
- if (l >= (max_size)) {
-// System.out.println("Rollever, size : " + l + " max: " + max);
-
- writer.performRollOver();
- } else {
-// System.out.println("NO Rollever, size not big enough: " + l + " max: " + max);
-
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- System.out.println(CorePlugin.Util.getString("FileLimitSizeLogWriter.Error_Checking_logwriter_rollover__10") + e.getMessage()); //$NON-NLS-1$
- }
- }
- }
-
- public void stopThread() {
- go = false;
- this.interrupt();
- }
- }
-
-}
Deleted: trunk/common-core/src/main/java/com/metamatrix/core/log/FileLogWriter.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/core/log/FileLogWriter.java 2009-06-16 17:20:38 UTC (rev 1055)
+++ trunk/common-core/src/main/java/com/metamatrix/core/log/FileLogWriter.java 2009-06-16 18:05:22 UTC (rev 1056)
@@ -1,65 +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.core.log;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-
-import com.metamatrix.core.CorePlugin;
-import com.metamatrix.internal.core.log.PlatformLogWriter;
-
-/**
- * The FileLogWriter is a {@link LogListener} that writes (appends) to a supplied file.
- */
-public class FileLogWriter implements LogListener {
-
- private PlatformLogWriter writer;
-
- public FileLogWriter( final File file ) {
- if (file == null) {
- final String msg = CorePlugin.Util.getString("FileLogWriter.The_File_reference_may_not_be_null"); //$NON-NLS-1$
- throw new IllegalArgumentException(msg);
- }
-
- try {
- OutputStream destination = new FileOutputStream(file.getAbsolutePath(), true);
- this.writer = new PlatformLogWriter(destination, destination);
- } catch (IOException e) {
- this.writer = new PlatformLogWriter(System.err, System.err);
- }
- }
-
- public void logMessage(LogMessage msg) {
- this.writer.logMessage(msg);
- }
-
- /**
- * Close the stream to the file.
- */
- public void shutdown() {
- this.writer.shutdown();
- }
-
-}
Modified: trunk/common-core/src/main/java/com/metamatrix/core/log/JavaLogWriter.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/core/log/JavaLogWriter.java 2009-06-16 17:20:38 UTC (rev 1055)
+++ trunk/common-core/src/main/java/com/metamatrix/core/log/JavaLogWriter.java 2009-06-16 18:05:22 UTC (rev 1056)
@@ -30,11 +30,17 @@
*/
public class JavaLogWriter implements LogListener {
- public void logMessage(LogMessage msg) {
- Logger logger = Logger.getLogger("org.teiid." + msg.getContext()); //$NON-NLS-1$
- Level level = convertLevel(msg.getLevel());
- if (logger.isLoggable(level)) {
- logger.log(level, msg.getText(), msg.getException());
+ public void logMessage(int level, String context, Object msg) {
+ Logger logger = Logger.getLogger("org.teiid." + context); //$NON-NLS-1$
+
+ Level javaLevel = convertLevel(level);
+ if (logger.isLoggable(javaLevel)) {
+ if (msg instanceof LogMessage) {
+ logger.log(javaLevel, ((LogMessage)msg).getText(), ((LogMessage)msg).getException());
+ }
+ else {
+ logger.log(javaLevel, msg.toString());
+ }
}
}
Modified: trunk/common-core/src/main/java/com/metamatrix/core/log/LogListener.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/core/log/LogListener.java 2009-06-16 17:20:38 UTC (rev 1055)
+++ trunk/common-core/src/main/java/com/metamatrix/core/log/LogListener.java 2009-06-16 18:05:22 UTC (rev 1056)
@@ -36,7 +36,7 @@
* @param pluginID the identifier of the plugin that submitted the log message
* @param threadName the name of the thread upon which the message was created
*/
- void logMessage(LogMessage msg);
+ void logMessage(int level, String context, Object msg);
/**
* Shut down this listener, requesting it clean up and release any resources it
Modified: trunk/common-core/src/main/java/com/metamatrix/core/log/LogMessage.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/core/log/LogMessage.java 2009-06-16 17:20:38 UTC (rev 1055)
+++ trunk/common-core/src/main/java/com/metamatrix/core/log/LogMessage.java 2009-06-16 18:05:22 UTC (rev 1056)
@@ -27,59 +27,15 @@
public class LogMessage implements Serializable{
- private String context;
- private int level;
private Object[] msgParts;
private Throwable exception;
- private long timestamp;
- private String threadName;
- private int errorCode;
- public LogMessage() {
- }
- public LogMessage(String context, int level, Object[] msgParts ) {
- this.context = context;
- this.level = level;
- this.msgParts = msgParts;
- this.timestamp = System.currentTimeMillis();
- this.threadName = Thread.currentThread().getName();
- }
-
- public LogMessage(String context, int level, Throwable e, Object[] msgParts) {
- this(context, level, msgParts);
+ public LogMessage(Throwable e, Object[] msgParts) {
+ this.msgParts = msgParts;
this.exception = e;
}
-
- public LogMessage(String context, int level, Throwable e, Object[] msgParts, int errorCode) {
- this(context, level, msgParts);
- this.exception = e;
- this.errorCode = errorCode;
- }
-
- public LogMessage(String context, int level, Throwable e, Object[] msgParts, String threadname ) {
- this(context, level, msgParts);
- this.exception = e;
- this.threadName = threadname;
- }
-
- public String getContext() {
- return this.context;
- }
-
- public int getLevel() {
- return this.level;
- }
-
- public String getThreadName() {
- return this.threadName;
- }
-
- public long getTimestamp() {
- return this.timestamp;
- }
-
public Throwable getException() {
return this.exception;
}
@@ -106,11 +62,8 @@
}
return text.toString();
}
-
- /**
- * @return Returns the errorCode.
- */
- public int getErrorCode() {
- return this.errorCode;
- }
+
+ public String toString() {
+ return getText();
+ }
}
Deleted: trunk/common-core/src/main/java/com/metamatrix/core/log/NullLogger.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/core/log/NullLogger.java 2009-06-16 17:20:38 UTC (rev 1055)
+++ trunk/common-core/src/main/java/com/metamatrix/core/log/NullLogger.java 2009-06-16 18:05:22 UTC (rev 1056)
@@ -1,46 +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.core.log;
-
-
-/**
- * Implementation of {@link Logger} that does nothing. An instance of this class is often useful
- * when a reference to a {@link Logger} is always expected to be non-null, but no logging is desired.
- */
-public class NullLogger implements Logger {
-
- /**
- * @see com.metamatrix.core.log.Logger#log(int, java.lang.String)
- */
- public void log(int severity, String message) {
-
- }
-
- /**
- * @see com.metamatrix.core.log.Logger#log(int, java.lang.Throwable, java.lang.String)
- */
- public void log(int severity, Throwable t, String message) {
-
- }
-
-}
Deleted: trunk/common-core/src/main/java/com/metamatrix/core/log/SystemLogWriter.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/core/log/SystemLogWriter.java 2009-06-16 17:20:38 UTC (rev 1055)
+++ trunk/common-core/src/main/java/com/metamatrix/core/log/SystemLogWriter.java 2009-06-16 18:05:22 UTC (rev 1056)
@@ -1,53 +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.core.log;
-
-import com.metamatrix.internal.core.log.PlatformLogWriter;
-
-/**
- * The SystemLogWriter is a {@link LogListener} that writes error log messages to System.err and other log
- * messages to System.out.
- */
-public class SystemLogWriter implements LogListener {
-
- private PlatformLogWriter writer;
-
- public SystemLogWriter() {
- this.writer = new PlatformLogWriter(System.out,System.err);
- }
-
- /* (non-Javadoc)
- * @see com.metamatrix.core.log.LogListener#logMessage(org.eclipse.core.runtime.IStatus, long, java.lang.String, java.lang.String)
- */
- public void logMessage(LogMessage msg) {
- this.writer.logMessage(msg);
- }
-
- /**
- * Close the stream to the file.
- */
- public void shutdown() {
- this.writer.shutdown();
- }
-
-}
Modified: trunk/common-internal/src/main/java/com/metamatrix/common/log/LogManager.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/log/LogManager.java 2009-06-16 17:20:38 UTC (rev 1055)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/log/LogManager.java 2009-06-16 18:05:22 UTC (rev 1056)
@@ -296,7 +296,7 @@
* not logged if this parameter is null
*/
public static void log(int msgLevel, String context, Object message) {
- logMessage(msgLevel, context, message);
+ logListener.logMessage(msgLevel, context, message);
}
/**
@@ -366,8 +366,8 @@
return;
}
- LogMessage msg = new LogMessage( context, level, e, msgParts);
- logListener.logMessage(msg);
+ LogMessage msg = new LogMessage(e, msgParts);
+ logListener.logMessage(level, context, msg);
}
Modified: trunk/common-internal/src/test/java/com/metamatrix/common/log/TestLogManager.java
===================================================================
--- trunk/common-internal/src/test/java/com/metamatrix/common/log/TestLogManager.java 2009-06-16 17:20:38 UTC (rev 1055)
+++ trunk/common-internal/src/test/java/com/metamatrix/common/log/TestLogManager.java 2009-06-16 18:05:22 UTC (rev 1056)
@@ -32,7 +32,6 @@
import com.metamatrix.core.log.LogListener;
import com.metamatrix.core.log.LogMessage;
import com.metamatrix.core.log.MessageLevel;
-import com.metamatrix.internal.core.log.PlatformLog;
/**
* This test case tests the LogManager.
@@ -50,8 +49,6 @@
@Override
protected void setUp() throws Exception {
LogManager.configuration = new BasicLogConfiguration();
- LogManager.logListener = new PlatformLog();
-
}
// =========================================================================
@@ -117,8 +114,8 @@
/* (non-Javadoc)
* @see com.metamatrix.core.log.LogListener#logMessage(org.eclipse.core.runtime.IStatus, long, java.lang.String, java.lang.String)
*/
- public synchronized void logMessage(LogMessage msg){
- this.messages.add(msg.getText());
+ public synchronized void logMessage(int level, String context, Object msg){
+ this.messages.add(((LogMessage)msg).getText());
if (this.messages.size() == expectedMessages) {
this.notifyAll();
}
Modified: trunk/connector-sdk/src/main/java/com/metamatrix/core/commandshell/CommandShell.java
===================================================================
--- trunk/connector-sdk/src/main/java/com/metamatrix/core/commandshell/CommandShell.java 2009-06-16 17:20:38 UTC (rev 1055)
+++ trunk/connector-sdk/src/main/java/com/metamatrix/core/commandshell/CommandShell.java 2009-06-16 18:05:22 UTC (rev 1056)
@@ -23,7 +23,6 @@
package com.metamatrix.core.commandshell;
import java.io.BufferedReader;
-import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Method;
@@ -34,14 +33,11 @@
import java.util.Set;
import java.util.Stack;
-import com.metamatrix.common.log.LogManager;
import com.metamatrix.core.CorePlugin;
import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.core.log.FileLogWriter;
import com.metamatrix.core.util.FileUtil;
import com.metamatrix.core.util.MetaMatrixExceptionUtil;
import com.metamatrix.core.util.StringUtil;
-import com.metamatrix.internal.core.log.PlatformLog;
/**
* Reads input from standard input and directs commands read to the underlying target object.
@@ -110,9 +106,7 @@
* Start reading commands from standard input.
*/
public void run(String[] args, String logFile) {
- redirectLogging(logFile);
-
writeln(CorePlugin.Util.getString("CommandShell.Started")); //$NON-NLS-1$
write(getCommandPrompt());
if (args.length == 0) {
@@ -137,19 +131,7 @@
writeln(CorePlugin.Util.getString("CommandShell.Finished")); //$NON-NLS-1$
}
-
- private void redirectLogging(String logFile) {
- //add a listener that writes to a file
- File file = new File(logFile);
- FileLogWriter flw = new FileLogWriter(file);
-
- PlatformLog logger = new PlatformLog();
- logger.addListener(flw);
- LogManager.setLogListener(logger);
- }
-
-
-
+
public void writeln(String text) {
if (!silent) {
System.out.println(text);
Modified: trunk/embedded/pom.xml
===================================================================
--- trunk/embedded/pom.xml 2009-06-16 17:20:38 UTC (rev 1055)
+++ trunk/embedded/pom.xml 2009-06-16 18:05:22 UTC (rev 1056)
@@ -61,5 +61,9 @@
<groupId>com.google.code.guice</groupId>
<artifactId>guice</artifactId>
</dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
Modified: trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/DQPLogListener.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/DQPLogListener.java 2009-06-16 17:20:38 UTC (rev 1055)
+++ trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/DQPLogListener.java 2009-06-16 18:05:22 UTC (rev 1056)
@@ -36,11 +36,11 @@
this.logger = logger;
}
- public void logMessage(LogMessage msg) {
+ public void logMessage(int level, String context, Object msg) {
int logLevel = EmbeddedLogger.INFO;
- switch(msg.getLevel()) {
+ switch(level) {
case MessageLevel.WARNING:
logLevel = EmbeddedLogger.WARNING;
break;
@@ -60,7 +60,14 @@
default:
logLevel = EmbeddedLogger.INFO;
}
- logger.log(logLevel, msg.getTimestamp(), msg.getContext(), msg.getThreadName(), msg.getText(), msg.getException());
+
+ if (msg instanceof LogMessage) {
+ LogMessage lm = (LogMessage)msg;
+ logger.log(logLevel, System.currentTimeMillis(), context, Thread.currentThread().getName(), lm.getText(), lm.getException());
+ }
+ else {
+ logger.log(logLevel, System.currentTimeMillis(), context, Thread.currentThread().getName(), msg.toString(), null);
+ }
}
public void shutdown() {
Modified: trunk/embedded/src/main/java/com/metamatrix/jdbc/LogListernerProvider.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/jdbc/LogListernerProvider.java 2009-06-16 17:20:38 UTC (rev 1055)
+++ trunk/embedded/src/main/java/com/metamatrix/jdbc/LogListernerProvider.java 2009-06-16 18:05:22 UTC (rev 1056)
@@ -22,10 +22,12 @@
package com.metamatrix.jdbc;
-import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
+import org.apache.log4j.Logger;
+import org.apache.log4j.Priority;
+
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
@@ -33,11 +35,10 @@
import com.metamatrix.common.application.DQPConfigSource;
import com.metamatrix.common.protocol.URLHelper;
import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.core.log.FileLimitSizeLogWriter;
import com.metamatrix.core.log.JavaLogWriter;
import com.metamatrix.core.log.LogListener;
+import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
-import com.metamatrix.internal.core.log.PlatformLog;
@Singleton
class LogListernerProvider implements Provider<LogListener> {
@@ -66,10 +67,12 @@
modifiedLogFileName = logFile+"_"+instanceId; //$NON-NLS-1$
}
URL logURL = URLHelper.buildURL(dqpURL, modifiedLogFileName);
- File file = new File(logURL.getPath());
- PlatformLog log = new PlatformLog();
- log.addListener(new FileLimitSizeLogWriter(file, false));
- return log;
+
+ // TODO: The Log4j File appender needs to be created with the above name
+ // since we do not have handle on the Log4J configuration we come back to this issue.
+ // until then just manage on the properties file.
+ System.setProperty("dqp.log4jFile", logURL.getPath()); //$NON-NLS-1$ // hack
+ return new Log4jListener();
}
return new JavaLogWriter();
} catch (MalformedURLException e) {
@@ -77,4 +80,36 @@
}
}
+ /**
+ * Log4J Listener
+ */
+ static class Log4jListener implements LogListener{
+
+ @Override
+ public void logMessage(int level, String context, Object msg) {
+ Logger log4j = Logger.getLogger("org.teiid."+context); //$NON-NLS-1$
+ log4j.log(convertLevel(level), msg);
+ }
+
+ @Override
+ public void shutdown() {
+ }
+
+ public Priority convertLevel(int level) {
+ switch (level) {
+ case MessageLevel.CRITICAL:
+ return Priority.FATAL;
+ case MessageLevel.ERROR:
+ return Priority.ERROR;
+ case MessageLevel.WARNING:
+ return Priority.WARN;
+ case MessageLevel.INFO:
+ return Priority.INFO;
+ case MessageLevel.DETAIL:
+ case MessageLevel.TRACE:
+ return Priority.DEBUG;
+ }
+ return Priority.DEBUG;
+ }
+ }
}
Modified: trunk/engine/src/test/java/com/metamatrix/dqp/config/TestDQPLauncher.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/config/TestDQPLauncher.java 2009-06-16 17:20:38 UTC (rev 1055)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/config/TestDQPLauncher.java 2009-06-16 18:05:22 UTC (rev 1056)
@@ -23,7 +23,6 @@
package com.metamatrix.dqp.config;
import java.util.HashMap;
-import java.util.List;
import java.util.Properties;
import junit.framework.TestCase;
@@ -33,13 +32,11 @@
import com.metamatrix.common.application.ApplicationService;
import com.metamatrix.common.application.DQPConfigSource;
-import com.metamatrix.core.log.LogListener;
import com.metamatrix.dqp.service.AutoGenDataService;
import com.metamatrix.dqp.service.DQPServiceNames;
import com.metamatrix.dqp.service.FakeAbstractService;
import com.metamatrix.dqp.service.FakeBufferService;
import com.metamatrix.dqp.service.FakeMetadataService;
-import com.metamatrix.internal.core.log.PlatformLog;
/**
*/
@@ -66,12 +63,6 @@
DQPCore dqpCore = new DQPCore();
dqpCore.start(configSource);
- PlatformLog log = new PlatformLog();
- List<LogListener> list = log.getLogListeners();
- for(LogListener l: list) {
- log.removeListener(l);
- }
-
DQPCore dqp = new DQPCore();
dqp.start(configSource);
assertNotNull("DQP should not be null", dqp); //$NON-NLS-1$
Modified: trunk/server/src/main/java/com/metamatrix/common/log/DbLogListener.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/log/DbLogListener.java 2009-06-16 17:20:38 UTC (rev 1055)
+++ trunk/server/src/main/java/com/metamatrix/common/log/DbLogListener.java 2009-06-16 18:05:22 UTC (rev 1056)
@@ -49,9 +49,9 @@
this.enabled = enable;
}
- public void logMessage(LogMessage msg) {
+ public void logMessage(int level, String context, Object msg) {
if (enabled) {
- writer.logMessage(msg);
+ writer.logMessage(level, context, (LogMessage)msg);
}
}
Modified: trunk/server/src/main/java/com/metamatrix/common/log/DbLogWriter.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/log/DbLogWriter.java 2009-06-16 17:20:38 UTC (rev 1055)
+++ trunk/server/src/main/java/com/metamatrix/common/log/DbLogWriter.java 2009-06-16 18:05:22 UTC (rev 1056)
@@ -245,11 +245,11 @@
}
- public synchronized void logMessage(LogMessage msg) {
- write(msg);
+ public synchronized void logMessage(int level, String context,LogMessage msg) {
+ write(level, context, msg);
}
- private void write(LogMessage message) {
+ private void write(int level, String context, LogMessage message) {
// put this in a while to so that as long a
int retrycnt = 0;
if (isLogSuspended && System.currentTimeMillis() > resumeTime) {
@@ -257,7 +257,7 @@
}
while (!isLogSuspended && !shutdown) {
try {
- printMsg(message);
+ printMsg(level, context, message);
return;
} catch (Exception ex) {
@@ -301,12 +301,12 @@
return this.insert;
}
- private void printMsg(LogMessage message) throws SQLException {
+ private void printMsg(int level, String context, LogMessage message) throws SQLException {
if (this.shutdown) {
return;
}
- long msgTimeStamp = message.getTimestamp();
+ long msgTimeStamp = System.currentTimeMillis();
if (lastSequenceStart != msgTimeStamp) {
lastSequenceStart = msgTimeStamp;
sequenceNumber = 0;
@@ -326,10 +326,10 @@
stmt.setShort(2, sequenceNumber);
// Message context column
- stmt.setString(3, StringUtil.truncString(message.getContext(), maxGeneralLength));
+ stmt.setString(3, StringUtil.truncString(context, maxGeneralLength));
// Message type column
- stmt.setInt(4, message.getLevel());
+ stmt.setInt(4, level);
// Message text column
stmt.setString(5, StringUtil.truncString(message.getText(), maxMsgLength));
@@ -341,7 +341,7 @@
stmt.setString(7, StringUtil.truncString(CurrentConfiguration.getInstance().getProcessName(), maxGeneralLength));
// Message thread name column
- stmt.setString(8, StringUtil.truncString(message.getThreadName(), maxGeneralLength));
+ stmt.setString(8, StringUtil.truncString(Thread.currentThread().getName(), maxGeneralLength));
// Exception column
if(message.getException() != null) {
Modified: trunk/server/src/main/java/com/metamatrix/server/FileLogListenerProvider.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/FileLogListenerProvider.java 2009-06-16 17:20:38 UTC (rev 1055)
+++ trunk/server/src/main/java/com/metamatrix/server/FileLogListenerProvider.java 2009-06-16 18:05:22 UTC (rev 1056)
@@ -22,20 +22,11 @@
package com.metamatrix.server;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.PrintStream;
-import java.util.Properties;
-
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.name.Named;
-import com.metamatrix.common.config.CurrentConfiguration;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.core.log.FileLimitSizeLogWriter;
+import com.metamatrix.core.log.JavaLogWriter;
import com.metamatrix.core.log.LogListener;
-import com.metamatrix.internal.core.log.PlatformLog;
public class FileLogListenerProvider implements Provider<LogListener> {
@@ -49,45 +40,8 @@
@Override
public LogListener get() {
- final PlatformLog log = new PlatformLog();
- try {
- FileLimitSizeLogWriter flw = buildFileLogger();
- log.addListener(flw);
- } catch (FileNotFoundException e) {
- throw new MetaMatrixRuntimeException(e);
- }
- return log;
+ return new JavaLogWriter();
}
- FileLimitSizeLogWriter buildFileLogger() throws FileNotFoundException {
- File tmpFile = new File(path, logFile);
- tmpFile.getParentFile().mkdirs();
-
- // if log file exists then create a archive
- if (tmpFile.exists()) {
- int index = logFile.lastIndexOf("."); //$NON-NLS-1$
- String archiveName = FileLimitSizeLogWriter.buildArchiveFileName(logFile.substring(0, index), logFile.substring(index));
- tmpFile.renameTo(new File(path, archiveName));
- }
-
- FileOutputStream fos = new FileOutputStream(tmpFile);
- PrintStream ps = new PrintStream(fos);
-
- System.setOut(ps);
- System.setErr(ps);
-
- Properties logProps = new Properties();
- Properties configProps = CurrentConfiguration.getInstance().getProperties();
- if (configProps.containsKey(FileLimitSizeLogWriter.FILE_SIZE_LIMIT)) {
- logProps.setProperty(FileLimitSizeLogWriter.FILE_SIZE_LIMIT,configProps.getProperty(FileLimitSizeLogWriter.FILE_SIZE_LIMIT));
- }
- if (configProps.containsKey(FileLimitSizeLogWriter.FILE_SIZE_MONITOR_TIME)) {
- logProps.setProperty(FileLimitSizeLogWriter.FILE_SIZE_MONITOR_TIME,configProps.getProperty(FileLimitSizeLogWriter.FILE_SIZE_MONITOR_TIME));
- }
-
- FileLimitSizeLogWriter flw = new FileLimitSizeLogWriter(tmpFile,logProps, false);
- return flw;
- }
-
}
Modified: trunk/server/src/main/java/com/metamatrix/server/Main.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/Main.java 2009-06-16 17:20:38 UTC (rev 1055)
+++ trunk/server/src/main/java/com/metamatrix/server/Main.java 2009-06-16 18:05:22 UTC (rev 1056)
@@ -26,6 +26,7 @@
import java.io.FilenameFilter;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Date;
import com.google.inject.Guice;
import com.google.inject.Inject;
@@ -36,7 +37,6 @@
import com.metamatrix.common.config.api.exceptions.ConfigurationException;
import com.metamatrix.common.messaging.MessageBus;
import com.metamatrix.common.messaging.MessagingException;
-import com.metamatrix.core.log.FileLimitSizeLogWriter;
import com.metamatrix.core.log.LogListener;
import com.metamatrix.core.util.FileUtils;
import com.metamatrix.core.util.StringUtil;
@@ -151,7 +151,7 @@
String configDir = host.getConfigDirectory();
File f = new File(configDir);
f.mkdirs();
- FilePersistentUtil.writeModel(CONFIG_PREFIX+FileLimitSizeLogWriter.getDate()+".xml", configDir, //$NON-NLS-1$
+ FilePersistentUtil.writeModel(CONFIG_PREFIX+new Date().toString()+".xml", configDir, //$NON-NLS-1$
CurrentConfiguration.getInstance().getConfigurationModel(),
processName);
//remove old instances
Modified: trunk/server/src/main/java/com/metamatrix/server/ServerGuiceModule.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/ServerGuiceModule.java 2009-06-16 17:20:38 UTC (rev 1055)
+++ trunk/server/src/main/java/com/metamatrix/server/ServerGuiceModule.java 2009-06-16 18:05:22 UTC (rev 1056)
@@ -98,7 +98,7 @@
// Start the log file
bind(LogConfiguration.class).toProvider(LogConfigurationProvider.class).in(Scopes.SINGLETON);
- bind(LogListener.class).toProvider(ServerLogListernerProvider.class).in(Scopes.SINGLETON);
+ bind(LogListener.class).toProvider(FileLogListenerProvider.class).in(Scopes.SINGLETON);
// this needs to be removed.
binder().requestStaticInjection(LogManager.class);
Deleted: trunk/server/src/main/java/com/metamatrix/server/ServerLogListernerProvider.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/ServerLogListernerProvider.java 2009-06-16 17:20:38 UTC (rev 1055)
+++ trunk/server/src/main/java/com/metamatrix/server/ServerLogListernerProvider.java 2009-06-16 18:05:22 UTC (rev 1056)
@@ -1,103 +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.server;
-
-import java.io.FileNotFoundException;
-import java.util.EventObject;
-import java.util.Properties;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import com.metamatrix.common.config.CurrentConfiguration;
-import com.metamatrix.common.config.api.Configuration;
-import com.metamatrix.common.config.api.exceptions.ConfigurationException;
-import com.metamatrix.common.log.DbLogListener;
-import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.messaging.MessageBus;
-import com.metamatrix.common.messaging.MessagingException;
-import com.metamatrix.common.util.LogContextsUtil;
-import com.metamatrix.common.util.PropertiesUtils;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.core.event.EventObjectListener;
-import com.metamatrix.core.log.FileLimitSizeLogWriter;
-import com.metamatrix.core.log.LogListener;
-import com.metamatrix.internal.core.log.PlatformLog;
-import com.metamatrix.platform.config.event.ConfigurationChangeEvent;
-
- at Singleton
-class ServerLogListernerProvider extends FileLogListenerProvider {
- public static final String LOG_DB_ENABLED = "metamatrix.log.jdbcDatabase.enabled"; //$NON-NLS-1$
-
- @Inject
- MessageBus messsgeBus;
-
- @Override
- public LogListener get() {
-
- final PlatformLog log = new PlatformLog();
-
- try {
- FileLimitSizeLogWriter flw = buildFileLogger();
- log.addListener(flw);
-
- } catch (FileNotFoundException e) {
- throw new MetaMatrixRuntimeException(e);
- }
-
- final DbLogListener dbLogger = buildDBLogger();
- log.addListener(dbLogger);
-
- try {
-
- this.messsgeBus.addListener(ConfigurationChangeEvent.class, new EventObjectListener() {
-
- public void processEvent(EventObject obj) {
- if(obj instanceof ConfigurationChangeEvent){
- if(obj instanceof ConfigurationChangeEvent){
- try {
- Configuration currentConfig = CurrentConfiguration.getInstance().getConfiguration();
- Properties props = currentConfig.getProperties();
- boolean enabled = PropertiesUtils.getBooleanProperty(props, LOG_DB_ENABLED, true);
- dbLogger.enableDBLogging(enabled);
- } catch( ConfigurationException ce ) {
- LogManager.logError(LogContextsUtil.CommonConstants.CTX_MESSAGE_BUS, ce, ce.getMessage());
- }
- }
- }
- }
- });
-
- } catch (MessagingException e) {
- throw new MetaMatrixRuntimeException(e);
- }
- return log;
- }
-
- private DbLogListener buildDBLogger() {
- Properties currentProps = CurrentConfiguration.getInstance().getProperties();
- Properties resultsProps = PropertiesUtils.clone(currentProps, null, true, false);
- boolean enabled = PropertiesUtils.getBooleanProperty(resultsProps, LOG_DB_ENABLED, true);
- return new DbLogListener(resultsProps, enabled);
- }
-
-}
Deleted: trunk/soap/src/main/java/com/metamatrix/soap/log/MMSOAPLog.java
===================================================================
--- trunk/soap/src/main/java/com/metamatrix/soap/log/MMSOAPLog.java 2009-06-16 17:20:38 UTC (rev 1055)
+++ trunk/soap/src/main/java/com/metamatrix/soap/log/MMSOAPLog.java 2009-06-16 18:05:22 UTC (rev 1056)
@@ -1,50 +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.soap.log;
-
-import com.metamatrix.core.log.LogMessage;
-import com.metamatrix.core.log.Logger;
-import com.metamatrix.internal.core.log.PlatformLog;
-
-/**
- * MMSOAPLog
- */
-public class MMSOAPLog implements Logger
-{
- private String context;
- private PlatformLog log;
-
- public MMSOAPLog(String context, PlatformLog log) {
- this.context = context;
- this.log = log;
- }
-
- public void log(int severity, String message) {
- log.logMessage(new LogMessage(context, severity, new Object[] {message}));
- }
-
- public void log(int severity, Throwable t, String message) {
- log.logMessage(new LogMessage(context, severity, t, new Object[] {message}));
- }
-
-}
Modified: trunk/soap/src/main/java/com/metamatrix/soap/servlet/MMDiscoverWSDLServlet.java
===================================================================
--- trunk/soap/src/main/java/com/metamatrix/soap/servlet/MMDiscoverWSDLServlet.java 2009-06-16 17:20:38 UTC (rev 1055)
+++ trunk/soap/src/main/java/com/metamatrix/soap/servlet/MMDiscoverWSDLServlet.java 2009-06-16 18:05:22 UTC (rev 1056)
@@ -22,26 +22,21 @@
package com.metamatrix.soap.servlet;
-import java.io.File;
-import java.io.IOException;
-import java.util.List;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.List;
-import org.apache.log4j.Logger;
-
-import com.metamatrix.admin.api.exception.AdminException;
-import com.metamatrix.api.exception.security.LogonException;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import com.metamatrix.admin.api.exception.AdminException;
+import com.metamatrix.api.exception.security.LogonException;
import com.metamatrix.common.util.WSDLServletUtil;
-import com.metamatrix.core.log.FileLogWriter;
-import com.metamatrix.core.log.MessageLevel;
-import com.metamatrix.core.util.StringUtil;
-import com.metamatrix.soap.SOAPPlugin;
-import com.metamatrix.soap.object.MMServerInfo;
-import com.metamatrix.soap.util.WebServiceUtil;
+import com.metamatrix.core.util.StringUtil;
+import com.metamatrix.soap.SOAPPlugin;
+import com.metamatrix.soap.object.MMServerInfo;
+import com.metamatrix.soap.util.WebServiceUtil;
/**
* Servlet to retrieve WSDL from a VDB using servlet context values specified in the web.xml.
Modified: trunk/soap/src/main/java/com/metamatrix/soap/servlet/MMGetVDBResourceServlet.java
===================================================================
--- trunk/soap/src/main/java/com/metamatrix/soap/servlet/MMGetVDBResourceServlet.java 2009-06-16 17:20:38 UTC (rev 1055)
+++ trunk/soap/src/main/java/com/metamatrix/soap/servlet/MMGetVDBResourceServlet.java 2009-06-16 18:05:22 UTC (rev 1056)
@@ -22,7 +22,6 @@
package com.metamatrix.soap.servlet;
-import java.io.File;
import java.io.IOException;
import java.io.Reader;
import java.io.StringWriter;
@@ -50,9 +49,6 @@
import com.metamatrix.common.api.MMURL;
import com.metamatrix.common.util.WSDLServletUtil;
import com.metamatrix.core.CoreConstants;
-import com.metamatrix.core.log.FileLogWriter;
-import com.metamatrix.core.log.LogListener;
-import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.core.util.StringUtil;
import com.metamatrix.soap.SOAPPlugin;
import com.metamatrix.soap.util.ErrorMessageKeys;
Modified: trunk/soap/src/main/java/com/metamatrix/soap/servlet/MMGetWSDLServlet.java
===================================================================
--- trunk/soap/src/main/java/com/metamatrix/soap/servlet/MMGetWSDLServlet.java 2009-06-16 17:20:38 UTC (rev 1055)
+++ trunk/soap/src/main/java/com/metamatrix/soap/servlet/MMGetWSDLServlet.java 2009-06-16 18:05:22 UTC (rev 1056)
@@ -22,25 +22,22 @@
package com.metamatrix.soap.servlet;
-import java.io.File;
-import java.io.IOException;
-import java.sql.Connection;
-import java.sql.SQLException;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.sql.Connection;
+import java.sql.SQLException;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
import org.apache.log4j.Logger;
-
+
import com.metamatrix.common.util.WSDLServletUtil;
-import com.metamatrix.core.log.FileLogWriter;
-import com.metamatrix.core.log.MessageLevel;
-import com.metamatrix.core.util.StringUtil;
-import com.metamatrix.soap.SOAPPlugin;
-import com.metamatrix.soap.util.ErrorMessageKeys;
-import com.metamatrix.soap.util.SOAPConstants;
+import com.metamatrix.core.util.StringUtil;
+import com.metamatrix.soap.SOAPPlugin;
+import com.metamatrix.soap.util.ErrorMessageKeys;
+import com.metamatrix.soap.util.SOAPConstants;
import com.metamatrix.soap.util.WebServiceUtil;
/**
Modified: trunk/soap/src/main/java/com/metamatrix/soap/servlet/WSDLURLGenerator.java
===================================================================
--- trunk/soap/src/main/java/com/metamatrix/soap/servlet/WSDLURLGenerator.java 2009-06-16 17:20:38 UTC (rev 1055)
+++ trunk/soap/src/main/java/com/metamatrix/soap/servlet/WSDLURLGenerator.java 2009-06-16 18:05:22 UTC (rev 1056)
@@ -22,34 +22,30 @@
package com.metamatrix.soap.servlet;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLEncoder;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.StringTokenizer;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLEncoder;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.StringTokenizer;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
import org.apache.log4j.Logger;
-
+
import com.metamatrix.common.util.WSDLServletUtil;
-import com.metamatrix.core.log.FileLogWriter;
-import com.metamatrix.core.log.LogListener;
-import com.metamatrix.core.log.MessageLevel;
-import com.metamatrix.soap.SOAPPlugin;
-import com.metamatrix.soap.util.ErrorMessageKeys;
-import com.metamatrix.soap.util.SOAPConstants;
+import com.metamatrix.soap.SOAPPlugin;
+import com.metamatrix.soap.util.ErrorMessageKeys;
+import com.metamatrix.soap.util.SOAPConstants;
/**
* Servlet to build the WSDL URL for the specified VDB
Modified: trunk/soap/src/main/java/com/metamatrix/soap/sqlquerywebservice/log/LogUtil.java
===================================================================
--- trunk/soap/src/main/java/com/metamatrix/soap/sqlquerywebservice/log/LogUtil.java 2009-06-16 17:20:38 UTC (rev 1055)
+++ trunk/soap/src/main/java/com/metamatrix/soap/sqlquerywebservice/log/LogUtil.java 2009-06-16 18:05:22 UTC (rev 1056)
@@ -22,8 +22,9 @@
package com.metamatrix.soap.sqlquerywebservice.log;
+import com.metamatrix.core.log.JavaLogWriter;
+import com.metamatrix.core.log.LogListener;
import com.metamatrix.core.log.LogMessage;
-import com.metamatrix.internal.core.log.PlatformLog;
import com.metamatrix.soap.SOAPPlugin;
/**
@@ -34,22 +35,14 @@
// =========================================================================
// Static Members
// =========================================================================
- private static final LogUtil INSTANCE = new LogUtil();
+ private static final LogListener log = new JavaLogWriter();
- PlatformLog log = new PlatformLog("MetaMatrix SOAP log"); //$NON-NLS-1$
-
- /**
- * Get an instance of this class.
- */
- public static LogUtil getInstance() {
- return INSTANCE;
- }
public static void log(int severity, String message) {
- INSTANCE.log.logMessage(new LogMessage(SOAPPlugin.PLUGIN_ID, severity, new Object[] {message}));
+ log.logMessage(severity, SOAPPlugin.PLUGIN_ID, new LogMessage(null, new Object[] {message}));
}
public static void log(int severity, Throwable t, String message) {
- INSTANCE.log.logMessage(new LogMessage(SOAPPlugin.PLUGIN_ID, severity, t, new Object[] {message}));
+ log.logMessage(severity, SOAPPlugin.PLUGIN_ID, new LogMessage( t, new Object[] {message}));
}
}
More information about the teiid-commits
mailing list