protected static synchronized CollectionAdapter createAdapterInstance(
FeedConfiguration config,
Abdera abdera)
throws Exception {
CollectionAdapter basicAdapter = adapterInstanceMap.get(config.getFeedId());
if (basicAdapter != null) {
return basicAdapter;
}
ClassLoader cl = Thread.currentThread().getContextClassLoader();
Class<?> adapterClass = cl.loadClass(config.getAdapterClassName());
Constructor<?>[] ctors = adapterClass.getConstructors();
for (Constructor<?> element : ctors) {
logger.finest("Public constructor found: " +
element.toString());
}
Constructor<?> c =
adapterClass.getConstructor(
new Class[] {
Abdera.class,
FeedConfiguration.class});
c.setAccessible(true);
CollectionAdapter adapterInstance =
(CollectionAdapter) c.newInstance(
abdera, config);
// put this adapter instance in adapterInstanceMap
adapterInstanceMap.put(config.getFeedId(), adapterInstance);