Java 5 code style

This commit is contained in:
Juergen Hoeller
2008-11-28 11:39:36 +00:00
parent fda7100866
commit f8c690c542
55 changed files with 356 additions and 445 deletions

View File

@@ -230,11 +230,11 @@ public class SingleConnectionFactory extends DelegatingConnectionFactory impleme
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if (method.getName().equals("equals")) {
// Only consider equal when proxies are identical.
return (proxy == args[0] ? Boolean.TRUE : Boolean.FALSE);
return (proxy == args[0]);
}
else if (method.getName().equals("hashCode")) {
// Use hashCode of Connection proxy.
return new Integer(System.identityHashCode(proxy));
return System.identityHashCode(proxy);
}
else if (method.getName().equals("close")) {
// Handle close method: don't pass the call on.

View File

@@ -132,11 +132,11 @@ public class TransactionAwareConnectionFactoryProxy extends DelegatingConnection
if (method.getName().equals("equals")) {
// Only consider equal when proxies are identical.
return (proxy == args[0] ? Boolean.TRUE : Boolean.FALSE);
return (proxy == args[0]);
}
else if (method.getName().equals("hashCode")) {
// Use hashCode of Connection proxy.
return new Integer(System.identityHashCode(proxy));
return System.identityHashCode(proxy);
}
else if (method.getName().equals("getLocalTransaction")) {
if (ConnectionFactoryUtils.isConnectionTransactional(this.target, this.connectionFactory)) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 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.
@@ -99,12 +99,12 @@ public class OC4JJtaTransactionManager extends JtaTransactionManager {
protected UserTransaction retrieveUserTransaction() throws TransactionSystemException {
try {
Class transactionUtilityClass = getClass().getClassLoader().loadClass(TRANSACTION_UTILITY_CLASS_NAME);
Method getInstanceMethod = transactionUtilityClass.getMethod("getInstance", new Class[0]);
Object transactionUtility = getInstanceMethod.invoke(null, new Object[0]);
Method getInstanceMethod = transactionUtilityClass.getMethod("getInstance");
Object transactionUtility = getInstanceMethod.invoke(null);
logger.debug("Retrieving JTA UserTransaction from OC4J TransactionUtility");
Method getUserTransactionMethod =
transactionUtility.getClass().getMethod("getOC4JUserTransaction", new Class[0]);
return (UserTransaction) getUserTransactionMethod.invoke(transactionUtility, new Object[0]);
transactionUtility.getClass().getMethod("getOC4JUserTransaction");
return (UserTransaction) getUserTransactionMethod.invoke(transactionUtility);
}
catch (ClassNotFoundException ex) {
logger.debug("Could not find OC4J 10.1.3.2 TransactionUtility: " + ex);
@@ -144,9 +144,9 @@ public class OC4JJtaTransactionManager extends JtaTransactionManager {
// Cache reflective Method references for later use.
if (transactionManagerClass.isInstance(getUserTransaction())) {
this.beginWithNameMethod = ClassUtils.getMethodIfAvailable(
transactionManagerClass, "begin", new Class[] {String.class});
transactionManagerClass, "begin", String.class);
this.setTransactionIsolationMethod = ClassUtils.getMethodIfAvailable(
transactionClass, "setTransactionIsolation", new Class[] {int.class});
transactionClass, "setTransactionIsolation", int.class);
logger.info("Support for OC4J transaction names and isolation levels available");
}
else {
@@ -169,7 +169,7 @@ public class OC4JJtaTransactionManager extends JtaTransactionManager {
otm.begin(definition.getName());
*/
try {
this.beginWithNameMethod.invoke(txObject.getUserTransaction(), new Object[] {definition.getName()});
this.beginWithNameMethod.invoke(txObject.getUserTransaction(), definition.getName());
}
catch (InvocationTargetException ex) {
throw new TransactionSystemException(
@@ -195,8 +195,7 @@ public class OC4JJtaTransactionManager extends JtaTransactionManager {
oracle.j2ee.transaction.OC4JTransaction otx = (oracle.j2ee.transaction.OC4JTransaction) tx;
otx.setTransactionIsolation(definition.getIsolationLevel());
*/
Integer isolationLevel = new Integer(definition.getIsolationLevel());
this.setTransactionIsolationMethod.invoke(tx, new Object[] {isolationLevel});
this.setTransactionIsolationMethod.invoke(tx, definition.getIsolationLevel());
}
catch (InvocationTargetException ex) {
throw new TransactionSystemException(
@@ -222,7 +221,7 @@ public class OC4JJtaTransactionManager extends JtaTransactionManager {
ut.setTransactionTimeout(timeout);
}
try {
this.beginWithNameMethod.invoke(ut, new Object[] {name});
this.beginWithNameMethod.invoke(ut, name);
}
catch (InvocationTargetException ex) {
if (ex.getTargetException() instanceof NotSupportedException) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 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.
@@ -117,8 +117,8 @@ public class WebLogicJtaTransactionManager extends JtaTransactionManager {
try {
logger.debug("Retrieving JTA UserTransaction from WebLogic TransactionHelper/TxHelper");
Method getUserTransactionMethod =
this.transactionHelperClass.getMethod("getUserTransaction", new Class[0]);
return (UserTransaction) getUserTransactionMethod.invoke(this.transactionHelper, new Object[0]);
this.transactionHelperClass.getMethod("getUserTransaction");
return (UserTransaction) getUserTransactionMethod.invoke(this.transactionHelper);
}
catch (InvocationTargetException ex) {
throw new TransactionSystemException(
@@ -135,9 +135,8 @@ public class WebLogicJtaTransactionManager extends JtaTransactionManager {
loadWebLogicTransactionHelperClass();
try {
logger.debug("Retrieving JTA TransactionManager from WebLogic TransactionHelper/TxHelper");
Method getTransactionManagerMethod =
this.transactionHelperClass.getMethod("getTransactionManager", new Class[0]);
return (TransactionManager) getTransactionManagerMethod.invoke(this.transactionHelper, new Object[0]);
Method getTransactionManagerMethod = this.transactionHelperClass.getMethod("getTransactionManager");
return (TransactionManager) getTransactionManagerMethod.invoke(this.transactionHelper);
}
catch (InvocationTargetException ex) {
throw new TransactionSystemException(
@@ -158,7 +157,7 @@ public class WebLogicJtaTransactionManager extends JtaTransactionManager {
getClass().getClassLoader().loadClass(TRANSACTION_HELPER_CLASS_NAME);
Method getTransactionHelperMethod =
this.transactionHelperClass.getMethod("getTransactionHelper", new Class[0]);
this.transactionHelper = getTransactionHelperMethod.invoke(null, new Object[0]);
this.transactionHelper = getTransactionHelperMethod.invoke(null);
logger.debug("WebLogic 8.1+ TransactionHelper found");
}
catch (ClassNotFoundException ex) {
@@ -246,16 +245,14 @@ public class WebLogicJtaTransactionManager extends JtaTransactionManager {
weblogic.transaction.UserTransaction wut = (weblogic.transaction.UserTransaction) ut;
wut.begin(definition.getName(), timeout);
*/
this.beginWithNameAndTimeoutMethod.invoke(txObject.getUserTransaction(),
new Object[] {definition.getName(), new Integer(timeout)});
this.beginWithNameAndTimeoutMethod.invoke(txObject.getUserTransaction(), definition.getName(), timeout);
}
else {
/*
weblogic.transaction.UserTransaction wut = (weblogic.transaction.UserTransaction) ut;
wut.begin(definition.getName());
*/
this.beginWithNameMethod.invoke(txObject.getUserTransaction(),
new Object[] {definition.getName()});
this.beginWithNameMethod.invoke(txObject.getUserTransaction(), definition.getName());
}
}
catch (InvocationTargetException ex) {
@@ -279,12 +276,12 @@ public class WebLogicJtaTransactionManager extends JtaTransactionManager {
if (definition.getIsolationLevel() != TransactionDefinition.ISOLATION_DEFAULT) {
try {
Transaction tx = getTransactionManager().getTransaction();
Integer isolationLevel = new Integer(definition.getIsolationLevel());
Integer isolationLevel = definition.getIsolationLevel();
/*
weblogic.transaction.Transaction wtx = (weblogic.transaction.Transaction) tx;
wtx.setProperty(ISOLATION_LEVEL_KEY, isolationLevel);
*/
this.setPropertyMethod.invoke(tx, new Object[] {ISOLATION_LEVEL_KEY, isolationLevel});
this.setPropertyMethod.invoke(tx, ISOLATION_LEVEL_KEY, isolationLevel);
}
catch (InvocationTargetException ex) {
throw new TransactionSystemException(
@@ -323,7 +320,7 @@ public class WebLogicJtaTransactionManager extends JtaTransactionManager {
wtm.forceResume(suspendedTransaction);
*/
try {
this.forceResumeMethod.invoke(getTransactionManager(), new Object[] {suspendedTransaction});
this.forceResumeMethod.invoke(getTransactionManager(), suspendedTransaction);
}
catch (InvocationTargetException ex2) {
throw new TransactionSystemException(
@@ -342,10 +339,10 @@ public class WebLogicJtaTransactionManager extends JtaTransactionManager {
if (this.weblogicUserTransactionAvailable && name != null) {
try {
if (timeout >= 0) {
this.beginWithNameAndTimeoutMethod.invoke(getUserTransaction(), new Object[] {name, new Integer(timeout)});
this.beginWithNameAndTimeoutMethod.invoke(getUserTransaction(), name, timeout);
}
else {
this.beginWithNameMethod.invoke(getUserTransaction(), new Object[] {name});
this.beginWithNameMethod.invoke(getUserTransaction(), name);
}
}
catch (InvocationTargetException ex) {

View File

@@ -127,7 +127,7 @@ public class DefaultTransactionDefinition implements TransactionDefinition, Seri
* @see #PROPAGATION_REQUIRED
*/
public final void setPropagationBehavior(int propagationBehavior) {
if (!constants.getValues(PREFIX_PROPAGATION).contains(new Integer(propagationBehavior))) {
if (!constants.getValues(PREFIX_PROPAGATION).contains(propagationBehavior)) {
throw new IllegalArgumentException("Only values of propagation constants allowed");
}
this.propagationBehavior = propagationBehavior;
@@ -161,7 +161,7 @@ public class DefaultTransactionDefinition implements TransactionDefinition, Seri
* @see #ISOLATION_DEFAULT
*/
public final void setIsolationLevel(int isolationLevel) {
if (!constants.getValues(PREFIX_ISOLATION).contains(new Integer(isolationLevel))) {
if (!constants.getValues(PREFIX_ISOLATION).contains(isolationLevel)) {
throw new IllegalArgumentException("Only values of isolation constants allowed");
}
this.isolationLevel = isolationLevel;