From 30ad07a4e2f86887dc5987a63f07db4d79c7e4e0 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 9 Jan 2013 18:42:51 +0100 Subject: [PATCH] SpringContextResourceAdapter implements equals/hashCode according to the JCA 1.5 contract Issue: SPR-9162 --- .../context/SpringContextResourceAdapter.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/org.springframework.transaction/src/main/java/org/springframework/jca/context/SpringContextResourceAdapter.java b/org.springframework.transaction/src/main/java/org/springframework/jca/context/SpringContextResourceAdapter.java index 418bcc4cec..94aef9ba20 100644 --- a/org.springframework.transaction/src/main/java/org/springframework/jca/context/SpringContextResourceAdapter.java +++ b/org.springframework.transaction/src/main/java/org/springframework/jca/context/SpringContextResourceAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2013 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. @@ -33,6 +33,7 @@ import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.env.StandardEnvironment; +import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; /** @@ -87,7 +88,7 @@ import org.springframework.util.StringUtils; * Note that "META-INF/applicationContext.xml" is the default context config * location, so it doesn't have to specified unless you intend to specify * different/additional config files. So in the default case, you may remove - * the entire config-property section above. + * the entire {@code config-property} section above. * *

For simple deployment needs, all you need to do is the following: * Package all application classes into a RAR file (which is just a standard @@ -222,10 +223,23 @@ public class SpringContextResourceAdapter implements ResourceAdapter { } /** - * This implementation always returns null. + * This implementation always returns {@code null}. */ public XAResource[] getXAResources(ActivationSpec[] activationSpecs) throws ResourceException { return null; } + + @Override + public boolean equals(Object obj) { + return (obj instanceof SpringContextResourceAdapter && + ObjectUtils.nullSafeEquals(getContextConfigLocation(), + ((SpringContextResourceAdapter) obj).getContextConfigLocation())); + } + + @Override + public int hashCode() { + return ObjectUtils.nullSafeHashCode(getContextConfigLocation()); + } + }