Package org.apache.tuscany.sca.data.engine.config

Examples of org.apache.tuscany.sca.data.engine.config.ConnectionInfo


     */
    public ConnectionInfo read(XMLStreamReader reader) throws ContributionReadException {
        assert CONNECTION_INFO.equals(reader.getName());

        // Create a ConnectionInfo from the component type model
        ConnectionInfo connectionInfo = new ConnectionInfo();

        /*
         *  <connectionInfo dataSource="jdbc:derby:target/test-classes/dastest; create = true"/>
         */
        String dataSource = reader.getAttributeValue(null, "datasource"); // exclusive with connection properties
        if (dataSource != null && dataSource.length() > 0) {
            connectionInfo.setDataSource(dataSource);
        } else {
            try {
                int event = reader.next();
                while (event == XMLStreamConstants.CHARACTERS) {
                    event = reader.next();
                }
            } catch (XMLStreamException e) {
              ContributionReadException ce = new ContributionReadException(e);
              error("ContributionReadException", reader, ce);
                throw ce;
            }

            QName element = reader.getName();
           
            assert CONNECTION_PROPERTIES.equals(element);
           
            /*
             * <connectionProperties
             *  driverClass="org.apache.derby.jdbc.EmbeddedDriver"
             *  databaseURL="jdbc:derby:target/test-classes/dastest; create = true"
             *  username=""
             *  password=""
             *  loginTimeout="600000"/>
             */
           
            String driverClass = reader.getAttributeValue(null, "driverClass");
            String databaseURL = reader.getAttributeValue(null, "databaseURL");
            String username = reader.getAttributeValue(null, "username");
            String password = reader.getAttributeValue(null, "password");
            String loginTimeout = reader.getAttributeValue(null, "loginTimeout");

            // FIXME: validation sending info to monitor....
            ConnectionProperties connectionProperties = new ConnectionProperties();
            connectionProperties.setDriverClass(driverClass);
            connectionProperties.setDatabaseURL(databaseURL);
            connectionProperties.setUsername(username);
            connectionProperties.setPassword(password);
            if (loginTimeout != null) {
                connectionProperties.setLoginTimeout(Integer.parseInt(loginTimeout));
            }

            connectionInfo.setConnectionProperties(connectionProperties);
        }
       
        return connectionInfo;
    }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.data.engine.config.ConnectionInfo

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.