Skip to content

Commit

Permalink
Polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoeller committed Jul 7, 2014
1 parent 4082274 commit 55c3515
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 47 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 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.
Expand Down Expand Up @@ -45,9 +45,8 @@
* {@link SQLExceptionTranslator} implementation which analyzes the specific
* {@link java.sql.SQLException} subclass thrown by the JDBC driver.
*
* <p>This is only available with JDBC 4.0 and later drivers when using Java 6 or later.
* Falls back to a standard {@link SQLStateSQLExceptionTranslator} if the JDBC driver
* does not actually expose JDBC 4 compliant {@code SQLException} subclasses.
* <p>Falls back to a standard {@link SQLStateSQLExceptionTranslator} if the JDBC
* driver does not actually expose JDBC 4 compliant {@code SQLException} subclasses.
*
* @author Thomas Risberg
* @author Juergen Hoeller
Expand All @@ -65,35 +64,35 @@ public SQLExceptionSubclassTranslator() {
@Override
protected DataAccessException doTranslate(String task, String sql, SQLException ex) {
if (ex instanceof SQLTransientException) {
if (ex instanceof SQLTransactionRollbackException) {
return new ConcurrencyFailureException(buildMessage(task, sql, ex), ex);
}
if (ex instanceof SQLTransientConnectionException) {
return new TransientDataAccessResourceException(buildMessage(task, sql, ex), ex);
}
if (ex instanceof SQLTimeoutException) {
else if (ex instanceof SQLTransactionRollbackException) {
return new ConcurrencyFailureException(buildMessage(task, sql, ex), ex);
}
else if (ex instanceof SQLTimeoutException) {
return new QueryTimeoutException(buildMessage(task, sql, ex), ex);
}
}
else if (ex instanceof SQLNonTransientException) {
if (ex instanceof SQLDataException) {
return new DataIntegrityViolationException(buildMessage(task, sql, ex), ex);
if (ex instanceof SQLNonTransientConnectionException) {
return new DataAccessResourceFailureException(buildMessage(task, sql, ex), ex);
}
else if (ex instanceof SQLFeatureNotSupportedException) {
return new InvalidDataAccessApiUsageException(buildMessage(task, sql, ex), ex);
else if (ex instanceof SQLDataException) {
return new DataIntegrityViolationException(buildMessage(task, sql, ex), ex);
}
else if (ex instanceof SQLIntegrityConstraintViolationException) {
return new DataIntegrityViolationException(buildMessage(task, sql, ex), ex);
}
else if (ex instanceof SQLInvalidAuthorizationSpecException) {
return new PermissionDeniedDataAccessException(buildMessage(task, sql, ex), ex);
}
else if (ex instanceof SQLNonTransientConnectionException) {
return new DataAccessResourceFailureException(buildMessage(task, sql, ex), ex);
}
else if (ex instanceof SQLSyntaxErrorException) {
return new BadSqlGrammarException(task, sql, ex);
}
else if (ex instanceof SQLFeatureNotSupportedException) {
return new InvalidDataAccessApiUsageException(buildMessage(task, sql, ex), ex);
}
}
else if (ex instanceof SQLRecoverableException) {
return new RecoverableDataAccessException(buildMessage(task, sql, ex), ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,13 @@ public abstract class AbstractJmsListenerEndpoint implements JmsListenerEndpoint
private String selector;


@Override
public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

/**
* Return the name of the destination for this endpoint.
*/
public String getDestination() {
return destination;
@Override
public String getId() {
return this.id;
}

/**
Expand All @@ -67,10 +60,10 @@ public void setDestination(String destination) {
}

/**
* Return the name for the durable subscription, if any.
* Return the name of the destination for this endpoint.
*/
public String getSubscription() {
return subscription;
public String getDestination() {
return this.destination;
}

/**
Expand All @@ -81,32 +74,40 @@ public void setSubscription(String subscription) {
}

/**
* Return the JMS message selector expression, if any.
* <p>See the JMS specification for a detailed definition of selector expressions.
* Return the name for the durable subscription, if any.
*/
public String getSelector() {
return selector;
public String getSubscription() {
return this.subscription;
}

/**
* Set the JMS message selector expression.
* <p>See the JMS specification for a detailed definition of selector expressions.
*/
public void setSelector(String selector) {
this.selector = selector;
}

/**
* Return the JMS message selector expression, if any.
*/
public String getSelector() {
return this.selector;
}


@Override
public void setupMessageContainer(MessageListenerContainer container) {
if (container instanceof AbstractMessageListenerContainer) { // JMS
if (container instanceof AbstractMessageListenerContainer) { // JMS
setupJmsMessageContainer((AbstractMessageListenerContainer) container);
}
else if (container instanceof JmsMessageEndpointManager) { // JCA
else if (container instanceof JmsMessageEndpointManager) { // JCA
setupJcaMessageContainer((JmsMessageEndpointManager) container);
}
else {
throw new IllegalArgumentException("Could not configure endpoint with the specified container '"
+ container + "' Only JMS (" + AbstractMessageListenerContainer.class.getName()
+ " subclass) or JCA (" + JmsMessageEndpointManager.class.getName() + ") are supported.");
throw new IllegalArgumentException("Could not configure endpoint with the specified container '" +
container + "' Only JMS (" + AbstractMessageListenerContainer.class.getName() +
" subclass) or JCA (" + JmsMessageEndpointManager.class.getName() + ") are supported.");
}
}

Expand Down Expand Up @@ -160,16 +161,9 @@ private void setupMessageListener(MessageListenerContainer container) {
*/
protected StringBuilder getEndpointDescription() {
StringBuilder result = new StringBuilder();
return result.append(getClass().getSimpleName())
.append("[")
.append(this.id)
.append("] destination=")
.append(this.destination)
.append("' | subscription='")
.append(this.subscription)
.append(" | selector='")
.append(this.selector)
.append("'");
return result.append(getClass().getSimpleName()).append("[").append(this.id).append("] destination=").
append(this.destination).append("' | subscription='").append(this.subscription).
append(" | selector='").append(this.selector).append("'");
}

@Override
Expand Down

0 comments on commit 55c3515

Please sign in to comment.