Skip to content

Commit

Permalink
SOLDER-85 repackage typed message bundle and logger
Browse files Browse the repository at this point in the history
- split the typed message bundle and logger annotations into their own packages
- update annotation processor to reflect repackaging
- split type producers for the native logger, typed message bundle and typed message logger
- split extensions for typed message bundle and logger
- update javadoc and reference guide
  • Loading branch information
mojavelinux committed Mar 19, 2011
1 parent bfb90e7 commit 7fc1098
Show file tree
Hide file tree
Showing 52 changed files with 673 additions and 436 deletions.
20 changes: 3 additions & 17 deletions api/src/main/java/org/jboss/logging/package-info.java
Expand Up @@ -17,24 +17,10 @@
* limitations under the License.
*/
/**
* Seam Solder integrates JBoss Logging 3 as its logging framework of choice
*
* <p>JBoss Logging 3 is a modern logging framework offering:</p>
*
* <ul>
* <li>Abstraction over common logging back ends and frameworks (such as JDK Logging, log4j and slf4j)</li>
* <li>Innovative, typed-safe loggers</li>
* <li>Full support for internationalization and localization
* <ul>
* <li>Developers can work with interfaces and annotations only</li>
* <li>Translators can work with message bundles in properties files</li>
* </ul>
* </li>
* <li>Build time tooling to generate typed loggers for production, and runtime generation of typed loggers for development</li>
* <li>Access to MDC and NDC (if underlying logger supports it)</li>
* <li>Serializable loggers</li>
* </ul>
* Seam Solder integrates with JBoss Logging 3 to provide native and typed
* injectable loggers and choice of logging backend.
*
* <p>This package contains the JBoss Logging 3 library.</p>
* <p>Version imported: <a href="http://repository.jboss.org/nexus/content/groups/public/org/jboss/logging/jboss-logging/3.0.0.Beta4">jboss-logging-3.0.0.Beta4</a></p>
*/
package org.jboss.logging;
Expand Up @@ -18,7 +18,7 @@

import javax.enterprise.util.AnnotationLiteral;

import org.jboss.seam.solder.logging.MessageBundle;
import org.jboss.seam.solder.messages.MessageBundle;


public class MessageBundleLiteral extends AnnotationLiteral<MessageBundle> implements MessageBundle
Expand Down
155 changes: 0 additions & 155 deletions api/src/main/java/org/jboss/seam/solder/log/package-info.java

This file was deleted.

Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.seam.solder.log;
package org.jboss.seam.solder.logging;

import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
Expand All @@ -27,7 +27,6 @@
import java.lang.annotation.Target;

import org.jboss.logging.Logger;
import org.jboss.seam.solder.logging.MessageLogger;

/**
* <p>
Expand Down
Expand Up @@ -23,16 +23,17 @@
import java.lang.annotation.Target;

import org.jboss.logging.Logger;
import org.jboss.seam.solder.messages.Message;

/**
* A typed logger method. Indicates that this method will log the associated {@link Message} to the logger system, as
* 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@redhat.com">David M. Lloyd</a>
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface LogMessage {
public @interface Log {

/**
* The log level at which this message should be logged. Defaults to {@code INFO}.
Expand Down
Expand Up @@ -22,6 +22,8 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.jboss.seam.solder.messages.MessageBundle;

/**
* 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.
Expand Down
Expand Up @@ -23,6 +23,8 @@

import org.jboss.logging.BasicLogger;
import org.jboss.logging.Logger;
import org.jboss.seam.solder.messages.Message;
import org.jboss.seam.solder.messages.MessageBundleInvocationHandler;

/**
* @author <a href="mailto:david.lloyd@redhat.com">David M. Lloyd</a>
Expand All @@ -47,7 +49,7 @@ public Object invoke(final Object proxy, final Method method, Object[] args) thr
return null;
}
final Annotation[][] parameterAnnotations = method.getParameterAnnotations();
final LogMessage logMessage = method.getAnnotation(LogMessage.class);
final Log logMessage = method.getAnnotation(Log.class);
if (logMessage != null) {

try {
Expand Down
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.seam.solder.log;
package org.jboss.seam.solder.logging;

import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
Expand Down
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.seam.solder.log;
package org.jboss.seam.solder.logging;

import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
Expand All @@ -27,7 +27,6 @@
import java.lang.annotation.Target;

import org.jboss.logging.Logger;
import org.jboss.seam.solder.logging.MessageLogger;

/**
* <p>
Expand Down
106 changes: 106 additions & 0 deletions api/src/main/java/org/jboss/seam/solder/logging/package-info.java
@@ -0,0 +1,106 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* Seam Solder integrates with JBoss Logging 3 to provide injectable native
* loggers or typed message loggers (suitable for internationalization and
* localization) while still offering a choice of logging backend
*
* <p>Solder builds on its typed message bundles support combined with JBoss
* Logging 3 to provide the following feature set:</p>
*
* <ul>
* <li>An abstraction over common logging backends and frameworks (such as JDK Logging, log4j and slf4j)</li>
* <li>An innovative, typed message logger (and bundle) defined using an interface (see below for examples)</li>
* <li>Full support for internationalization and localization</li>
* <li>Build time tooling to generate typed loggers for production, and runtime generation of typed loggers for development</li>
* <li>Access to MDC and NDC (if underlying logger supports it)</li>
* <li>Serializable loggers</li>
* </ul>
*
* <p>To define a typed message logger, first create an annotated interface
* with methods configured as log commands. The log messages to use
* printf-style interpolations of parameters (%s).</p>
*
* <pre>
* &#64;MessageLogger
* public interface TrainSpotterLog {
*
* &#64;Log &#64;Message("Spotted %s diesel trains")
* void dieselTrainsSpotted(int number);
*
* }
* </pre>
*
* <p>You can then inject the typed logger with no further configuration
* necessary. You use another annotation to set the category of the logger to
* "trains" at the injection point:</p>
*
* <pre>
* &#64;Inject &#64;Category("trains") TrainSpotterLog log;
* </pre>
*
* <p>You log a message by simply invoking a method of the message logger
* interface:</p>
*
* <pre>
* log.dieselTrainsSpotted(7);
* </pre>
*
* <p>The default locale will be used unless overridden. Here we configure the
* logger to use the UK locale.</p>
*
* <pre>
* &#64;Inject &#64;Category("trains") &#64;Locale("en_GB") TrainSpotterLog log;
* </pre>
*
* <p>You can also log exceptions:</p>
*
* <pre>
* &#64;MessageLogger
* public interface TrainSpotterLog {
*
* &#64;Log &#64;Message("Failed to spot train %s")
* void missedTrain(String trainNumber, &#64;Cause Exception exception);
*
* }
* </pre>
*
* <p>You can then log a message with exception:</p>
*
* <pre>
* log.missedTrain("RH1", cause);
* </pre>
*
* <p>
* You can also inject a native Logger from the JBoss Logging 3 API:
* </p>
*
* <pre>
* &#64;Inject Logger log;
* </pre>
*
* @see org.jboss.seam.solder.logging.Log
* @see org.jboss.seam.solder.logging.Category
* @see org.jboss.seam.solder.logging.TypedCategory
* @see org.jboss.seam.solder.logging.Suffix
* @see org.jboss.seam.solder.messages.Cause
* @see org.jboss.seam.solder.messages.Message
* @see org.jboss.seam.solder.messages.Locale
* @see org.jboss.seam.solder.messages.Formatter
*/
package org.jboss.seam.solder.logging;
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.jboss.seam.solder.logging;
package org.jboss.seam.solder.messages;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
Expand Down

0 comments on commit 7fc1098

Please sign in to comment.