This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 56861
Collapse All | Expand All

(-)DatabaseConnection.java (-16 / +41 lines)
Lines 20-31 Link Here
20
import java.sql.DriverManager;
20
import java.sql.DriverManager;
21
import java.sql.SQLException;
21
import java.sql.SQLException;
22
import java.text.MessageFormat;
22
import java.text.MessageFormat;
23
import java.util.Collection;
23
import java.util.Collections;
24
import java.util.Collections;
24
import java.util.HashSet;
25
import java.util.HashSet;
25
import java.util.Iterator;
26
import java.util.Iterator;
26
import java.util.Properties;
27
import java.util.Properties;
27
import java.util.ResourceBundle;
28
import java.util.ResourceBundle;
28
import java.util.Set;
29
import java.util.Set;
30
import org.openide.ErrorManager;
31
import org.openide.util.Lookup;
32
import org.openide.util.LookupEvent;
33
import org.openide.util.LookupListener;
29
34
30
import org.openide.util.NbBundle;
35
import org.openide.util.NbBundle;
31
import org.openide.util.RequestProcessor;
36
import org.openide.util.RequestProcessor;
Lines 91-116 Link Here
91
    public static final String PROP_DRIVERNAME = "drivername"; //NOI18N
96
    public static final String PROP_DRIVERNAME = "drivername"; //NOI18N
92
    public static final String PROP_NAME = "name"; //NOI18N
97
    public static final String PROP_NAME = "name"; //NOI18N
93
98
94
    OpenConnectionInterface openConnection;
99
    private OpenConnectionInterface openConnection;
95
100
96
    /** Default constructor */
101
    static private final Lookup.Result openConnectionLookupResult;
97
    public DatabaseConnection() {
102
    static private Collection openConnectionServices = null;
98
        propertySupport = new PropertyChangeSupport(this);
103
    static {
99
        
104
        openConnectionLookupResult = Lookup.getDefault().lookup(new Lookup.Template(OpenConnectionInterface.class));
100
        // For Java Studio Enterprise. Create instanceof OpenConnection
105
        openConnectionLookupResult.addLookupListener(new LookupListener() {
101
        try {
106
            public void resultChanged(LookupEvent ev) {
102
            ClassLoader cl = Thread.currentThread().getContextClassLoader();
107
                synchronized (DatabaseConnection.class) {
103
            try {
108
                    openConnectionServices = null;
104
                openConnection =  (OpenConnectionInterface) Class.forName(bundle.getString("CLASS_open_connection"), true, cl).newInstance();
105
            } catch(ClassNotFoundException cnfe) {
106
                org.openide.ErrorManager.getDefault().log(cnfe.getMessage());
107
            }
109
            }
108
            if (openConnection == null) {
109
                openConnection =  (OpenConnectionInterface) Class.forName(bundle.getString("CLASS_open_connection")).newInstance();
110
            }
110
            }
111
        } catch(Exception ex) {
111
        });            
112
            org.openide.ErrorManager.getDefault().notify(ex);
113
        }
112
        }
113
114
    /** Default constructor */
115
    public DatabaseConnection() {
116
        propertySupport = new PropertyChangeSupport(this);
117
        openConnection = new OpenConnection();
114
    }
118
    }
115
119
116
    /** Advanced constructor
120
    /** Advanced constructor
Lines 128-133 Link Here
128
        pwd = password;
132
        pwd = password;
129
        name = null;
133
        name = null;
130
        name = getName();
134
        name = getName();
135
         
136
         // For Java Studio Enterprise. Create instanceof OpenConnection
137
         try {
138
             Collection c = getOpenConnections();
139
             for (Iterator i=c.iterator(); driver != null && i.hasNext();) {
140
                 OpenConnectionInterface oci = (OpenConnectionInterface) i.next();
141
                 if (oci.isFor(driver)) {
142
                     openConnection = oci;
143
                     break;
144
                 }
145
             }
146
         } catch(Exception ex) {
147
             ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex);
148
         }
149
    }
150
151
     private Collection getOpenConnections() {
152
         if (openConnectionServices == null) {
153
             openConnectionServices = openConnectionLookupResult.allInstances();
154
         }
155
         return openConnectionServices;
131
    }
156
    }
132
157
133
    /** Returns driver URL */
158
    /** Returns driver URL */
(-)OpenConnection.java (+4 lines)
Lines 22-27 Link Here
22
    /** Creates a new instance of OpenConnection */
22
    /** Creates a new instance of OpenConnection */
23
    public OpenConnection() {
23
    public OpenConnection() {
24
    }
24
    }
25
26
    public boolean isFor(String driverName) {
27
        return true;
28
    }
25
    
29
    
26
    public void enable() {
30
    public void enable() {
27
        // No implementation in open source.
31
        // No implementation in open source.
(-)OpenConnectionInterface.java (+1 lines)
Lines 18-23 Link Here
18
 * @author  Administrator
18
 * @author  Administrator
19
 */
19
 */
20
public interface OpenConnectionInterface {
20
public interface OpenConnectionInterface {
21
    public boolean isFor(String driverName);
21
    public void enable();
22
    public void enable();
22
    public void disable();
23
    public void disable();
23
}
24
}

Return to bug 56861