You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by do...@apache.org on 2007/10/18 01:15:39 UTC
svn commit: r585750 - in
/ofbiz/trunk/framework/base/src/base/org/ofbiz/base: component/ util/
util/collections/
Author: doogie
Date: Wed Oct 17 16:15:38 2007
New Revision: 585750
URL: http://svn.apache.org/viewvc?rev=585750&view=rev
Log:
Java 1.5 markup. Closes https://issues.apache.org/jira/browse/OFBIZ-1342
Modified:
ofbiz/trunk/framework/base/src/base/org/ofbiz/base/component/ComponentConfig.java
ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/SSLUtil.java
ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilTimer.java
ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections/FlexibleProperties.java
ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections/LocalizedMap.java
ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections/MapComparator.java
Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/component/ComponentConfig.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/component/ComponentConfig.java?rev=585750&r1=585749&r2=585750&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/component/ComponentConfig.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/component/ComponentConfig.java Wed Oct 17 16:15:38 2007
@@ -50,8 +50,8 @@
public static final String OFBIZ_COMPONENT_XML_FILENAME = "ofbiz-component.xml";
// this is not a UtilCache because reloading may cause problems
- protected static Map componentConfigs = FastMap.newInstance();
- protected static Map serverWebApps = FastMap.newInstance();
+ protected static Map<String, ComponentConfig> componentConfigs = FastMap.newInstance();
+ protected static Map<String, List<WebappInfo>> serverWebApps = FastMap.newInstance();
public static ComponentConfig getComponentConfig(String globalName) throws ComponentException {
// TODO: we need to look up the rootLocation from the container config, or this will blow up
@@ -61,13 +61,13 @@
public static ComponentConfig getComponentConfig(String globalName, String rootLocation) throws ComponentException {
ComponentConfig componentConfig = null;
if (UtilValidate.isNotEmpty(globalName)) {
- componentConfig = (ComponentConfig) componentConfigs.get(globalName);
+ componentConfig = componentConfigs.get(globalName);
}
if (componentConfig == null) {
if (rootLocation != null) {
synchronized (ComponentConfig.class) {
if (UtilValidate.isNotEmpty(globalName)) {
- componentConfig = (ComponentConfig) componentConfigs.get(globalName);
+ componentConfig = componentConfigs.get(globalName);
}
if (componentConfig == null) {
componentConfig = new ComponentConfig(globalName, rootLocation);
@@ -86,8 +86,8 @@
return componentConfig;
}
- public static Collection getAllComponents() {
- Collection values = componentConfigs.values();
+ public static Collection<ComponentConfig> getAllComponents() {
+ Collection<ComponentConfig> values = componentConfigs.values();
if (values != null) {
return values;
} else {
@@ -96,15 +96,13 @@
}
}
- public static List getAllClasspathInfos() {
+ public static List<ClasspathInfo> getAllClasspathInfos() {
return getAllClasspathInfos(null);
}
- public static List getAllClasspathInfos(String componentName) {
- List classpaths = FastList.newInstance();
- Iterator i = getAllComponents().iterator();
- while (i.hasNext()) {
- ComponentConfig cc = (ComponentConfig) i.next();
+ public static List<ClasspathInfo> getAllClasspathInfos(String componentName) {
+ List<ClasspathInfo> classpaths = FastList.newInstance();
+ for (ComponentConfig cc: getAllComponents()) {
if (componentName == null || componentName.equals(cc.getComponentName())) {
classpaths.addAll(cc.getClasspathInfos());
}
@@ -112,23 +110,19 @@
return classpaths;
}
- public static List getAllEntityResourceInfos(String type) {
+ public static List<EntityResourceInfo> getAllEntityResourceInfos(String type) {
return getAllEntityResourceInfos(type, null);
}
- public static List getAllEntityResourceInfos(String type, String componentName) {
- List entityInfos = FastList.newInstance();
- Iterator i = getAllComponents().iterator();
- while (i.hasNext()) {
- ComponentConfig cc = (ComponentConfig) i.next();
+ public static List<EntityResourceInfo> getAllEntityResourceInfos(String type, String componentName) {
+ List<EntityResourceInfo> entityInfos = FastList.newInstance();
+ for (ComponentConfig cc: getAllComponents()) {
if (componentName == null || componentName.equals(cc.getComponentName())) {
- List ccEntityInfoList = cc.getEntityResourceInfos();
+ List<EntityResourceInfo> ccEntityInfoList = cc.getEntityResourceInfos();
if (UtilValidate.isEmpty(type)) {
entityInfos.addAll(ccEntityInfoList);
} else {
- Iterator ccEntityInfoIter = ccEntityInfoList.iterator();
- while (ccEntityInfoIter.hasNext()) {
- EntityResourceInfo entityResourceInfo = (EntityResourceInfo) ccEntityInfoIter.next();
+ for (EntityResourceInfo entityResourceInfo: ccEntityInfoList) {
if (type.equals(entityResourceInfo.type)) {
entityInfos.add(entityResourceInfo);
}
@@ -139,23 +133,19 @@
return entityInfos;
}
- public static List getAllServiceResourceInfos(String type) {
+ public static List<ServiceResourceInfo> getAllServiceResourceInfos(String type) {
return getAllServiceResourceInfos(type, null);
}
- public static List getAllServiceResourceInfos(String type, String componentName) {
- List serviceInfos = FastList.newInstance();
- Iterator i = getAllComponents().iterator();
- while (i.hasNext()) {
- ComponentConfig cc = (ComponentConfig) i.next();
+ public static List<ServiceResourceInfo> getAllServiceResourceInfos(String type, String componentName) {
+ List<ServiceResourceInfo> serviceInfos = FastList.newInstance();
+ for (ComponentConfig cc: getAllComponents()) {
if (componentName == null || componentName.equals(cc.getComponentName())) {
- List ccServiceInfoList = cc.getServiceResourceInfos();
+ List<ServiceResourceInfo> ccServiceInfoList = cc.getServiceResourceInfos();
if (UtilValidate.isEmpty(type)) {
serviceInfos.addAll(ccServiceInfoList);
} else {
- Iterator ccServiceInfoIter = ccServiceInfoList.iterator();
- while (ccServiceInfoIter.hasNext()) {
- ServiceResourceInfo serviceResourceInfo = (ServiceResourceInfo) ccServiceInfoIter.next();
+ for (ServiceResourceInfo serviceResourceInfo: ccServiceInfoList) {
if (type.equals(serviceResourceInfo.type)) {
serviceInfos.add(serviceResourceInfo);
}
@@ -166,15 +156,13 @@
return serviceInfos;
}
- public static List getAllTestSuiteInfos() {
+ public static List<TestSuiteInfo> getAllTestSuiteInfos() {
return getAllTestSuiteInfos(null);
}
- public static List getAllTestSuiteInfos(String componentName) {
- List testSuiteInfos = FastList.newInstance();
- Iterator i = getAllComponents().iterator();
- while (i.hasNext()) {
- ComponentConfig cc = (ComponentConfig) i.next();
+ public static List<TestSuiteInfo> getAllTestSuiteInfos(String componentName) {
+ List<TestSuiteInfo> testSuiteInfos = FastList.newInstance();
+ for (ComponentConfig cc: getAllComponents()) {
if (componentName == null || componentName.equals(cc.getComponentName())) {
testSuiteInfos.addAll(cc.getTestSuiteInfos());
}
@@ -182,15 +170,13 @@
return testSuiteInfos;
}
- public static List getAllKeystoreInfos() {
+ public static List<KeystoreInfo> getAllKeystoreInfos() {
return getAllKeystoreInfos(null);
}
- public static List getAllKeystoreInfos(String componentName) {
- List keystoreInfos = FastList.newInstance();
- Iterator i = getAllComponents().iterator();
- while (i.hasNext()) {
- ComponentConfig cc = (ComponentConfig) i.next();
+ public static List<KeystoreInfo> getAllKeystoreInfos(String componentName) {
+ List<KeystoreInfo> keystoreInfos = FastList.newInstance();
+ for (ComponentConfig cc: getAllComponents()) {
if (componentName == null || componentName.equals(cc.getComponentName())) {
keystoreInfos.addAll(cc.getKeystoreInfos());
}
@@ -199,13 +185,9 @@
}
public static KeystoreInfo getKeystoreInfo(String componentName, String keystoreName) {
- Iterator i = getAllComponents().iterator();
- while (i.hasNext()) {
- ComponentConfig cc = (ComponentConfig) i.next();
+ for (ComponentConfig cc: getAllComponents()) {
if (componentName != null && componentName.equals(cc.getComponentName())) {
- Iterator ki = cc.getKeystoreInfos().iterator();
- while (ki.hasNext()) {
- KeystoreInfo ks = (KeystoreInfo) ki.next();
+ for (KeystoreInfo ks: cc.getKeystoreInfos()) {
if (keystoreName != null && keystoreName.equals(ks.getName())) {
return ks;
}
@@ -216,15 +198,13 @@
return null;
}
- public static List getAllWebappResourceInfos() {
+ public static List<WebappInfo> getAllWebappResourceInfos() {
return getAllWebappResourceInfos(null);
}
- public static List getAllWebappResourceInfos(String componentName) {
- List webappInfos = FastList.newInstance();
- Iterator i = getAllComponents().iterator();
- while (i.hasNext()) {
- ComponentConfig cc = (ComponentConfig) i.next();
+ public static List<WebappInfo> getAllWebappResourceInfos(String componentName) {
+ List<WebappInfo> webappInfos = FastList.newInstance();
+ for (ComponentConfig cc: getAllComponents()) {
if (componentName == null || componentName.equals(cc.getComponentName())) {
webappInfos.addAll(cc.getWebappInfos());
}
@@ -276,32 +256,28 @@
return ComponentConfig.getAppBarWebInfos(serverName, null);
}
- public static List getAppBarWebInfos(String serverName, Comparator comp) {
- List webInfos = (List) serverWebApps.get(serverName);
+ public static List<WebappInfo> getAppBarWebInfos(String serverName, Comparator<? super String> comp) {
+ List<WebappInfo> webInfos = serverWebApps.get(serverName);
if (webInfos == null) {
synchronized (ComponentConfig.class) {
if (webInfos == null) {
- Map tm = null;
- Iterator i = getAllComponents().iterator();
+ Map<String, WebappInfo> tm = null;
// use a TreeMap to sort the components alpha by title
if (comp != null) {
- tm = new TreeMap(comp);
+ tm = new TreeMap<String, WebappInfo>(comp);
} else {
- tm = new TreeMap();
+ tm = new TreeMap<String, WebappInfo>();
}
- while (i.hasNext()) {
- ComponentConfig cc = (ComponentConfig) i.next();
- Iterator wi = cc.getWebappInfos().iterator();
- while (wi.hasNext()) {
- ComponentConfig.WebappInfo wInfo = (ComponentConfig.WebappInfo) wi.next();
+ for (ComponentConfig cc: getAllComponents()) {
+ for (WebappInfo wInfo: cc.getWebappInfos()) {
if (serverName.equals(wInfo.server) && wInfo.appBarDisplay) {
tm.put(wInfo.title, wInfo);
}
}
}
- List webInfoList = FastList.newInstance();
+ List<WebappInfo> webInfoList = FastList.newInstance();
webInfoList.addAll(tm.values());
serverWebApps.put(serverName, webInfoList);
return webInfoList;
@@ -317,12 +293,8 @@
return info;
}
- Iterator i = getAllComponents().iterator();
- while (i.hasNext() && info == null) {
- ComponentConfig cc = (ComponentConfig) i.next();
- Iterator wi = cc.getWebappInfos().iterator();
- while (wi.hasNext()) {
- ComponentConfig.WebappInfo wInfo = (ComponentConfig.WebappInfo) wi.next();
+ for (ComponentConfig cc: getAllComponents()) {
+ for (WebappInfo wInfo: cc.getWebappInfos()) {
if (serverName.equals(wInfo.server) && contextRoot.equals(wInfo.getContextRoot())) {
info = wInfo;
}
@@ -337,13 +309,13 @@
protected String componentName = null;
protected boolean enabled = true;
- protected Map resourceLoaderInfos = FastMap.newInstance();
- protected List classpathInfos = FastList.newInstance();
- protected List entityResourceInfos = FastList.newInstance();
- protected List serviceResourceInfos = FastList.newInstance();
- protected List testSuiteInfos = FastList.newInstance();
- protected List keystoreInfos = FastList.newInstance();
- protected List webappInfos = FastList.newInstance();
+ protected Map<String, ResourceLoaderInfo> resourceLoaderInfos = FastMap.newInstance();
+ protected List<ClasspathInfo> classpathInfos = FastList.newInstance();
+ protected List<EntityResourceInfo> entityResourceInfos = FastList.newInstance();
+ protected List<ServiceResourceInfo> serviceResourceInfos = FastList.newInstance();
+ protected List<TestSuiteInfo> testSuiteInfos = FastList.newInstance();
+ protected List<KeystoreInfo> keystoreInfos = FastList.newInstance();
+ protected List<WebappInfo> webappInfos = FastList.newInstance();
protected ComponentConfig() {}
@@ -385,60 +357,45 @@
if (UtilValidate.isEmpty(this.globalName)) {
this.globalName = this.componentName;
}
- Iterator elementIter = null;
// resource-loader - resourceLoaderInfos
- elementIter = UtilXml.childElementList(ofbizComponentElement, "resource-loader").iterator();
- while (elementIter.hasNext()) {
- Element curElement = (Element) elementIter.next();
+ for (Element curElement: UtilXml.childElementList(ofbizComponentElement, "resource-loader")) {
ResourceLoaderInfo resourceLoaderInfo = new ResourceLoaderInfo(curElement);
this.resourceLoaderInfos.put(resourceLoaderInfo.name, resourceLoaderInfo);
}
// classpath - classpathInfos
- elementIter = UtilXml.childElementList(ofbizComponentElement, "classpath").iterator();
- while (elementIter.hasNext()) {
- Element curElement = (Element) elementIter.next();
+ for (Element curElement: UtilXml.childElementList(ofbizComponentElement, "classpath")) {
ClasspathInfo classpathInfo = new ClasspathInfo(this, curElement);
this.classpathInfos.add(classpathInfo);
}
// entity-resource - entityResourceInfos
- elementIter = UtilXml.childElementList(ofbizComponentElement, "entity-resource").iterator();
- while (elementIter.hasNext()) {
- Element curElement = (Element) elementIter.next();
+ for (Element curElement: UtilXml.childElementList(ofbizComponentElement, "entity-resource")) {
EntityResourceInfo entityResourceInfo = new EntityResourceInfo(this, curElement);
this.entityResourceInfos.add(entityResourceInfo);
}
// service-resource - serviceResourceInfos
- elementIter = UtilXml.childElementList(ofbizComponentElement, "service-resource").iterator();
- while (elementIter.hasNext()) {
- Element curElement = (Element) elementIter.next();
+ for (Element curElement: UtilXml.childElementList(ofbizComponentElement, "service-resource")) {
ServiceResourceInfo serviceResourceInfo = new ServiceResourceInfo(this, curElement);
this.serviceResourceInfos.add(serviceResourceInfo);
}
// test-suite - serviceResourceInfos
- elementIter = UtilXml.childElementList(ofbizComponentElement, "test-suite").iterator();
- while (elementIter.hasNext()) {
- Element curElement = (Element) elementIter.next();
+ for (Element curElement: UtilXml.childElementList(ofbizComponentElement, "test-suite")) {
TestSuiteInfo testSuiteInfo = new TestSuiteInfo(this, curElement);
this.testSuiteInfos.add(testSuiteInfo);
}
// keystore - (cert/trust store infos)
- elementIter = UtilXml.childElementList(ofbizComponentElement, "keystore").iterator();
- while (elementIter.hasNext()) {
- Element curElement = (Element) elementIter.next();
+ for (Element curElement: UtilXml.childElementList(ofbizComponentElement, "keystore")) {
KeystoreInfo keystoreInfo = new KeystoreInfo(this, curElement);
this.keystoreInfos.add(keystoreInfo);
}
// webapp - webappInfos
- elementIter = UtilXml.childElementList(ofbizComponentElement, "webapp").iterator();
- while (elementIter.hasNext()) {
- Element curElement = (Element) elementIter.next();
+ for (Element curElement: UtilXml.childElementList(ofbizComponentElement, "webapp")) {
WebappInfo webappInfo = new WebappInfo(this, curElement);
this.webappInfos.add(webappInfo);
}
@@ -450,7 +407,7 @@
return isFileResourceLoader(resourceInfo.loader);
}
public boolean isFileResourceLoader(String resourceLoaderName) throws ComponentException {
- ResourceLoaderInfo resourceLoaderInfo = (ResourceLoaderInfo) resourceLoaderInfos.get(resourceLoaderName);
+ ResourceLoaderInfo resourceLoaderInfo = resourceLoaderInfos.get(resourceLoaderName);
if (resourceLoaderInfo == null) {
throw new ComponentException("Could not find resource-loader named: " + resourceLoaderName);
}
@@ -467,7 +424,7 @@
}
public URL getURL(String resourceLoaderName, String location) throws ComponentException {
- ResourceLoaderInfo resourceLoaderInfo = (ResourceLoaderInfo) resourceLoaderInfos.get(resourceLoaderName);
+ ResourceLoaderInfo resourceLoaderInfo = resourceLoaderInfos.get(resourceLoaderName);
if (resourceLoaderInfo == null) {
throw new ComponentException("Could not find resource-loader named: " + resourceLoaderName);
}
@@ -504,12 +461,12 @@
}
public String getFullLocation(String resourceLoaderName, String location) throws ComponentException {
- ResourceLoaderInfo resourceLoaderInfo = (ResourceLoaderInfo) resourceLoaderInfos.get(resourceLoaderName);
+ ResourceLoaderInfo resourceLoaderInfo = resourceLoaderInfos.get(resourceLoaderName);
if (resourceLoaderInfo == null) {
throw new ComponentException("Could not find resource-loader named: " + resourceLoaderName);
}
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
// pre-pend component root location if this is a type component resource-loader
if ("component".equals(resourceLoaderInfo.type)) {
@@ -532,7 +489,7 @@
return buf.toString();
}
- public List getClasspathInfos() {
+ public List<ClasspathInfo> getClasspathInfos() {
return this.classpathInfos;
}
@@ -540,7 +497,7 @@
return this.componentName;
}
- public List getEntityResourceInfos() {
+ public List<EntityResourceInfo> getEntityResourceInfos() {
return this.entityResourceInfos;
}
@@ -548,7 +505,7 @@
return this.globalName;
}
- public Map getResourceLoaderInfos() {
+ public Map<String, ResourceLoaderInfo> getResourceLoaderInfos() {
return this.resourceLoaderInfos;
}
@@ -556,19 +513,19 @@
return this.rootLocation;
}
- public List getServiceResourceInfos() {
+ public List<ServiceResourceInfo> getServiceResourceInfos() {
return this.serviceResourceInfos;
}
- public List getTestSuiteInfos() {
+ public List<TestSuiteInfo> getTestSuiteInfos() {
return this.testSuiteInfos;
}
- public List getKeystoreInfos() {
+ public List<KeystoreInfo> getKeystoreInfos() {
return this.keystoreInfos;
}
- public List getWebappInfos() {
+ public List<WebappInfo> getWebappInfos() {
return this.webappInfos;
}
@@ -699,8 +656,8 @@
public static class WebappInfo {
public ComponentConfig componentConfig;
- public List virtualHosts;
- public Map initParameters;
+ public List<String> virtualHosts;
+ public Map<String, String> initParameters;
public String name;
public String title;
public String server;
@@ -759,21 +716,17 @@
}
// load the virtual hosts
- List virtHostList = UtilXml.childElementList(element, "virtual-host");
+ List<? extends Element> virtHostList = UtilXml.childElementList(element, "virtual-host");
if (virtHostList != null && virtHostList.size() > 0) {
- Iterator elementIter = virtHostList.iterator();
- while (elementIter.hasNext()) {
- Element e = (Element) elementIter.next();
+ for (Element e: virtHostList) {
virtualHosts.add(e.getAttribute("host-name"));
}
}
// load the init parameters
- List initParamList = UtilXml.childElementList(element, "init-param");
+ List<? extends Element> initParamList = UtilXml.childElementList(element, "init-param");
if (initParamList != null && initParamList.size() > 0) {
- Iterator elementIter = initParamList.iterator();
- while (elementIter.hasNext()) {
- Element e = (Element) elementIter.next();
+ for (Element e: virtHostList) {
this.initParameters.put(e.getAttribute("name"), e.getAttribute("value"));
}
}
@@ -802,11 +755,11 @@
return title;
}
- public List getVirtualHosts() {
+ public List<String> getVirtualHosts() {
return virtualHosts;
}
- public Map getInitParameters() {
+ public Map<String, String> getInitParameters() {
return initParameters;
}
}
Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/SSLUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/SSLUtil.java?rev=585750&r1=585749&r2=585750&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/SSLUtil.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/SSLUtil.java Wed Oct 17 16:15:38 2007
@@ -65,10 +65,10 @@
}
if (mgrs != null) {
- for (int i = 0; i < mgrs.length; i++) {
- if (mgrs[i] instanceof X509TrustManager) {
+ for (TrustManager mgr: mgrs) {
+ if (mgr instanceof X509TrustManager) {
try {
- ((X509TrustManager) mgrs[i]).checkClientTrusted(chain, authType);
+ ((X509TrustManager) mgr).checkClientTrusted(chain, authType);
return true;
} catch (CertificateException e) {
// do nothing; just loop
@@ -80,15 +80,12 @@
}
public static KeyManager[] getKeyManagers(String alias) throws IOException, GeneralSecurityException, GenericConfigException {
- Iterator i = ComponentConfig.getAllKeystoreInfos().iterator();
- List keyMgrs = FastList.newInstance();
-
- while (i.hasNext()) {
- ComponentConfig.KeystoreInfo ksi = (ComponentConfig.KeystoreInfo) i.next();
+ List<KeyManager> keyMgrs = FastList.newInstance();
+ for (ComponentConfig.KeystoreInfo ksi: ComponentConfig.getAllKeystoreInfos()) {
if (ksi.isCertStore()) {
KeyStore ks = ksi.getKeyStore();
if (ks != null) {
- List newKeyManagers = Arrays.asList(getKeyManagers(ks, ksi.getPassword(), alias));
+ List<KeyManager> newKeyManagers = Arrays.asList(getKeyManagers(ks, ksi.getPassword(), alias));
keyMgrs.addAll(newKeyManagers);
if (Debug.verboseOn()) Debug.logVerbose("Loaded another cert store, adding [" + (newKeyManagers == null ? "0" : newKeyManagers.size()) + "] KeyManagers for alias [" + alias + "] and keystore: " + ksi.createResourceHandler().getFullLocation(), module);
} else {
@@ -97,7 +94,7 @@
}
}
- return (KeyManager[]) keyMgrs.toArray(new KeyManager[keyMgrs.size()]);
+ return keyMgrs.toArray(new KeyManager[keyMgrs.size()]);
}
public static KeyManager[] getKeyManagers() throws IOException, GeneralSecurityException, GenericConfigException {
@@ -111,9 +108,7 @@
Debug.logWarning("System truststore not found!", module);
}
- Iterator i = ComponentConfig.getAllKeystoreInfos().iterator();
- while (i.hasNext()) {
- ComponentConfig.KeystoreInfo ksi = (ComponentConfig.KeystoreInfo) i.next();
+ for (ComponentConfig.KeystoreInfo ksi: ComponentConfig.getAllKeystoreInfos()) {
if (ksi.isTrustStore()) {
KeyStore ks = ksi.getKeyStore();
if (ks != null) {
@@ -211,15 +206,15 @@
Debug.logWarning(e.getMessage(), module);
return false;
}
- for (int i = 0; i < peerCerts.length; i++) {
- Principal x500s = peerCerts[i].getSubjectDN();
+ for (javax.security.cert.X509Certificate peerCert: peerCerts) {
+ Principal x500s = peerCert.getSubjectDN();
Map subjectMap = KeyStoreUtil.getX500Map(x500s);
if (Debug.infoOn())
- Debug.logInfo(peerCerts[i].getSerialNumber().toString(16) + " :: " + subjectMap.get("CN"), module);
+ Debug.logInfo(peerCert.getSerialNumber().toString(16) + " :: " + subjectMap.get("CN"), module);
try {
- peerCerts[i].checkValidity();
+ peerCert.checkValidity();
} catch (Exception e) {
// certificate not valid
Debug.logWarning("Certificate is not valid!", module);
@@ -272,18 +267,18 @@
static class TrustAnyManager implements X509TrustManager {
- public void checkClientTrusted(X509Certificate[] cert, String string) throws CertificateException {
+ public void checkClientTrusted(X509Certificate[] certs, String string) throws CertificateException {
Debug.logImportant("Trusting (un-trusted) client certificate chain:", module);
- for (int i = 0; i < cert.length; i++) {
- Debug.logImportant("---- " + cert[i].getSubjectX500Principal().getName() + " valid: " + cert[i].getNotAfter(), module);
+ for (X509Certificate cert: certs) {
+ Debug.logImportant("---- " + cert.getSubjectX500Principal().getName() + " valid: " + cert.getNotAfter(), module);
}
}
- public void checkServerTrusted(X509Certificate[] cert, String string) throws CertificateException {
+ public void checkServerTrusted(X509Certificate[] certs, String string) throws CertificateException {
Debug.logImportant("Trusting (un-trusted) server certificate chain:", module);
- for (int i = 0; i < cert.length; i++) {
- Debug.logImportant("---- " + cert[i].getSubjectX500Principal().getName() + " valid: " + cert[i].getNotAfter(), module);
+ for (X509Certificate cert: certs) {
+ Debug.logImportant("---- " + cert.getSubjectX500Principal().getName() + " valid: " + cert.getNotAfter(), module);
}
}
Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilTimer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilTimer.java?rev=585750&r1=585749&r2=585750&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilTimer.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilTimer.java Wed Oct 17 16:15:38 2007
@@ -32,7 +32,7 @@
public class UtilTimer {
public static final String module = UtilTimer.class.getName();
- protected static Map staticTimers = FastMap.newInstance();
+ protected static Map<String, UtilTimer> staticTimers = FastMap.newInstance();
protected String timerName = null;
protected String lastMessage = null;
@@ -220,10 +220,10 @@
}
public static UtilTimer getTimer(String timerName, boolean log) {
- UtilTimer timer = (UtilTimer) staticTimers.get(timerName);
+ UtilTimer timer = staticTimers.get(timerName);
if (timer == null) {
synchronized(UtilTimer.class) {
- timer = (UtilTimer) staticTimers.get(timerName);
+ timer = staticTimers.get(timerName);
if (timer == null) {
timer = new UtilTimer(timerName, false);
timer.setLog(log);
Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections/FlexibleProperties.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections/FlexibleProperties.java?rev=585750&r1=585749&r2=585750&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections/FlexibleProperties.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections/FlexibleProperties.java Wed Oct 17 16:15:38 2007
@@ -193,10 +193,10 @@
return interpolate(value, props, truncateIfMissing, null);
}
- public static String interpolate(String value, Properties props, boolean truncateIfMissing, ArrayList beenThere) {
+ public static String interpolate(String value, Properties props, boolean truncateIfMissing, ArrayList<String> beenThere) {
if (props == null || value == null) return value;
if (beenThere == null) {
- beenThere = new ArrayList();
+ beenThere = new ArrayList<String>();
// Debug.log("[FlexibleProperties.interpolate] starting interpolate: value=[" + value + "]");
} else {// Debug.log("[FlexibleProperties.interpolate] starting sub-interpolate: beenThere=[" + beenThere + "], value=[" + value + "]");
}
@@ -224,7 +224,7 @@
// Debug.log("[FlexibleProperties.interpolate] recursing on key: keyToExpand=[" + keyToExpand + "]");
// save current beenThere and restore after so the later interpolates don't get messed up
- ArrayList tempBeenThere = new ArrayList(beenThere);
+ ArrayList<String> tempBeenThere = new ArrayList<String>(beenThere);
beenThere.add(keyToExpand);
keyToExpand = interpolate(keyToExpand, props, truncateIfMissing, beenThere);
@@ -259,7 +259,7 @@
if (expandValue.indexOf("${") > -1) {
// Debug.log("[FlexibleProperties] recursing on value: expandValue=[" + expandValue + "]");
// save current beenThere and restore after so the later interpolates don't get messed up
- ArrayList tempBeenThere = new ArrayList(beenThere);
+ ArrayList<String> tempBeenThere = new ArrayList<String>(beenThere);
beenThere.add(keyToExpand);
expandValue = interpolate(expandValue, props, truncateIfMissing, beenThere);
@@ -297,14 +297,12 @@
public String toString() {
StringBuilder retVal = new StringBuilder();
- Set keySet = keySet();
- Iterator keys = keySet.iterator();
+ Set<Object> keySet = keySet();
+ for (Object key: keySet) {
+ String keyS = key.toString();
+ String value = getProperty(keyS);
- while (keys.hasNext()) {
- String key = keys.next().toString();
- String value = getProperty(key);
-
- retVal.append(key);
+ retVal.append(keyS);
retVal.append("=");
retVal.append(value);
retVal.append("\n");
Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections/LocalizedMap.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections/LocalizedMap.java?rev=585750&r1=585749&r2=585750&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections/LocalizedMap.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections/LocalizedMap.java Wed Oct 17 16:15:38 2007
@@ -24,6 +24,6 @@
* A simple interface to facilitate the retreival of values based on a Locale.
*
*/
-public interface LocalizedMap {
- public Object get(String name, Locale locale);
+public interface LocalizedMap<V> {
+ public V get(String name, Locale locale);
}
Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections/MapComparator.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections/MapComparator.java?rev=585750&r1=585749&r2=585750&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections/MapComparator.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/collections/MapComparator.java Wed Oct 17 16:15:38 2007
@@ -29,17 +29,17 @@
* MapComparator.java
*
*/
-public class MapComparator implements Comparator {
+public class MapComparator implements Comparator<Map<Object, Object>> {
public static final String module = MapComparator.class.getName();
- private List keys;
+ private List<? extends Object> keys;
/**
* Method MapComparator.
* @param keys List of Map keys to sort on
*/
- public MapComparator(List keys) {
+ public MapComparator(List<? extends Object> keys) {
this.keys = keys;
}
@@ -53,22 +53,13 @@
/**
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
*/
- public int compare(Object obj1, Object obj2) {
- Map map1, map2;
- try {
- map1 = (Map) obj1;
- map2 = (Map) obj2;
- } catch (ClassCastException e) {
- throw new IllegalArgumentException("Objects not from the Map interface");
- }
+ public int compare(Map<Object, Object> map1, Map<Object, Object> map2) {
if (keys == null || keys.size() < 1) {
throw new IllegalArgumentException("No sort fields defined");
}
- Iterator i = keys.iterator();
- while (i.hasNext()) {
- Object key = i.next();
+ for (Object key: keys) {
// if false will be descending, ie reverse order
boolean ascending = true;
@@ -81,8 +72,8 @@
//Debug.logInfo("Doing compare with a FlexibleMapAccessor [" + fmaKey.getOriginalName() + "] ascending [" + ascending + "]", module);
- o1 = fmaKey.get(map1);
- o2 = fmaKey.get(map2);
+ o1 = fmaKey.get((Map) map1);
+ o2 = fmaKey.get((Map) map2);
} else {
if (key instanceof String) {
String keyStr = (String) key;