-
1. Re: BaseConnectionManager2.managedConnectionToListenerMap
deegs_ca Aug 12, 2002 6:05 PM (in response to deegs_ca)apologies, what I meant was obtain a javax.resource.cci.Connection from a servlet context i.e. using jndi, then connection factory etc...
Again, much obliged for the help.
-cheers -
2. Re: BaseConnectionManager2.managedConnectionToListenerMap
deegs_ca Aug 12, 2002 10:57 PM (in response to deegs_ca)I tweaked a little with the source from BaseConnectionManager2 and instead of using the whole object as the key, I put it into the map with the toString() method.
i.e. instead of
hash.put(o1, o2);
i use
hash.put(o1.toString(), o2)
this is not a solution but the lookup is succeeding now. However, this only exposes other areas in the code which fall victim to the same failing hashmap lookup.
-d -
3. Re: BaseConnectionManager2.managedConnectionToListenerMap
davidjencks Aug 13, 2002 10:56 PM (in response to deegs_ca)I think you failed to properly implement equals and hashCode in your ManagedConnection. This is the normal way to fail at hashmap lookup. I found Effective Java to have very useful advice on correctly implementing these methods.
-
4. Re: BaseConnectionManager2.managedConnectionToListenerMap
davidjencks Aug 18, 2002 9:53 PM (in response to deegs_ca)My previous response doesn't make any sense. However, I think you have implemented equals and hashCode in your ManagedConnection implementation.
Why? Do you need it for some purpose?
The ManagedConnection interface does not include equals or hashCode. The jca 1.5 spec does indicate clearly when you are required to implement equals and hashCode. Although several classes are prohibited from implementing equals and hashCode, these are all new in jca 1.5. I think leaving out a prohibition for implementing equals and hashCode is an oversight in the specification. -
5. Re: BaseConnectionManager2.managedConnectionToListenerMap
deegs_ca Aug 20, 2002 12:14 PM (in response to deegs_ca)David,
I discovered what was causing my problem and it was self inflicted.
I was using the java.lang.reflect.Proxy and java.lang.reflect.Invocationhandler to activate logging of all the methods in my jca interface implementations.
For a brief discussion of this see
http://developer.java.sun.com/developer/TechTips/2000/tt0530.html#tip1
What this does is allow me to create a new class at runtime which wraps every method defined on the class's interfaces, implements the required interfaces, and gives me an intercept point to insert, in this case, logging without sprinkling logging code throughout my source.
Somehow, a reference to the unwrapped object was getting used to lookup the wrapped object or vice versa. Thus, wrapped_object != object implies failing hashmap lookup.
In regards to implementing hashCode and equals, at first I implemented them where the interfaces requested and the spec recommended. But then I saw no point to this, for much the same reasons you stated. i.e. it is unnecessary. Why should I guess about how the container spi will store my objects.
At any rate, I disabled the logging and everything worked.
many thanks
-doug -
6. Re: BaseConnectionManager2.managedConnectionToListenerMap
deegs_ca Aug 20, 2002 12:17 PM (in response to deegs_ca)Apologize if this is a duplicate, but the following response did not appear....
>> begin
David,
I discovered what was causing my problem and it was self inflicted.
I was using the java.lang.reflect.Proxy and java.lang.reflect.Invocationhandler to activate logging of all the methods in my jca interface implementations.
For a brief discussion of this see
http://developer.java.sun.com/developer/TechTips/2000/tt0530.html#tip1
What this does is allow me to create a new class at runtime which wraps every method defined on the class's interfaces, implements the required interfaces, and gives me an intercept point to insert, in this case, logging without sprinkling logging code throughout my source.
Somehow, a reference to the unwrapped object was getting used to lookup the wrapped object or vice versa. Thus, wrapped_object != object implies failing hashmap lookup.
In regards to implementing hashCode and equals, at first I implemented them where the interfaces requested and the spec recommended. But then I saw no point to this, for much the same reasons you stated. i.e. it is unnecessary. Why should I guess about how the container spi will store my objects.
At any rate, I disabled the logging and everything worked.
many thanks
-doug