Java 5 code style

This commit is contained in:
Juergen Hoeller
2008-11-27 00:27:52 +00:00
parent 6bbc966a21
commit b0790bf5e7
248 changed files with 2374 additions and 3208 deletions

View File

@@ -31,7 +31,7 @@ import javax.jms.Session;
* @see JmsTemplate#browse(BrowserCallback)
* @see JmsTemplate#browseSelected(String, BrowserCallback)
*/
public interface BrowserCallback {
public interface BrowserCallback<T> {
/**
* Perform operations on the given {@link javax.jms.Session} and {@link javax.jms.QueueBrowser}.
@@ -41,6 +41,6 @@ public interface BrowserCallback {
* @return a result object from working with the <code>Session</code>, if any (can be <code>null</code>)
* @throws javax.jms.JMSException if thrown by JMS API methods
*/
Object doInJms(Session session, QueueBrowser browser) throws JMSException;
T doInJms(Session session, QueueBrowser browser) throws JMSException;
}

View File

@@ -52,7 +52,7 @@ public interface JmsOperations {
* @return the result object from working with the session
* @throws JmsException if there is any problem
*/
Object execute(SessionCallback action) throws JmsException;
<T> T execute(SessionCallback<T> action) throws JmsException;
/**
* Send messages to the default JMS destination (or one specified
@@ -62,7 +62,7 @@ public interface JmsOperations {
* @return the result object from working with the session
* @throws JmsException checked JMSException converted to unchecked
*/
Object execute(ProducerCallback action) throws JmsException;
<T> T execute(ProducerCallback<T> action) throws JmsException;
/**
* Send messages to a JMS destination. The callback gives access to the JMS Session
@@ -72,7 +72,7 @@ public interface JmsOperations {
* @return the result object from working with the session
* @throws JmsException checked JMSException converted to unchecked
*/
Object execute(Destination destination, ProducerCallback action) throws JmsException;
<T> T execute(Destination destination, ProducerCallback<T> action) throws JmsException;
/**
* Send messages to a JMS destination. The callback gives access to the JMS Session
@@ -83,7 +83,7 @@ public interface JmsOperations {
* @return the result object from working with the session
* @throws JmsException checked JMSException converted to unchecked
*/
Object execute(String destinationName, ProducerCallback action) throws JmsException;
<T> T execute(String destinationName, ProducerCallback<T> action) throws JmsException;
//-------------------------------------------------------------------------
@@ -363,7 +363,7 @@ public interface JmsOperations {
* @return the result object from working with the session
* @throws JmsException checked JMSException converted to unchecked
*/
Object browse(BrowserCallback action) throws JmsException;
<T> T browse(BrowserCallback<T> action) throws JmsException;
/**
* Browse messages in a JMS queue. The callback gives access to the JMS Session
@@ -373,7 +373,7 @@ public interface JmsOperations {
* @return the result object from working with the session
* @throws JmsException checked JMSException converted to unchecked
*/
Object browse(Queue queue, BrowserCallback action) throws JmsException;
<T> T browse(Queue queue, BrowserCallback<T> action) throws JmsException;
/**
* Browse messages in a JMS queue. The callback gives access to the JMS Session
@@ -384,7 +384,7 @@ public interface JmsOperations {
* @return the result object from working with the session
* @throws JmsException checked JMSException converted to unchecked
*/
Object browse(String queueName, BrowserCallback action) throws JmsException;
<T> T browse(String queueName, BrowserCallback<T> action) throws JmsException;
/**
* Browse selected messages in a JMS queue. The callback gives access to the JMS
@@ -395,7 +395,7 @@ public interface JmsOperations {
* @return the result object from working with the session
* @throws JmsException checked JMSException converted to unchecked
*/
Object browseSelected(String messageSelector, BrowserCallback action) throws JmsException;
<T> T browseSelected(String messageSelector, BrowserCallback<T> action) throws JmsException;
/**
* Browse selected messages in a JMS queue. The callback gives access to the JMS
@@ -407,7 +407,7 @@ public interface JmsOperations {
* @return the result object from working with the session
* @throws JmsException checked JMSException converted to unchecked
*/
Object browseSelected(Queue queue, String messageSelector, BrowserCallback action) throws JmsException;
<T> T browseSelected(Queue queue, String messageSelector, BrowserCallback<T> action) throws JmsException;
/**
* Browse selected messages in a JMS queue. The callback gives access to the JMS
@@ -420,6 +420,6 @@ public interface JmsOperations {
* @return the result object from working with the session
* @throws JmsException checked JMSException converted to unchecked
*/
Object browseSelected(String queueName, String messageSelector, BrowserCallback action) throws JmsException;
<T> T browseSelected(String queueName, String messageSelector, BrowserCallback<T> action) throws JmsException;
}

View File

@@ -432,7 +432,7 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
// JmsOperations execute methods
//-------------------------------------------------------------------------
public Object execute(SessionCallback action) throws JmsException {
public <T> T execute(SessionCallback<T> action) throws JmsException {
return execute(action, false);
}
@@ -450,7 +450,7 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
* @see #execute(SessionCallback)
* @see #receive
*/
public Object execute(SessionCallback action, boolean startConnection) throws JmsException {
public <T> T execute(SessionCallback<T> action, boolean startConnection) throws JmsException {
Assert.notNull(action, "Callback object must not be null");
Connection conToClose = null;
Session sessionToClose = null;
@@ -479,7 +479,7 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
}
}
public Object execute(ProducerCallback action) throws JmsException {
public <T> T execute(ProducerCallback<T> action) throws JmsException {
String defaultDestinationName = getDefaultDestinationName();
if (defaultDestinationName != null) {
return execute(defaultDestinationName, action);
@@ -489,10 +489,10 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
}
}
public Object execute(final Destination destination, final ProducerCallback action) throws JmsException {
public <T> T execute(final Destination destination, final ProducerCallback<T> action) throws JmsException {
Assert.notNull(action, "Callback object must not be null");
return execute(new SessionCallback() {
public Object doInJms(Session session) throws JMSException {
return execute(new SessionCallback<T>() {
public T doInJms(Session session) throws JMSException {
MessageProducer producer = createProducer(session, destination);
try {
return action.doInJms(session, producer);
@@ -504,10 +504,10 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
}, false);
}
public Object execute(final String destinationName, final ProducerCallback action) throws JmsException {
public <T> T execute(final String destinationName, final ProducerCallback<T> action) throws JmsException {
Assert.notNull(action, "Callback object must not be null");
return execute(new SessionCallback() {
public Object doInJms(Session session) throws JMSException {
return execute(new SessionCallback<T>() {
public T doInJms(Session session) throws JMSException {
Destination destination = resolveDestinationName(session, destinationName);
MessageProducer producer = createProducer(session, destination);
try {
@@ -826,7 +826,7 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
// Convenience methods for browsing messages
//-------------------------------------------------------------------------
public Object browse(BrowserCallback action) throws JmsException {
public <T> T browse(BrowserCallback<T> action) throws JmsException {
Queue defaultQueue = getDefaultQueue();
if (defaultQueue != null) {
return browse(defaultQueue, action);
@@ -836,15 +836,15 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
}
}
public Object browse(Queue queue, BrowserCallback action) throws JmsException {
public <T> T browse(Queue queue, BrowserCallback<T> action) throws JmsException {
return browseSelected(queue, null, action);
}
public Object browse(String queueName, BrowserCallback action) throws JmsException {
public <T> T browse(String queueName, BrowserCallback<T> action) throws JmsException {
return browseSelected(queueName, null, action);
}
public Object browseSelected(String messageSelector, BrowserCallback action) throws JmsException {
public <T> T browseSelected(String messageSelector, BrowserCallback<T> action) throws JmsException {
Queue defaultQueue = getDefaultQueue();
if (defaultQueue != null) {
return browseSelected(defaultQueue, messageSelector, action);
@@ -854,12 +854,12 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
}
}
public Object browseSelected(final Queue queue, final String messageSelector, final BrowserCallback action)
public <T> T browseSelected(final Queue queue, final String messageSelector, final BrowserCallback<T> action)
throws JmsException {
Assert.notNull(action, "Callback object must not be null");
return execute(new SessionCallback() {
public Object doInJms(Session session) throws JMSException {
return execute(new SessionCallback<T>() {
public T doInJms(Session session) throws JMSException {
QueueBrowser browser = createBrowser(session, queue, messageSelector);
try {
return action.doInJms(session, browser);
@@ -871,12 +871,12 @@ public class JmsTemplate extends JmsDestinationAccessor implements JmsOperations
}, true);
}
public Object browseSelected(final String queueName, final String messageSelector, final BrowserCallback action)
public <T> T browseSelected(final String queueName, final String messageSelector, final BrowserCallback<T> action)
throws JmsException {
Assert.notNull(action, "Callback object must not be null");
return execute(new SessionCallback() {
public Object doInJms(Session session) throws JMSException {
return execute(new SessionCallback<T>() {
public T doInJms(Session session) throws JMSException {
Queue queue = (Queue) getDestinationResolver().resolveDestinationName(session, queueName, false);
QueueBrowser browser = createBrowser(session, queue, messageSelector);
try {

View File

@@ -38,7 +38,7 @@ import javax.jms.Session;
* @see JmsTemplate#execute(javax.jms.Destination, ProducerCallback)
* @see JmsTemplate#execute(String, ProducerCallback)
*/
public interface ProducerCallback {
public interface ProducerCallback<T> {
/**
* Perform operations on the given {@link Session} and {@link MessageProducer}.
@@ -49,6 +49,6 @@ public interface ProducerCallback {
* @return a result object from working with the <code>Session</code>, if any (can be <code>null</code>)
* @throws javax.jms.JMSException if thrown by JMS API methods
*/
Object doInJms(Session session, MessageProducer producer) throws JMSException;
T doInJms(Session session, MessageProducer producer) throws JMSException;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2005 the original author or authors.
* Copyright 2002-2008 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,7 +30,7 @@ import javax.jms.Session;
* @since 1.1
* @see JmsTemplate#execute(SessionCallback)
*/
public interface SessionCallback {
public interface SessionCallback<T> {
/**
* Execute any number of operations against the supplied JMS
@@ -39,6 +39,6 @@ public interface SessionCallback {
* @return a result object from working with the <code>Session</code>, if any (so can be <code>null</code>)
* @throws javax.jms.JMSException if thrown by JMS API methods
*/
Object doInJms(Session session) throws JMSException;
T doInJms(Session session) throws JMSException;
}

View File

@@ -738,7 +738,7 @@ public class DefaultMessageListenerContainer extends AbstractPollingMessageListe
logger.debug("Setup of JMS message listener invoker failed - already recovered by other invoker", ex);
}
else {
StringBuffer msg = new StringBuffer();
StringBuilder msg = new StringBuilder();
msg.append("Setup of JMS message listener invoker failed for destination '");
msg.append(getDestinationDescription()).append("' - trying to recover. Cause: ");
msg.append(ex instanceof JMSException ? JmsUtils.buildExceptionMessage((JMSException) ex) : ex.getMessage());
@@ -791,7 +791,7 @@ public class DefaultMessageListenerContainer extends AbstractPollingMessageListe
break;
}
catch (Exception ex) {
StringBuffer msg = new StringBuffer();
StringBuilder msg = new StringBuilder();
msg.append("Could not refresh JMS Connection for destination '");
msg.append(getDestinationDescription()).append("' - retrying in ");
msg.append(this.recoveryInterval).append(" ms. Cause: ");