Skip to content

Commit 30ad07a

Browse files
committed
SpringContextResourceAdapter implements equals/hashCode according to the JCA 1.5 contract
Issue: SPR-9162
1 parent 0ed1a21 commit 30ad07a

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

org.springframework.transaction/src/main/java/org/springframework/jca/context/SpringContextResourceAdapter.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2008 the original author or authors.
2+
* Copyright 2002-2013 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,6 +33,7 @@
3333
import org.springframework.context.ConfigurableApplicationContext;
3434
import org.springframework.core.env.ConfigurableEnvironment;
3535
import org.springframework.core.env.StandardEnvironment;
36+
import org.springframework.util.ObjectUtils;
3637
import org.springframework.util.StringUtils;
3738

3839
/**
@@ -87,7 +88,7 @@
8788
* Note that "META-INF/applicationContext.xml" is the default context config
8889
* location, so it doesn't have to specified unless you intend to specify
8990
* different/additional config files. So in the default case, you may remove
90-
* the entire <code>config-property</code> section above.
91+
* the entire {@code config-property} section above.
9192
*
9293
* <p><b>For simple deployment needs, all you need to do is the following:</b>
9394
* Package all application classes into a RAR file (which is just a standard
@@ -222,10 +223,23 @@ public void endpointDeactivation(MessageEndpointFactory messageEndpointFactory,
222223
}
223224

224225
/**
225-
* This implementation always returns <code>null</code>.
226+
* This implementation always returns {@code null}.
226227
*/
227228
public XAResource[] getXAResources(ActivationSpec[] activationSpecs) throws ResourceException {
228229
return null;
229230
}
230231

232+
233+
@Override
234+
public boolean equals(Object obj) {
235+
return (obj instanceof SpringContextResourceAdapter &&
236+
ObjectUtils.nullSafeEquals(getContextConfigLocation(),
237+
((SpringContextResourceAdapter) obj).getContextConfigLocation()));
238+
}
239+
240+
@Override
241+
public int hashCode() {
242+
return ObjectUtils.nullSafeHashCode(getContextConfigLocation());
243+
}
244+
231245
}

0 commit comments

Comments
 (0)