Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Java EE 6 require equals() and hashCode() to be implemented for Resource Adapters?

I'm working on upgrading code from JBoss 5.1 to JBoss 7.1 and it fails if these methods are not implemented explicitly in the resource adapters. I understand the concept of each, and know about the contract between the two. I'm not asking about how to implement them or what they mean. I'm asking specifically why they MUST be implemented for Java EE 6 code (in this case JBoss AS 7.1).

Is there a good reason to put a lot of thought into them or is it sufficient to simply have:

boolean equals(Object obj) { return super.equals(obj) ; }
int hashCode() { return super.hashCode() ; }
like image 604
Justin K Avatar asked Nov 12 '22 22:11

Justin K


1 Answers

I think this is because of following

checkout ManagedConnectionFactory here.

see this is an interface and has equals() and hashCode() methods. So Basic java, the first concrete class that implements an interface must define all methods of the interface. Which your resource adapter must be implementing, so it has to define these methods

refer A resource adapter needs to implement ManagedConnectionFactory here.

As per the question above , according to JCA 1.6 spec we need to provide implementation for

A resource adapter must provide implementations of the following interfaces:

javax.resource.spi.ManagedConnectionFactory
javax.resource.spi.ManagedConnection
javax.resource.spi.ManagedConnectionMetaData

Which wasnt the case with 1.5

So that is why it gives error during Validation

The JCA validator has become more stringent with version 1.6 , thus the error.

Nothing is much clear about this , there are lot of question and posts on internet about the same issue. Best possible explanation i found was the "requirement" of providing a connection factory.

Also in case you need to bypass the error , you will either need to switch to JCA 1.5 or disable the with 1.6

like image 192
Mukul Goel Avatar answered Nov 15 '22 12:11

Mukul Goel