Package org.apache.cayenne.conn

Examples of org.apache.cayenne.conn.DataSourceInfo


     */
    public DataSourceInfo getConnectionInfo(String name) {
       
        if (EMBEDDED_DATASOURCE.equals(name)) {
            // Create embedded data source instead
            DataSourceInfo connectionInfo = new DataSourceInfo();
            connectionInfo.setAdapterClassName(EMBEDDED_DATASOURCE_DBADAPTER);
            connectionInfo.setUserName(EMBEDDED_DATASOURCE_USERNAME);
            connectionInfo.setPassword(EMBEDDED_DATASOURCE_PASSWORD);
            connectionInfo.setDataSourceUrl(EMBEDDED_DATASOURCE_URL);
            connectionInfo.setJdbcDriver(EMBEDDED_DATASOURCE_JDBC_DRIVER);
            return connectionInfo;
        }

        synchronized (connectionInfos) {
            return (DataSourceInfo) connectionInfos.get(name);
View Full Code Here


    /**
    * Creates a DataSourceInfo object from a set of properties.
    */
    protected DataSourceInfo buildDataSourceInfo(ExtendedProperties props) {
        DataSourceInfo dsi = new DataSourceInfo();

        dsi.setAdapterClassName(props.getString(ADAPTER_KEY));
        dsi.setUserName(props.getString(USER_NAME_KEY));
        dsi.setPassword(props.getString(PASSWORD_KEY));
        dsi.setDataSourceUrl(props.getString(URL_KEY));
        dsi.setJdbcDriver(props.getString(DRIVER_KEY));

        return dsi;
    }
View Full Code Here

        return new ProjectDataSource(this.getDriverInfo());
    }

    protected DataSourceInfo getDriverInfo() {
        DataSourceInfo temp = super.getDriverInfo();
        if (null == temp) {
            temp = new DataSourceInfo();
        }

        return temp;
    }
View Full Code Here

        }

        public void init(String name, Attributes attrs) {
            String className = attrs.getValue("", "class");
            logger.info("loading driver " + className);
            driverInfo = new DataSourceInfo();
            driverInfo.setJdbcDriver(className);
        }
View Full Code Here

    public DriverDataSourceFactory(@Inject AdhocObjectFactory objectFactory) {
        this.objectFactory = objectFactory;
    }

    public DataSource getDataSource(DataNodeDescriptor nodeDescriptor) throws Exception {
        DataSourceInfo properties = nodeDescriptor.getDataSourceDescriptor();
        if (properties == null) {
            throw new IllegalArgumentException("'nodeDescriptor' contains no datasource descriptor");
        }

        Driver driver = objectFactory.newInstance(Driver.class, properties.getJdbcDriver());
        return new DriverDataSource(driver, properties.getDataSourceUrl(), properties.getUserName(),
                properties.getPassword());
    }
View Full Code Here

    /**
     * Loads connection properties from $HOME/.cayenne/connection.properties.
     */
    protected static ConnectionProperties loadDefaultProperties() {

        DataSourceInfo dsi = new DataSourceInfo();

        String adapter = System.getProperty(ADAPTER_KEY_MAVEN);
        String usr = System.getProperty(USER_NAME_KEY_MAVEN);
        String pass = System.getProperty(PASSWORD_KEY_MAVEN);
        String url = System.getProperty(URL_KEY_MAVEN);
        String driver = System.getProperty(DRIVER_KEY_MAVEN);

        File f = new File(cayenneUserDir(), PROPERTIES_FILE);

        try {
            if (f.exists()) {

                ConnectionProperties cp = new ConnectionProperties(
                        new ExtendedProperties(f.getAbsolutePath()));

                if (((adapter != null && !adapter.startsWith("$"))
                        || (usr != null && !usr.startsWith("$"))
                        || (pass != null && !pass.startsWith("$"))
                        || (url != null && !url.startsWith("$")) || (driver != null && !driver
                        .startsWith("$")))
                        && (System.getProperty("cayenneTestConnection") != null && !System
                                .getProperty("cayenneTestConnection")
                                .equals("null"))) {

                    DataSourceInfo dsiOld = null;
                    if (connectionInfos.get(System.getProperty("cayenneTestConnection")) != null) {
                        dsiOld = connectionInfos.get(System
                                .getProperty("cayenneTestConnection"));
                        connectionInfos.remove(System
                                .getProperty("cayenneTestConnection"));
                    }

                    if (adapter != null && !adapter.startsWith("$")) {
                        dsi.setAdapterClassName(adapter);
                    }
                    else if (dsiOld != null) {
                        dsi.setAdapterClassName(dsiOld.getAdapterClassName());
                    }
                    if (usr != null && !usr.startsWith("$")) {
                        dsi.setUserName(usr);
                    }
                    else if (dsiOld != null) {
                        dsi.setUserName(dsiOld.getUserName());
                    }
                    if (pass != null && !pass.startsWith("$")) {
                        dsi.setPassword(pass);
                    }
                    else if (dsiOld != null) {
                        dsi.setPassword(dsiOld.getPassword());
                    }
                    if (url != null && !url.startsWith("$")) {
                        dsi.setDataSourceUrl(url);
                    }
                    else if (dsiOld != null) {
                        dsi.setDataSourceUrl(dsiOld.getDataSourceUrl());
                    }
                    if (driver != null && !driver.startsWith("$")) {
                        dsi.setJdbcDriver(driver);
                    }
                    else if (dsiOld != null) {
                        dsi.setJdbcDriver(dsiOld.getJdbcDriver());
                    }
                    connectionInfos.put(System.getProperty("cayenneTestConnection"), dsi);
                }
                else {
                    return cp;
View Full Code Here

    /**
     * Constructor for ConnectionProperties.
     */
    public ConnectionProperties(ExtendedProperties props) {
        for (final String name : extractNames(props)) {
            DataSourceInfo dsi = buildDataSourceInfo(props.subset(name));
            connectionInfos.put(name, dsi);
        }
    }
View Full Code Here

     */
    public DataSourceInfo getConnectionInfo(String name) {

        if (EMBEDDED_DATASOURCE.equals(name)) {
            // Create embedded data source instead
            DataSourceInfo connectionInfo = new DataSourceInfo();
            connectionInfo.setAdapterClassName(EMBEDDED_DATASOURCE_DBADAPTER);
            connectionInfo.setUserName(EMBEDDED_DATASOURCE_USERNAME);
            connectionInfo.setPassword(EMBEDDED_DATASOURCE_PASSWORD);
            connectionInfo.setDataSourceUrl(EMBEDDED_DATASOURCE_URL);
            connectionInfo.setJdbcDriver(EMBEDDED_DATASOURCE_JDBC_DRIVER);
            return connectionInfo;
        }

        synchronized (connectionInfos) {
            return connectionInfos.get(name);
View Full Code Here

    /**
     * Creates a DataSourceInfo object from a set of properties.
     */
    public DataSourceInfo buildDataSourceInfo(ExtendedProperties props) {
        DataSourceInfo dsi = new DataSourceInfo();

        String adapter = props.getString(ADAPTER_KEY);

        // try legacy adapter key
        if (adapter == null) {
            adapter = props.getString(ADAPTER20_KEY);
        }

        dsi.setAdapterClassName(adapter);
        dsi.setUserName(props.getString(USER_NAME_KEY));
        dsi.setPassword(props.getString(PASSWORD_KEY));
        dsi.setDataSourceUrl(props.getString(URL_KEY));
        dsi.setJdbcDriver(props.getString(DRIVER_KEY));

        return dsi;
    }
View Full Code Here

                node
                        .setDataSourceFactoryType(XMLPoolingDataSourceFactory.class
                                .getName());

                DataSourceInfo dsi = node.getDataSourceDescriptor();

                dsi.setDataSourceUrl(keyAsString(connection, "URL"));
                dsi.setJdbcDriver(keyAsString(connection, "driver"));
                dsi.setPassword(keyAsString(connection, "password"));
                dsi.setUserName(keyAsString(connection, "username"));
            }

            DataChannelDescriptor domain = (DataChannelDescriptor) getProjectController()
                    .getProject()
                    .getRootNode();
View Full Code Here

TOP

Related Classes of org.apache.cayenne.conn.DataSourceInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.