[jboss-svn-commits] JBoss Common SVN: r3185 - in jboss-logmanager/trunk/src/main/java/org/jboss: stdio and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed May 20 17:29:44 EDT 2009
Author: david.lloyd at jboss.com
Date: 2009-05-20 17:29:44 -0400 (Wed, 20 May 2009)
New Revision: 3185
Added:
jboss-logmanager/trunk/src/main/java/org/jboss/stdio/AbstractLoggingWriter.java
jboss-logmanager/trunk/src/main/java/org/jboss/stdio/LoggingWriter.java
Removed:
jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/AbstractLoggingWriter.java
jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/LoggingWriter.java
Modified:
jboss-logmanager/trunk/src/main/java/org/jboss/stdio/NullInputStream.java
Log:
More stdio shuffing
Deleted: jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/AbstractLoggingWriter.java
===================================================================
--- jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/AbstractLoggingWriter.java 2009-05-20 21:29:16 UTC (rev 3184)
+++ jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/AbstractLoggingWriter.java 2009-05-20 21:29:44 UTC (rev 3185)
@@ -1,113 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.logmanager;
-
-import java.io.Writer;
-import java.io.IOException;
-
-/**
- * Abstract base class for writers which log to a logger.
- */
-public abstract class AbstractLoggingWriter extends Writer {
-
- private final StringBuilder buffer = new StringBuilder();
-
- /**
- * Construct a new instance.
- */
- protected AbstractLoggingWriter() {
- }
-
- /** {@inheritDoc} */
- @Override
- public void write(final int c) throws IOException {
- final java.util.logging.Logger logger = getLogger();
- if (logger == null) {
- return;
- }
- synchronized (buffer) {
- if (c == '\n') {
- logger.log(getLevel(), buffer.toString());
- buffer.setLength(0);
- } else {
- buffer.append((char) c);
- }
- }
- }
-
- /** {@inheritDoc} */
- public void write(final char[] cbuf, final int off, final int len) throws IOException {
- final java.util.logging.Logger logger = getLogger();
- if (logger == null) {
- return;
- }
- synchronized (buffer) {
- int mark = 0;
- int i;
- for (i = 0; i < len; i++) {
- final char c = cbuf[off + i];
- if (c == '\n') {
- buffer.append(cbuf, mark + off, i - mark);
- logger.log(getLevel(), buffer.toString());
- buffer.setLength(0);
- mark = i + 1;
- }
- }
- buffer.append(cbuf, mark + off, i - mark);
- }
- }
-
- /** {@inheritDoc} */
- public void flush() throws IOException {
- final java.util.logging.Logger logger = getLogger();
- if (logger == null) {
- return;
- }
- synchronized (buffer) {
- if (buffer.length() > 0) {
- buffer.append(" >>> FLUSH");
- logger.log(getLevel(), buffer.toString());
- buffer.setLength(0);
- }
- }
- }
-
- /**
- * Get the logger to use.
- *
- * @return the logger
- */
- protected abstract java.util.logging.Logger getLogger();
-
- /**
- * Get the level at which to log.
- *
- * @return the level
- */
- protected abstract java.util.logging.Level getLevel();
-
- /** {@inheritDoc} */
- public void close() throws IOException {
- // ignore
- }
-}
Deleted: jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/LoggingWriter.java
===================================================================
--- jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/LoggingWriter.java 2009-05-20 21:29:16 UTC (rev 3184)
+++ jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/LoggingWriter.java 2009-05-20 21:29:44 UTC (rev 3185)
@@ -1,57 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.logmanager;
-
-import java.util.logging.Logger;
-import java.util.logging.Level;
-
-/**
- * A writer which sends its data to a logger.
- */
-public final class LoggingWriter extends AbstractLoggingWriter {
-
- @SuppressWarnings({ "NonConstantLogger" })
- private final Logger log;
- private final Level level;
-
- /**
- * Construct a new instance.
- *
- * @param category the log category to use
- * @param level the level at which to log messages
- */
- public LoggingWriter(final String category, final Level level) {
- this.level = level;
- log = Logger.getLogger(category);
- }
-
- /** {@inheritDoc} */
- protected Logger getLogger() {
- return log;
- }
-
- /** {@inheritDoc} */
- protected Level getLevel() {
- return level;
- }
-}
Copied: jboss-logmanager/trunk/src/main/java/org/jboss/stdio/AbstractLoggingWriter.java (from rev 3176, jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/AbstractLoggingWriter.java)
===================================================================
--- jboss-logmanager/trunk/src/main/java/org/jboss/stdio/AbstractLoggingWriter.java (rev 0)
+++ jboss-logmanager/trunk/src/main/java/org/jboss/stdio/AbstractLoggingWriter.java 2009-05-20 21:29:44 UTC (rev 3185)
@@ -0,0 +1,113 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.stdio;
+
+import java.io.Writer;
+import java.io.IOException;
+
+/**
+ * Abstract base class for writers which log to a logger.
+ */
+public abstract class AbstractLoggingWriter extends Writer {
+
+ private final StringBuilder buffer = new StringBuilder();
+
+ /**
+ * Construct a new instance.
+ */
+ protected AbstractLoggingWriter() {
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void write(final int c) throws IOException {
+ final java.util.logging.Logger logger = getLogger();
+ if (logger == null) {
+ return;
+ }
+ synchronized (buffer) {
+ if (c == '\n') {
+ logger.log(getLevel(), buffer.toString());
+ buffer.setLength(0);
+ } else {
+ buffer.append((char) c);
+ }
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void write(final char[] cbuf, final int off, final int len) throws IOException {
+ final java.util.logging.Logger logger = getLogger();
+ if (logger == null) {
+ return;
+ }
+ synchronized (buffer) {
+ int mark = 0;
+ int i;
+ for (i = 0; i < len; i++) {
+ final char c = cbuf[off + i];
+ if (c == '\n') {
+ buffer.append(cbuf, mark + off, i - mark);
+ logger.log(getLevel(), buffer.toString());
+ buffer.setLength(0);
+ mark = i + 1;
+ }
+ }
+ buffer.append(cbuf, mark + off, i - mark);
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void flush() throws IOException {
+ final java.util.logging.Logger logger = getLogger();
+ if (logger == null) {
+ return;
+ }
+ synchronized (buffer) {
+ if (buffer.length() > 0) {
+ buffer.append(" >>> FLUSH");
+ logger.log(getLevel(), buffer.toString());
+ buffer.setLength(0);
+ }
+ }
+ }
+
+ /**
+ * Get the logger to use.
+ *
+ * @return the logger
+ */
+ protected abstract java.util.logging.Logger getLogger();
+
+ /**
+ * Get the level at which to log.
+ *
+ * @return the level
+ */
+ protected abstract java.util.logging.Level getLevel();
+
+ /** {@inheritDoc} */
+ public void close() throws IOException {
+ // ignore
+ }
+}
Copied: jboss-logmanager/trunk/src/main/java/org/jboss/stdio/LoggingWriter.java (from rev 3176, jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/LoggingWriter.java)
===================================================================
--- jboss-logmanager/trunk/src/main/java/org/jboss/stdio/LoggingWriter.java (rev 0)
+++ jboss-logmanager/trunk/src/main/java/org/jboss/stdio/LoggingWriter.java 2009-05-20 21:29:44 UTC (rev 3185)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.stdio;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * A writer which sends its data to a logger.
+ */
+public final class LoggingWriter extends AbstractLoggingWriter {
+
+ @SuppressWarnings({ "NonConstantLogger" })
+ private final Logger log;
+ private final Level level;
+
+ /**
+ * Construct a new instance.
+ *
+ * @param category the log category to use
+ * @param level the level at which to log messages
+ */
+ public LoggingWriter(final String category, final Level level) {
+ this.level = level;
+ log = Logger.getLogger(category);
+ }
+
+ /**
+ * Construct a new instance.
+ *
+ * @param log the logger to use
+ * @param level the level at which to log messages
+ */
+ public LoggingWriter(final Logger log, final Level level) {
+ this.log = log;
+ this.level = level;
+ }
+
+ /** {@inheritDoc} */
+ protected Logger getLogger() {
+ return log;
+ }
+
+ /** {@inheritDoc} */
+ protected Level getLevel() {
+ return level;
+ }
+}
Modified: jboss-logmanager/trunk/src/main/java/org/jboss/stdio/NullInputStream.java
===================================================================
--- jboss-logmanager/trunk/src/main/java/org/jboss/stdio/NullInputStream.java 2009-05-20 21:29:16 UTC (rev 3184)
+++ jboss-logmanager/trunk/src/main/java/org/jboss/stdio/NullInputStream.java 2009-05-20 21:29:44 UTC (rev 3185)
@@ -23,10 +23,18 @@
package org.jboss.stdio;
import java.io.InputStream;
-import java.io.IOException;
+/**
+ * An input stream that is always in an EOF condition.
+ */
public final class NullInputStream extends InputStream {
- public int read() throws IOException {
+
+ /**
+ * Read a byte. Always returns EOF.
+ *
+ * @return -1 always
+ */
+ public int read() {
return -1;
}
}
More information about the jboss-svn-commits
mailing list