1 19 20 package org.netbeans.modules.dbapi; 21 22 import java.util.Iterator ; 23 import org.netbeans.api.db.explorer.DatabaseConnection; 24 import org.netbeans.modules.db.api.explorer.MetaDataListener; 25 import org.netbeans.modules.db.explorer.DbMetaDataListener; 26 import org.openide.filesystems.FileObject; 27 import org.openide.filesystems.Repository; 28 import org.openide.loaders.DataFolder; 29 import org.openide.loaders.FolderLookup; 30 import org.openide.util.Lookup; 31 32 36 public class DbMetaDataListenerImpl implements DbMetaDataListener { 37 38 41 static final String REFRESH_LISTENERS_PATH = "Databases/MetaDataListeners"; 43 private final Lookup.Result listeners = getListeners(); 44 45 public void tablesChanged(DatabaseConnection dbconn) { 46 for (Iterator i = listeners.allInstances().iterator(); i.hasNext();) { 47 ((MetaDataListener)i.next()).tablesChanged(dbconn); 48 } 49 } 50 51 public void tableChanged(DatabaseConnection dbconn, String tableName) { 52 for (Iterator i = listeners.allInstances().iterator(); i.hasNext();) { 53 ((MetaDataListener)i.next()).tableChanged(dbconn, tableName); 54 } 55 } 56 57 private static Lookup.Result getListeners() { 58 FileObject fo = Repository.getDefault().getDefaultFileSystem().findResource(REFRESH_LISTENERS_PATH); 59 DataFolder folder = DataFolder.findFolder(fo); 60 return new FolderLookup(folder).getLookup().lookup(new Lookup.Template(MetaDataListener.class)); 61 } 62 } 63 | Popular Tags |