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 89439
Collapse All | Expand All

(-)apichanges.xml (+19 lines)
Lines 86-91 Link Here
86
    <!-- ACTUAL CHANGES BEGIN HERE: -->
86
    <!-- ACTUAL CHANGES BEGIN HERE: -->
87
87
88
    <changes>
88
    <changes>
89
        <change id="jdbcDriverDeployment">
90
            <api name="j2eeserver"/>
91
            <summary>
92
                Adding an API for JDBC driver deployment.
93
            </summary>
94
            <version major="1" minor="24"/>
95
            <date day="28" month="3" year="2007"/>
96
            <author login="sherold"/>
97
            <compatibility binary="compatible" source="compatible" semantic="compatible" addition="yes"/>
98
            <description>
99
                <p>
100
		    API for JDBC driver deployment and a utility class for working with data sources was added.
101
		</p>
102
            </description>
103
            <class package="org.netbeans.modules.j2ee.deployment.common.api" name="DatasourceHelper"/>
104
            <class package="org.netbeans.modules.j2ee.deployment.plugins.spi" name="JDBCDriverDeployer"/>
105
	    <class package="org.netbeans.modules.j2ee.deployment.plugins.spi" name="OptionalDeploymentManagerFactory"/>
106
            <issue number="89439"/>
107
        </change>
89
        <change id="ensureResourceDefinedUpdate">
108
        <change id="ensureResourceDefinedUpdate">
90
            <api name="j2eeserver"/>
109
            <api name="j2eeserver"/>
91
            <summary>
110
            <summary>
(-)nbproject/project.properties (-1 / +1 lines)
Lines 17-23 Link Here
17
17
18
is.autoload=true
18
is.autoload=true
19
javac.source=1.5
19
javac.source=1.5
20
spec.version.base=1.21.0
20
spec.version.base=1.24.0
21
21
22
javadoc.overview=${basedir}/api/doc/overview.html
22
javadoc.overview=${basedir}/api/doc/overview.html
23
javadoc.arch=${basedir}/arch.xml
23
javadoc.arch=${basedir}/arch.xml
(-)src/org/netbeans/modules/j2ee/deployment/common/api/DatasourceHelper.java (+106 lines)
Added Link Here
1
/*
2
 * The contents of this file are subject to the terms of the Common Development
3
 * and Distribution License (the License). You may not use this file except in
4
 * compliance with the License.
5
 *
6
 * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7
 * or http://www.netbeans.org/cddl.txt.
8
 *
9
 * When distributing Covered Code, include this CDDL Header Notice in each file
10
 * and include the License file at http://www.netbeans.org/cddl.txt.
11
 * If applicable, add the following below the CDDL Header, with the fields
12
 * enclosed by brackets [] replaced by your own identifying information:
13
 * "Portions Copyrighted [year] [name of copyright owner]"
14
 *
15
 * The Original Software is NetBeans. The Initial Developer of the Original
16
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17
 * Microsystems, Inc. All Rights Reserved.
18
 */
19
20
package org.netbeans.modules.j2ee.deployment.common.api;
21
22
import java.util.ArrayList;
23
import java.util.Collections;
24
import java.util.List;
25
import org.netbeans.api.db.explorer.ConnectionManager;
26
import org.netbeans.api.db.explorer.DatabaseConnection;
27
import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider;
28
29
/**
30
 * An utility class for working with data sources.
31
 *
32
 * @author Andrei Badea
33
 *
34
 * @since 1.24
35
 */
36
public class DatasourceHelper {
37
38
    private DatasourceHelper() {
39
    }
40
41
    /**
42
     * Finds the database connections whose database URL and user name equal
43
     * the database URL and the user name of the passed data source.
44
     *
45
     * @param  datasource the data source.
46
     *
47
     * @return the list of database connections; never null.
48
     *
49
     * @throws NullPointerException if the datasource parameter was null.
50
     */
51
    public static List<DatabaseConnection> findDatabaseConnections(Datasource datasource) {
52
        if (datasource == null) {
53
            throw new NullPointerException("The datasource parameter cannot be null."); // NOI18N
54
        }
55
        String databaseUrl = datasource.getUrl();
56
        String user = datasource.getUsername();
57
        if (databaseUrl == null || user == null) {
58
            return Collections.emptyList();
59
        }
60
        List<DatabaseConnection> result = new ArrayList<DatabaseConnection>();
61
        for (DatabaseConnection dbconn : ConnectionManager.getDefault().getConnections()) {
62
            if (databaseUrl.equals(dbconn.getDatabaseURL()) && user.equals(dbconn.getUser())) {
63
                result.add(dbconn);
64
            }
65
        }
66
        if (result.size() > 0) {
67
            return Collections.unmodifiableList(result);
68
        } else {
69
            return Collections.emptyList();
70
        }
71
    }
72
73
    /**
74
     * Finds the data source with the given JNDI name in the module and
75
     * project data sources of the given provider.
76
     *
77
     * @param  provider the {@link J2eeModuleProvider provider} whose data sources 
78
     *         are to be searched; cannot be null.
79
     * @param  jndiName the JNDI name to search for; cannot be null.
80
     *
81
     * @return the found data source or null if no data source was found.
82
     *
83
     * @throws NullPointerException if either the <code>provider</code>
84
     *         or the <code>jndiName</code> parameter was null.
85
     */
86
    public static Datasource findDatasource(J2eeModuleProvider provider, String jndiName) 
87
    throws ConfigurationException {
88
        if (provider == null) {
89
            throw new NullPointerException("The provider parameter cannot be null."); // NOI18N
90
        }
91
        if (jndiName == null) {
92
            throw new NullPointerException("The jndiName parameter cannot be null."); // NOI18N
93
        }
94
        for (Datasource datasource : provider.getServerDatasources()) {
95
            if (jndiName.equals(datasource.getJndiName())) {
96
                return datasource;
97
            }
98
        }
99
        for (Datasource datasource : provider.getModuleDatasources()) {
100
            if (jndiName.equals(datasource.getJndiName())) {
101
                return datasource;
102
            }
103
        }
104
        return null;
105
    }
106
}
(-)src/org/netbeans/modules/j2ee/deployment/plugins/spi/JDBCDriverDeployer.java (+59 lines)
Added Link Here
1
/*
2
 * The contents of this file are subject to the terms of the Common Development
3
 * and Distribution License (the License). You may not use this file except in
4
 * compliance with the License.
5
 *
6
 * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7
 * or http://www.netbeans.org/cddl.txt.
8
 *
9
 * When distributing Covered Code, include this CDDL Header Notice in each file
10
 * and include the License file at http://www.netbeans.org/cddl.txt.
11
 * If applicable, add the following below the CDDL Header, with the fields
12
 * enclosed by brackets [] replaced by your own identifying information:
13
 * "Portions Copyrighted [year] [name of copyright owner]"
14
 *
15
 * The Original Software is NetBeans. The Initial Developer of the Original
16
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17
 * Microsystems, Inc. All Rights Reserved.
18
 */
19
20
package org.netbeans.modules.j2ee.deployment.plugins.spi;
21
22
import java.util.Set;
23
import javax.enterprise.deploy.spi.Target;
24
import javax.enterprise.deploy.spi.status.ProgressObject;
25
import org.netbeans.modules.j2ee.deployment.common.api.Datasource;
26
27
/**
28
 * JDBC driver deployer useful for deploying drivers to the server.
29
 * <p>
30
 * Implementation of JDBC driver deployer should be registerd via the {@link 
31
 * OptionalDeploymentManagerFactory}.
32
 * 
33
 * @author sherold
34
 * 
35
 * @since 1.24
36
 */
37
public interface JDBCDriverDeployer {
38
    
39
    /**
40
     * Returns true if the specified target supports deployment of JDBC drivers,
41
     * false otherwise.
42
     * 
43
     * @params target the JDBC drivers maight be deployed to.
44
     * 
45
     * @return true if the specified target supports deployment of JDBC drivers,
46
     *         false otherwise.
47
     */
48
    boolean supportsDeployJDBCDrivers(Target target);
49
    
50
    /**
51
     * Deploys JDBC drivers for all the specified resources to the specified target
52
     * server if the drivers have not been deployed yet.
53
     * 
54
     * @param target where the drivers should be deployed to.
55
     * @param datasources 
56
     */
57
    ProgressObject deployJDBCDrivers(Target target, Set<Datasource> datasources);
58
    
59
}
(-)src/org/netbeans/modules/j2ee/deployment/plugins/spi/OptionalDeploymentManagerFactory.java (+13 lines)
Lines 93-96 Link Here
93
    public DatasourceManager getDatasourceManager(DeploymentManager dm) {
93
    public DatasourceManager getDatasourceManager(DeploymentManager dm) {
94
        return null;
94
        return null;
95
    }
95
    }
96
    
97
    /**
98
     * Creates a JDBC driver deployer for the specified deployment manager.
99
     * 
100
     * @param dm deployment manager.
101
     * 
102
     * @return JDBC driver deployer for the specified deployment manager or null
103
     *         if JDBC driver deployment is not supported.
104
     * @since 1.24
105
     */
106
    public JDBCDriverDeployer getJDBCDriverDeployer(DeploymentManager dm) {
107
        return null;
108
    }
96
}
109
}

Return to bug 89439