Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Created the logger and messages class for enable i18n logging message…

…s and exception messages https://issues.jboss.org/browse/AS7-809
  • Loading branch information...
commit 2c6011a59706eca29b3f23c7917e10bf2e3c1493 1 parent ae828fa
fharms authored bstansberry committed
View
66 ejb3/src/main/java/org/jboss/as/ejb3/EjbLogger.java
@@ -0,0 +1,66 @@
+/*
+ *
+ * * JBoss, Home of Professional Open Source.
+ * * Copyright 2011, Red Hat, Inc., 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.as.ejb3;
+
+import org.jboss.ejb.client.SessionID;
+import org.jboss.logging.BasicLogger;
+import org.jboss.logging.LogMessage;
+import org.jboss.logging.Logger;
+import org.jboss.logging.Message;
+
+import static org.jboss.logging.Logger.Level.ERROR;
+import static org.jboss.logging.Logger.Level.WARN;
+
+/**
+ * Date: 19.10.2011
+ *
+ * @author <a href="mailto:Flemming.Harms@gmail.com">Flemming Harms</a>
+ */
+public interface EjbLogger extends BasicLogger {
+
+ /**
+ * Default root level logger with the package name for he category.
+ */
+ EjbLogger ROOT_LOGGER = Logger.getMessageLogger(EjbLogger.class, EjbLogger.class.getPackage().getName());
+
+ /**
+ * Logs an error message indicating an exception occurred while removing the an inactive bean.
+ * Initialization continues after logging the error.
+ * @param id the session id that could not be removed
+ * @param cause the cause of the error.
+ */
+ @LogMessage(level = ERROR)
+ @Message(id = 14100, value = "Exception removing stateful bean %s")
+ void errorRemovingStatefulBean(SessionID id, Exception cause);
+
+ /**
+ * Logs an warning message indicating the it could not find a EJB for the specific id
+ * Initialization continues after logging the warning.
+ * @param id the session id that could not be released
+ */
+ @LogMessage(level = WARN)
+ @Message(id = 14101, value = "Could not find stateful bean to release %s")
+ void couldNotFindStatefulBean(SessionID id);
+}
View
38 ejb3/src/main/java/org/jboss/as/ejb3/EjbMessages.java
@@ -0,0 +1,38 @@
+
+package org.jboss.as.ejb3;
+
+import org.jboss.ejb.client.SessionID;
+import org.jboss.logging.Cause;
+import org.jboss.logging.Logger;
+import org.jboss.logging.Message;
+import org.jboss.logging.MessageBundle;
+import org.jboss.logging.Messages;
+
+import javax.ejb.NoSuchEJBException;
+
+/**
+ * Date: 19.10.2011
+ *
+ * @author <a href="mailto:Flemming.Harms@gmail.com">Flemming Harms</a>
+ */
+@MessageBundle(projectCode = "JBAS")
+public interface EjbMessages {
+
+ /**
+ * The default messages.
+ */
+ EjbMessages MESSAGES = Messages.getBundle(EjbMessages.class);
+
+ /**
+ * Creates an exception indicating it could not find the EJB with specific id
+ *
+ *
+ * @param sessionId the name of the integration.
+ *
+ * @return a {@link NoSuchEJBException} for the error.
+ */
+ @Message(id = 14300, value = "Could not find EJB with id %s")
+ NoSuchEJBException couldNotFindEjb(SessionID sessionId);
+
+
+}
View
16 ejb3/src/main/java/org/jboss/as/ejb3/cache/ExpiringCache.java
@@ -28,16 +28,10 @@
import java.util.Map;
import java.util.concurrent.TimeUnit;
-import javax.transaction.RollbackException;
-import javax.transaction.Synchronization;
-import javax.transaction.SystemException;
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-
+import static org.jboss.as.ejb3.EjbLogger.ROOT_LOGGER;
+import static org.jboss.as.ejb3.EjbMessages.MESSAGES;
import org.jboss.ejb.client.SessionID;
-import org.jboss.logging.Logger;
import org.jboss.tm.TxUtils;
-
/**
* Cache that handles EJB expiration. This cache can be wrapped around an existing cache to
* provide expiration functionality.
@@ -79,10 +73,10 @@ public void run() {
}
for (Entry value : queue) {
try {
- logger.debugf("Removing stateful bean %s - %s as it has been inactive for %d milliseconds", beanName, value.getKey(), millisecondTimeout);
+ ROOT_LOGGER.debugf("Removing stateful bean %s - %s as it has been inactive for %d milliseconds", beanName, value.getKey(), millisecondTimeout);
factory.destroyInstance(value.getValue());
} catch (Exception e) {
- logger.error("Exception removing stateful bean " + value.getKey(), e);
+ ROOT_LOGGER.errorRemovingStatefulBean(value.getKey(), e);
}
}
@@ -177,7 +171,7 @@ public void release(final T obj) {
Entry entry = cache.get(obj.getId());
if (entry == null) {
- logger.warn("Could not find stateful bean to release " + obj.getId());
+ ROOT_LOGGER.couldNotFindStatefulBean(obj.getId());
return;
}
//this must stay within the synchronized block so the changes are visible to other threads

0 comments on commit 2c6011a

Please sign in to comment.
Something went wrong with that request. Please try again.