* @param clr ClassLoader resolver for resolving the adapter class
* @return the adapater class
*/
protected Class getAdapterClass(PluginManager pluginMgr, String adapterClassName, String productName, ClassLoaderResolver clr)
{
ConfigurationElement highestMatchingAdapter = null;
int highestPriority = Integer.MIN_VALUE;
Extension[] ex = pluginMgr.getExtensionPoint("org.jpox.store_datastoreadapter").getExtensions();
for (int i = 0; i < ex.length; i++)
{
ConfigurationElement[] confElm = ex[i].getConfigurationElements();
for (int c = 0; c < confElm.length; c++)
{
if (adapterClassName != null)
{
//if the user selected adapter is defined by one of the plug-ins use the classloader of the plug-in
if (confElm[c].getAttribute("class-name").equals(adapterClassName))
{
return pluginMgr.loadClass(confElm[c].getExtension().getPlugin().getSymbolicName(), confElm[c].getAttribute("class-name"));
}
}
else
{
String vendorId = confElm[c].getAttribute("vendor-id");
if (productName.toLowerCase().indexOf(vendorId.toLowerCase()) >= 0)
{
int priority = Integer.parseInt(confElm[c].getAttribute("priority"));
if (priority >= highestPriority)
{
if (priority > highestPriority && highestMatchingAdapter != null)
{
JPOXLogger.DATASTORE.warn(LOCALISER.msg("051002",
highestMatchingAdapter.getAttribute("class-name"), highestMatchingAdapter.getAttribute("vendor-id"),
String.valueOf(priority), confElm[c].getAttribute("class-name")));
}
highestMatchingAdapter = confElm[c];
highestPriority = priority;
}
}
}
}
}
if (adapterClassName != null)
{
//if the user selected adapter was not found in one of the plug-ins, load from the ClassLoaderResolver
return clr.classForName(adapterClassName, false);
}
if (highestMatchingAdapter != null)
{
return pluginMgr.loadClass(highestMatchingAdapter.getExtension().getPlugin().getSymbolicName(), highestMatchingAdapter.getAttribute("class-name"));
}
return null;
}