Package org.apache.cayenne.conn

Examples of org.apache.cayenne.conn.DataSourceInfo


        // use domain name as DataNode base, as node names must be unique across the
        // project...
        DataNode node = buildDataNode(domain);

        ProjectDataSource src = new ProjectDataSource(new DataSourceInfo());
        node.setDataSource(src);
        node.setAdapter(new ModelerDbAdapter(src));

        // by default create JDBC Node
        node.setDataSourceFactory(DriverDataSourceFactory.class.getName());
View Full Code Here


                String mapName = attributes.getValue("", "name");
                nodeDescriptor.getDataMapNames().add(mapName);
            }
            else if (localName.equals(DATA_SOURCE_TAG)) {

                DataSourceInfo dataSourceDescriptor = new DataSourceInfo();
                nodeDescriptor.setDataSourceDescriptor(dataSourceDescriptor);
                return new DataSourceChildrenHandler(parser, this, dataSourceDescriptor);
            }

            return super.createChildTagHandler(namespaceURI, localName, name, attributes);
View Full Code Here

    }

    public DataSource getDataSource(String location) throws Exception {

        String connectionSet = getDataSourceName();
        DataSourceInfo dsi = ConnectionProperties.getInstance().getConnectionInfo(
                connectionSet);

        if (dsi == null) {
            throw new CayenneRuntimeException("Connection info for key '"
                    + connectionSet
                    + "' is not configured");
        }

        String minPool = System.getProperty(CONNECTION_POOL_MIN_SIZE_PROPERTY);
        if (minPool != null) {
            dsi.setMinConnections(Integer.parseInt(minPool));
        }

        String maxPool = System.getProperty(CONNECTION_POOL_MAX_SIZE_PROPERTY);
        if (maxPool != null) {
            dsi.setMaxConnections(Integer.parseInt(maxPool));
        }

        if (dsi.getMinConnections() > dsi.getMaxConnections()) {
            dsi.setMaxConnections(dsi.getMinConnections());
        }

        return new PoolManager(dsi.getJdbcDriver(), dsi.getDataSourceUrl(), dsi
                .getMinConnections(), dsi.getMaxConnections(), dsi.getUserName(), dsi
                .getPassword());
    }
View Full Code Here

*/
public class ConfigSaverTest extends CayenneCase {
  protected ConfigSaver saver;

  public void testStoreFullDataNode() throws Exception {
    DataSourceInfo info = new DataSourceInfo();
    info.setDataSourceUrl("s1");
    info.setJdbcDriver("s2");
    info.setPassword("s3");
    info.setUserName("s4");
   
    info.setMaxConnections(35);
    info.setMinConnections(22);
    assertSaved(info);
  }
View Full Code Here

    info.setMinConnections(22);
    assertSaved(info);
  }
 
  public void testStoreDataNodeNoUserName() throws Exception {
    DataSourceInfo info = new DataSourceInfo();
    info.setDataSourceUrl("s1");
    info.setJdbcDriver("s2");
    info.setPassword("s3");
   
    info.setMaxConnections(35);
    info.setMinConnections(22);
    assertSaved(info);
  }
View Full Code Here

    info.setMinConnections(22);
    assertSaved(info);
  }
 
  public void testStoreDataNodeNoPassword() throws Exception {
    DataSourceInfo info = new DataSourceInfo();
    info.setDataSourceUrl("s1");
    info.setJdbcDriver("s2");
    info.setUserName("s4");
   
    info.setMaxConnections(35);
    info.setMinConnections(22);
    assertSaved(info);
  }
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

    /**
     * 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

                    Resource baseResource = descriptor.getConfigurationSource();
                    Resource dataNodeResource = baseResource
                            .getRelativeResource(datasource);
                    nodeDescriptor.setConfigurationSource(dataNodeResource);

                    DataSourceInfo dataSourceInfo = dataSourceInfoLoader
                            .load(dataNodeResource);
                    nodeDescriptor.setDataSourceDescriptor(dataSourceInfo);
                }
                else {
                    nodeDescriptor.setParameters(datasource);
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

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.