ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(theProxy);
oos.close();
byte[] proxyBytes = baos.toByteArray();
BinaryRefAddr dsAddr = new BinaryRefAddr("ProxyData", proxyBytes);
String factory = DataSourceFactory.class.getName();
Reference dsRef = new Reference("javax.sql.DataSource", dsAddr, factory, null);
referenceable.setReference(dsRef);
// Set the VMID as the address local/remote indicator
baos.reset();
ObjectOutputStream oos2 = new ObjectOutputStream(baos);
oos2.writeObject(DataSourceFactory.vmID);
oos2.close();
byte[] id = baos.toByteArray();
BinaryRefAddr localAddr = new BinaryRefAddr("VMID", id);
dsRef.add(localAddr);
/* Bind the Referenceable connection factory into JNDI and set the
JndiName value of the reference address for use by the DataSourceFactory
when looking up the local factory from the NonSerializableFactory.
*/