Java 5 code style

This commit is contained in:
Juergen Hoeller
2008-11-25 01:29:54 +00:00
parent 1f9e63af49
commit 29657105da
71 changed files with 726 additions and 877 deletions

View File

@@ -21,10 +21,8 @@ import java.lang.reflect.Method;
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
import javax.xml.namespace.QName;
import javax.xml.rpc.Call;
import javax.xml.rpc.JAXRPCException;
@@ -94,7 +92,7 @@ public class JaxRpcPortClientInterceptor extends LocalJaxRpcServiceFactory
private boolean maintainSession;
/** Map of custom properties, keyed by property name (String) */
private final Map customPropertyMap = new HashMap();
private final Map<String, Object> customPropertyMap = new HashMap<String, Object>();
private Class serviceInterface;
@@ -228,16 +226,10 @@ public class JaxRpcPortClientInterceptor extends LocalJaxRpcServiceFactory
* @see javax.xml.rpc.Stub#_setProperty
* @see javax.xml.rpc.Call#setProperty
*/
public void setCustomPropertyMap(Map customProperties) {
public void setCustomPropertyMap(Map<String, Object> customProperties) {
if (customProperties != null) {
Iterator it = customProperties.entrySet().iterator();
while (it.hasNext()) {
Map.Entry entry = (Map.Entry) it.next();
if (!(entry.getKey() instanceof String)) {
throw new IllegalArgumentException(
"Illegal property key [" + entry.getKey() + "]: only Strings allowed");
}
addCustomProperty((String) entry.getKey(), entry.getValue());
for (Map.Entry<String, Object> entry : customProperties.entrySet()) {
addCustomProperty(entry.getKey(), entry.getValue());
}
}
}
@@ -249,7 +241,7 @@ public class JaxRpcPortClientInterceptor extends LocalJaxRpcServiceFactory
* "customPropertyMap[myKey]". This is particularly useful for
* adding or overriding entries in child bean definitions.
*/
public Map getCustomPropertyMap() {
public Map<String, Object> getCustomPropertyMap() {
return this.customPropertyMap;
}
@@ -513,9 +505,8 @@ public class JaxRpcPortClientInterceptor extends LocalJaxRpcServiceFactory
stub._setProperty(Stub.SESSION_MAINTAIN_PROPERTY, Boolean.TRUE);
}
if (this.customPropertyMap != null) {
for (Iterator it = this.customPropertyMap.keySet().iterator(); it.hasNext();) {
String key = (String) it.next();
stub._setProperty(key, this.customPropertyMap.get(key));
for (Map.Entry<String, Object> entry : this.customPropertyMap.entrySet()) {
stub._setProperty(entry.getKey(), entry.getValue());
}
}
}
@@ -687,9 +678,8 @@ public class JaxRpcPortClientInterceptor extends LocalJaxRpcServiceFactory
call.setProperty(Call.SESSION_MAINTAIN_PROPERTY, Boolean.TRUE);
}
if (this.customPropertyMap != null) {
for (Iterator it = this.customPropertyMap.keySet().iterator(); it.hasNext();) {
String key = (String) it.next();
call.setProperty(key, this.customPropertyMap.get(key));
for (Map.Entry<String, Object> entry : this.customPropertyMap.entrySet()) {
call.setProperty(entry.getKey(), entry.getValue());
}
}
}
@@ -750,8 +740,8 @@ public class JaxRpcPortClientInterceptor extends LocalJaxRpcServiceFactory
* @see org.springframework.remoting.rmi.RmiClientInterceptorUtils#isConnectFailure
*/
protected boolean isConnectFailure(RemoteException ex) {
return (ex.getClass().getName().indexOf("Fault") == -1 &&
ex.getClass().getSuperclass().getName().indexOf("Fault") == -1);
return (!ex.getClass().getName().contains("Fault") &&
!ex.getClass().getSuperclass().getName().contains("Fault"));
}
}

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.
@@ -18,10 +18,8 @@ package org.springframework.remoting.jaxrpc.support;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
import javax.xml.namespace.QName;
import javax.xml.rpc.Service;
import javax.xml.rpc.encoding.TypeMapping;
@@ -62,7 +60,7 @@ public class AxisBeanMappingServicePostProcessor implements JaxRpcServicePostPro
private String typeNamespaceUri;
private Map beanMappings;
private Map<Object, String> beanMappings;
private ClassLoader beanClassLoader = ClassUtils.getDefaultClassLoader();
@@ -95,7 +93,7 @@ public class AxisBeanMappingServicePostProcessor implements JaxRpcServicePostPro
*/
public void setBeanMappings(Properties beanMappingProps) {
if (beanMappingProps != null) {
this.beanMappings = new HashMap(beanMappingProps.size());
this.beanMappings = new HashMap<Object, String>(beanMappingProps.size());
Enumeration propertyNames = beanMappingProps.propertyNames();
while (propertyNames.hasMoreElements()) {
String javaTypeName = (String) propertyNames.nextElement();
@@ -115,9 +113,8 @@ public class AxisBeanMappingServicePostProcessor implements JaxRpcServicePostPro
*/
public void setBeanClasses(Class[] beanClasses) {
if (beanClasses != null) {
this.beanMappings = new HashMap(beanClasses.length);
for (int i = 0; i < beanClasses.length; i++) {
Class beanClass = beanClasses[i];
this.beanMappings = new HashMap<Object, String>(beanClasses.length);
for (Class beanClass : beanClasses) {
String wsdlTypeName = ClassUtils.getShortName(beanClass);
this.beanMappings.put(beanClass, wsdlTypeName);
}
@@ -142,9 +139,7 @@ public class AxisBeanMappingServicePostProcessor implements JaxRpcServicePostPro
public void postProcessJaxRpcService(Service service) {
TypeMappingRegistry registry = service.getTypeMappingRegistry();
TypeMapping mapping = registry.createTypeMapping();
registerBeanMappings(mapping);
if (this.encodingStyleUri != null) {
registry.register(this.encodingStyleUri, mapping);
}
@@ -161,18 +156,10 @@ public class AxisBeanMappingServicePostProcessor implements JaxRpcServicePostPro
*/
protected void registerBeanMappings(TypeMapping mapping) {
if (this.beanMappings != null) {
for (Iterator it = this.beanMappings.entrySet().iterator(); it.hasNext();) {
Map.Entry entry = (Map.Entry) it.next();
Object key = entry.getKey();
Class javaType = null;
if (key instanceof Class) {
javaType = (Class) key;
}
else {
javaType = ClassUtils.resolveClassName((String) key, this.beanClassLoader);
}
String wsdlTypeName = (String) entry.getValue();
registerBeanMapping(mapping, javaType, wsdlTypeName);
for (Map.Entry<Object, String> entry : this.beanMappings.entrySet()) {
Class javaType = (entry.getKey() instanceof Class ? (Class) entry.getKey() :
ClassUtils.resolveClassName(entry.getKey().toString(), this.beanClassLoader));
registerBeanMapping(mapping, javaType, entry.getValue());
}
}
}