From: jprocter Date: Fri, 16 Nov 2007 15:07:18 +0000 (+0000) Subject: added generic method for adding new database proxies by reflection on instance. X-Git-Tag: Release_2_4~183 X-Git-Url: http://source.jalview.org/gitweb/?p=jalview.git;a=commitdiff_plain;h=300c01c1363c3d0d0f92df3750a07314479ed7ca added generic method for adding new database proxies by reflection on instance. --- diff --git a/src/jalview/ws/seqfetcher/ASequenceFetcher.java b/src/jalview/ws/seqfetcher/ASequenceFetcher.java index 7b455bf..9c2bfd4 100644 --- a/src/jalview/ws/seqfetcher/ASequenceFetcher.java +++ b/src/jalview/ws/seqfetcher/ASequenceFetcher.java @@ -201,4 +201,49 @@ public class ASequenceFetcher return dbs; } + /** + * constructs and instance of the proxy and registers it as a valid + * dbrefsource + * + * @param dbSourceProxy + * reference for class implementing + * jalview.ws.seqfetcher.DbSourceProxy + * @throws java.lang.IllegalArgumentException + * if class does not implement + * jalview.ws.seqfetcher.DbSourceProxy + */ + protected void addDBRefSourceImpl(Class dbSourceProxy) + throws java.lang.IllegalArgumentException + { + try + { + Object proxyObj = dbSourceProxy.getConstructor( + null).newInstance(null); + if (!DbSourceProxy.class.isInstance(proxyObj)) + { + throw new IllegalArgumentException( + dbSourceProxy.toString() + + " does not implement the jalview.ws.seqfetcher.DbSourceProxy"); + } + DbSourceProxy proxy = (DbSourceProxy) proxyObj; + if (proxy != null) + { + if (FETCHABLEDBS == null) + { + FETCHABLEDBS = new Hashtable(); + } + FETCHABLEDBS.put(proxy.getDbSource(), proxy); + } + } + catch (IllegalArgumentException e) + { + throw e; + } + catch (Exception e) + { + // Serious problems if this happens. + throw new Error("DBRefSource Implementation Exception", e); + } + } + } \ No newline at end of file