user manual
Chapter 27: Using VisiConnect 327
Other Considerations
javax.naming.spi.ObjectFactory implemenation source Adapter with backup
mechanism for JNDI Reference-based connection factory lookup.
■
The Resource Adapter which specifies an connection factory or connection
interface while not implementing that interface in its connection factory or
connection class, respectively. Section 10.6 "Resource Adapter XML DTD"
in the Connectors spec discusses the related requirements. To illustrate,
let's say that in the ra.xml of a particular Resource Adapter, you have the
following elements:
//...
<connection-interface>java.sql.Connection</connection-interface>
<connection-impl-class>com.shme.shmeAdapter.ShmeConnection</connection-
impl-class>
//...
But your implementation of ShmeConnection is as follows:
package shme;
public class ShmeConnection
{
private ShmeManagedConnection mc;
public ShmeConnection( ShmeManagedConnection mc )
{
System.out.println( "In ShmeConnection" );
this.mc = mc;
}
}
Any attempt to invoke getConnection() on this Resource Adapter's connection
factory will result in a java.lang.ClassCastException, as you're indicating to the
appserver in ra.xml that connection objects returned by the Resource Adapter
are to be cast to java.sql.Connection.
Working with a Poor Resource Adapter Implementation
To work around a poor Resource Adapter implementation, perform the
following:
Extend the connection factory and/or connection class of the Local Connector,
and have the extension correctly implement the poorly implemented code. For
example, when dealing with a connection factory which implements
Serializable, and doesn't implement Referenceable the idea is to extend the
original connection factory to implement Referenceable, which means
implementing getReference() and setReference().
To illustrate, if the connection factory is com.shme.BadConnectionFactory, extend
the connection factory as com.shme.GoodConnectionFactory, and implement
Referenceable as follows:
package com.shme.shmeAdapter;
public class GoodConnectionFactory
{










