String className = getClass().getName();
String factoryClassName = this.getClass().getName();
Reference ref = new Reference(className, factoryClassName, null);
if (getName() != null) {
ref.add(new StringRefAddr(SOURCE_NAME, getName()));
}
if (getRootNodeUuid() != null) {
ref.add(new StringRefAddr(ROOT_NODE_UUID, getRootNodeUuid()));
}
if (getDataSourceName() != null) {
ref.add(new StringRefAddr(DATA_SOURCE_JNDI_NAME, getDataSourceName()));
}
if (getUserName() != null) {
ref.add(new StringRefAddr(USERNAME, getUserName()));
}
if (getPassword() != null) {
ref.add(new StringRefAddr(PASSWORD, getPassword()));
}
if (getDatabaseUrl() != null) {
ref.add(new StringRefAddr(URL, getDatabaseUrl()));
}
if (getDriverClassName() != null) {
ref.add(new StringRefAddr(DRIVER_CLASS_NAME, getDriverClassName()));
}
if (getDefaultCachePolicy() != null) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
CachePolicy policy = getDefaultCachePolicy();
try {
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(policy);
ref.add(new BinaryRefAddr(DEFAULT_CACHE_POLICY, baos.toByteArray()));
} catch (IOException e) {
I18n msg = JdbcMetadataI18n.errorSerializingCachePolicyInSource;
throw new RepositorySourceException(getName(), msg.text(policy.getClass().getName(), getName()), e);
}
}
ref.add(new StringRefAddr(RETRY_LIMIT, Integer.toString(getRetryLimit())));
// return it
return ref;
}