[jboss-svn-commits] JBoss Common SVN: r4481 - jboss-logging/trunk/src/main/java/org/jboss/logging.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Jun 9 13:40:03 EDT 2010


Author: david.lloyd at jboss.com
Date: 2010-06-09 13:40:01 -0400 (Wed, 09 Jun 2010)
New Revision: 4481

Added:
   jboss-logging/trunk/src/main/java/org/jboss/logging/LogMessage.java
   jboss-logging/trunk/src/main/java/org/jboss/logging/Message.java
   jboss-logging/trunk/src/main/java/org/jboss/logging/MessageBundle.java
   jboss-logging/trunk/src/main/java/org/jboss/logging/MessageLogger.java
Removed:
   jboss-logging/trunk/src/main/java/org/jboss/logging/annotation/
Modified:
   jboss-logging/trunk/src/main/java/org/jboss/logging/Logger.java
   jboss-logging/trunk/src/main/java/org/jboss/logging/ParameterConverter.java
Log:
Flatten annotations into the main package; add missing logv methods

Copied: jboss-logging/trunk/src/main/java/org/jboss/logging/LogMessage.java (from rev 4474, jboss-logging/trunk/src/main/java/org/jboss/logging/annotation/LogMessage.java)
===================================================================
--- jboss-logging/trunk/src/main/java/org/jboss/logging/LogMessage.java	                        (rev 0)
+++ jboss-logging/trunk/src/main/java/org/jboss/logging/LogMessage.java	2010-06-09 17:40:01 UTC (rev 4481)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.logging;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * A typed logger method.  Indicates that this method will log the associated {@link Message} to the logger system, as
+ * opposed to being a simple message lookup.
+ *
+ * @author <a href="mailto:david.lloyd at redhat.com">David M. Lloyd</a>
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target(ElementType.METHOD)
+public @interface LogMessage {
+
+    /**
+     * The log level at which this message should be logged.  Defaults to {@code INFO}.
+     *
+     * @return the log level
+     */
+    Logger.Level level() default Logger.Level.INFO;
+}

Modified: jboss-logging/trunk/src/main/java/org/jboss/logging/Logger.java
===================================================================
--- jboss-logging/trunk/src/main/java/org/jboss/logging/Logger.java	2010-06-09 16:48:47 UTC (rev 4480)
+++ jboss-logging/trunk/src/main/java/org/jboss/logging/Logger.java	2010-06-09 17:40:01 UTC (rev 4481)
@@ -1927,6 +1927,67 @@
     }
 
     /**
+     * Issue a log message at the given log level using {@link java.text.MessageFormat}-style formatting.
+     *
+     * @param loggerFqcn the logger class name
+     * @param level the level
+     * @param t the throwable
+     * @param format the message format string
+     * @param params the parameters
+     */
+    public void logv(String loggerFqcn, Level level, Throwable t, String format, Object... params) {
+        doLog(level, loggerFqcn, format, params, t);
+    }
+
+    /**
+     * Issue a log message at the given log level using {@link java.text.MessageFormat}-style formatting.
+     *
+     * @param loggerFqcn the logger class name
+     * @param level the level
+     * @param t the throwable
+     * @param format the message format string
+     * @param param1 the sole parameter
+     */
+    public void logv(String loggerFqcn, Level level, Throwable t, String format, Object param1) {
+        if (isEnabled(level)) {
+            doLog(level, loggerFqcn, format, new Object[] { param1 }, t);
+        }
+    }
+
+    /**
+     * Issue a log message at the given log level using {@link java.text.MessageFormat}-style formatting.
+     *
+     * @param loggerFqcn the logger class name
+     * @param level the level
+     * @param t the throwable
+     * @param format the message format string
+     * @param param1 the first parameter
+     * @param param2 the second parameter
+     */
+    public void logv(String loggerFqcn, Level level, Throwable t, String format, Object param1, Object param2) {
+        if (isEnabled(level)) {
+            doLog(level, loggerFqcn, format, new Object[] { param1, param2 }, t);
+        }
+    }
+
+    /**
+     * Issue a log message at the given log level using {@link java.text.MessageFormat}-style formatting.
+     *
+     * @param loggerFqcn the logger class name
+     * @param level the level
+     * @param t the throwable
+     * @param format the message format string
+     * @param param1 the first parameter
+     * @param param2 the second parameter
+     * @param param3 the third parameter
+     */
+    public void logv(String loggerFqcn, Level level, Throwable t, String format, Object param1, Object param2, Object param3) {
+        if (isEnabled(level)) {
+            doLog(level, loggerFqcn, format, new Object[] { param1, param2, param3 }, t);
+        }
+    }
+
+    /**
      * Issue a formatted log message at the given log level.
      *
      * @param level the level

Copied: jboss-logging/trunk/src/main/java/org/jboss/logging/Message.java (from rev 4474, jboss-logging/trunk/src/main/java/org/jboss/logging/annotation/Message.java)
===================================================================
--- jboss-logging/trunk/src/main/java/org/jboss/logging/Message.java	                        (rev 0)
+++ jboss-logging/trunk/src/main/java/org/jboss/logging/Message.java	2010-06-09 17:40:01 UTC (rev 4481)
@@ -0,0 +1,93 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.logging;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Assigns a message string to a resource method.  The method arguments are used to supply the positional parameter
+ * values for the method.
+ *
+ * @author <a href="mailto:david.lloyd at redhat.com">David M. Lloyd</a>
+ */
+ at Target(ElementType.METHOD)
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface Message {
+
+    /**
+     * Indicates that this message has no ID.
+     */
+    int NONE = 0;
+    /**
+     * Indicates that this message should inherit the ID from another message with the same name.
+     */
+    int INHERIT = -1;
+
+    /**
+     * The message ID number.  Only one message with a given name may specify an ID other than {@link #INHERIT}.
+     *
+     * @return the message ID number
+     */
+    int id() default INHERIT;
+
+    /**
+     * The default format string of this message.
+     *
+     * @return the format string
+     */
+    String value();
+
+    /**
+     * The format type of this method (defaults to {@link Format#PRINTF}).
+     *
+     * @return the format type
+     */
+    Format format() default Format.PRINTF;
+
+    /**
+     * The converter to use.  Any specified converter must implement the {@code ParameterConverter} interface
+     * from JBoss Logging or JBoss I18n.
+     *
+     * @return the converter
+     */
+    Class<?> converter() default Object.class;
+
+    /**
+     * The possible format types.
+     */
+    enum Format {
+
+        /**
+         * A {@link java.util.Formatter}-type format string.
+         */
+        PRINTF,
+        /**
+         * A {@link java.text.MessageFormat}-type format string.
+         */
+        MESSAGE_FORMAT,
+    }
+
+}

Copied: jboss-logging/trunk/src/main/java/org/jboss/logging/MessageBundle.java (from rev 4474, jboss-logging/trunk/src/main/java/org/jboss/logging/annotation/MessageBundle.java)
===================================================================
--- jboss-logging/trunk/src/main/java/org/jboss/logging/MessageBundle.java	                        (rev 0)
+++ jboss-logging/trunk/src/main/java/org/jboss/logging/MessageBundle.java	2010-06-09 17:40:01 UTC (rev 4481)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.logging;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Signify that an interface is a message bundle interface.
+ *
+ * @author <a href="mailto:david.lloyd at redhat.com">David M. Lloyd</a>
+ */
+ at Target(ElementType.TYPE)
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface MessageBundle {
+
+    /**
+     * Get the project code for messages that have an associated code.
+     *
+     * @return the project code
+     */
+    String projectCode() default "";
+}

Copied: jboss-logging/trunk/src/main/java/org/jboss/logging/MessageLogger.java (from rev 4474, jboss-logging/trunk/src/main/java/org/jboss/logging/annotation/MessageLogger.java)
===================================================================
--- jboss-logging/trunk/src/main/java/org/jboss/logging/MessageLogger.java	                        (rev 0)
+++ jboss-logging/trunk/src/main/java/org/jboss/logging/MessageLogger.java	2010-06-09 17:40:01 UTC (rev 4481)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.logging;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Signify that an interface is a typed logger interface.  A message logger interface may optionally extend other message logger
+ * interfaces and message bundle interfaces (see {@link MessageBundle}, as well as the {@link org.jboss.logging.BasicLogger} interface.
+ *
+ * @author <a href="mailto:david.lloyd at redhat.com">David M. Lloyd</a>
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target(ElementType.TYPE)
+public @interface MessageLogger {
+
+    /**
+     * Get the project code for messages that have an associated code.
+     *
+     * @return the project code
+     */
+    String projectCode() default "";
+}

Modified: jboss-logging/trunk/src/main/java/org/jboss/logging/ParameterConverter.java
===================================================================
--- jboss-logging/trunk/src/main/java/org/jboss/logging/ParameterConverter.java	2010-06-09 16:48:47 UTC (rev 4480)
+++ jboss-logging/trunk/src/main/java/org/jboss/logging/ParameterConverter.java	2010-06-09 17:40:01 UTC (rev 4481)
@@ -35,7 +35,7 @@
     /**
      * Convert the parameter to its string or string-equivalent representation.  The returned value will be passed in
      * as a parameter to either a {@link java.text.MessageFormat} or {@link java.util.Formatter} instance, depending
-     * on the setting of {@link org.jboss.logging.annotation.Message#format()}.
+     * on the setting of {@link Message#format()}.
      *
      * @param locale the locale
      * @param parameter the parameter



More information about the jboss-svn-commits mailing list