+ This module provides the
+ All Javadoc-specified functionality should be covered by unit tests. +
++ The implementation is done. The target milestone is promo-G. +
+
+ The code completion for Java Persistence API annotations displays database
+ metadata (tables and columns). When the tables or columns change because of the
+ user interaction with the Database Explorer, the code completion needs to refresh
+ the cached metadata. In order to listen on these changes, the code completion
+ registers an implementation of the MetaDataListener
in the
+ Databases/MetaDataListeners
of the system file system.
+ The code completion is the only client of this module at this moment.
+
+ This module provides friend APIs related to the database support. It can + serve as a place to put friend APIs which cannot be exported by the + Database Explorer module, since it already exports a public API. +
++ The module does not contain any UI, so it does not need to be internationalized. +
++ The module does not define nor implement any standards. +
++ The module does not save nor read any settings. +
++ The module requires JRE 1.4. +
++ JRE is enough. +
++ The module does not depend on any projects outside NetBeans. +
++ The module should run in the samy way on all platforms. +
++ Only friend modules can declare a dependency on this module. +
++ Just the module JAR needs to be deployed. +
++ Yes. +
++ Only API packages are exported, and only to the friend modules. +
++ Anywhere. +
++ No. +
++ No. +
++ No. +
++ No. +
++ No. +
++ No. +
++ No. +
++ No. +
++ The API is thread-safe. Events are fired synchronously. +
++ None. +
++ None. +
++ The module does not write any files and it only reads instance files from a folder + in the from the system file system. +
+
+ FolderLookup
is used to locate the clients.
+
+ The module registers an implementation of an interface defined by the + Database Explorer in the default lookup in order to obtain the metadata change events. +
++ No. +
++ No. +
++ No. +
++ None known. +
++ Some memory is needed to store the list of registered clients. +
++ No. +
++ No. +
++ Performance scales linearly with the number of registered clients. +
++ The plugged in code is expected to execute quickly. +
++ No. +
++ No. +
++ No. +
+
+ The module provides its own layer containing the Databases/MetaDataListeners
+ folder in which the clients register their implementations of
+ MetaDataListener
.
+
+ No. +
++ No. +
++ No. +
++ No. +
+dbconn
parameter has changed.
+ *
+ * @param dbconn the database connection whose tables have changed
+ */
+ void tablesChanged(DatabaseConnection dbconn);
+
+ /**
+ * Invoked when the structure of a table in the database represented by the
+ * dbconn
parameter has changed.
+ *
+ * @param dbconn the database connection whose table have changed
+ * @param tableName the name of the table which changed
+ */
+ void tableChanged(DatabaseConnection dbconn, String tableName);
+}
Index: src/org/netbeans/modules/dbapi/DbMetaDataListenerImpl.java
===================================================================
RCS file: src/org/netbeans/modules/dbapi/DbMetaDataListenerImpl.java
diff -N src/org/netbeans/modules/dbapi/DbMetaDataListenerImpl.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/netbeans/modules/dbapi/DbMetaDataListenerImpl.java 3 Apr 2006 13:52:24 -0000
@@ -0,0 +1,56 @@
+/*
+ * Sun Public License Notice
+ *
+ * The contents of this file are subject to the Sun Public License
+ * Version 1.0 (the "License"). You may not use this file except in
+ * compliance with the License. A copy of the License is available at
+ * http://www.sun.com/
+ *
+ * The Original Code is NetBeans. The Initial Developer of the Original
+ * Code is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
+ * Microsystems, Inc. All Rights Reserved.
+ */
+
+package org.netbeans.modules.dbapi;
+
+import java.util.Iterator;
+import org.netbeans.api.db.explorer.DatabaseConnection;
+import org.netbeans.modules.db.api.explorer.MetaDataListener;
+import org.netbeans.modules.db.explorer.DbMetaDataListener;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.Repository;
+import org.openide.loaders.DataFolder;
+import org.openide.loaders.FolderLookup;
+import org.openide.util.Lookup;
+
+/**
+ *
+ * @author Andrei Badea
+ */
+public class DbMetaDataListenerImpl implements DbMetaDataListener {
+
+ /**
+ * Static because of the tests.
+ */
+ static final String REFRESH_LISTENERS_PATH = "Databases/MetaDataListeners"; // NOI18N
+
+ private final Lookup.Result listeners = getListeners();
+
+ public void tablesChanged(DatabaseConnection dbconn) {
+ for (Iterator i = listeners.allInstances().iterator(); i.hasNext();) {
+ ((MetaDataListener)i.next()).tablesChanged(dbconn);
+ }
+ }
+
+ public void tableChanged(DatabaseConnection dbconn, String tableName) {
+ for (Iterator i = listeners.allInstances().iterator(); i.hasNext();) {
+ ((MetaDataListener)i.next()).tableChanged(dbconn, tableName);
+ }
+ }
+
+ private static Lookup.Result getListeners() {
+ FileObject fo = Repository.getDefault().getDefaultFileSystem().findResource(REFRESH_LISTENERS_PATH);
+ DataFolder folder = DataFolder.findFolder(fo);
+ return new FolderLookup(folder).getLookup().lookup(new Lookup.Template(MetaDataListener.class));
+ }
+}
Index: src/org/netbeans/modules/dbapi/resources/Bundle.properties
===================================================================
RCS file: src/org/netbeans/modules/dbapi/resources/Bundle.properties
diff -N src/org/netbeans/modules/dbapi/resources/Bundle.properties
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/netbeans/modules/dbapi/resources/Bundle.properties 3 Apr 2006 13:52:24 -0000
@@ -0,0 +1,4 @@
+OpenIDE-Module-Name=Database APIs
+OpenIDE-Module-Display-Category=Database
+OpenIDE-Module-Short-Description=Database support APIs
+OpenIDE-Module-Long-Description=Provides friend APIs related to the database support.
Index: src/org/netbeans/modules/dbapi/resources/layer.xml
===================================================================
RCS file: src/org/netbeans/modules/dbapi/resources/layer.xml
diff -N src/org/netbeans/modules/dbapi/resources/layer.xml
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/netbeans/modules/dbapi/resources/layer.xml 3 Apr 2006 13:52:24 -0000
@@ -0,0 +1,8 @@
+
+
+