if (!targetClass.isAssignableFrom(CommonDataSource.class)) return null;
CommonDataSource<Z, D, F> result = targetClass.asSubclass(CommonDataSource.class).newInstance();
RefAddr clusterAddr = reference.get(CLUSTER);
if (clusterAddr == null) return null;
Object clusterAddrContent = clusterAddr.getContent();
if (!(clusterAddrContent instanceof String)) return null;
result.setCluster((String) clusterAddrContent);
RefAddr configAddr = reference.get(CONFIG);
if (configAddr == null) return null;
Object configAddrContent = configAddr.getContent();
if (configAddrContent == null) return null;
if (configAddrContent instanceof String)
{
result.setConfig((String) configAddrContent);
}
else if (configAddrContent instanceof byte[])
{
byte[] config = (byte[]) configAddrContent;
result.setConfigurationFactory(Objects.<DatabaseClusterConfigurationFactory<Z, D>>deserialize(config));
}
RefAddr userAddr = reference.get(USER);
if (userAddr != null)
{
Object userAddrContent = userAddr.getContent();
if (userAddrContent instanceof String)
{
result.setUser((String) userAddrContent);
}
}
RefAddr passwordAddr = reference.get(USER);
if (passwordAddr != null)
{
Object passwordAddrContent = passwordAddr.getContent();
if (passwordAddrContent instanceof String)
{
result.setPassword((String) passwordAddrContent);
}
}