Examples of JdbcConnectionDescriptor


Examples of org.apache.ojb.broker.metadata.JdbcConnectionDescriptor

            log.debug("Initializing OJB");
        }

        // This line effectively loads OJB.properties & repository.xml
        ConnectionRepository     connRep = MetadataManager.getInstance().connectionRepository();
        JdbcConnectionDescriptor jcd     = connRep.addDescriptor("default", dataSource, username, password);
        SequenceDescriptor       seqDesc = new SequenceDescriptor(jcd);

        seqDesc.setSequenceManagerClass(SequenceManagerHighLowImpl.class);
        jcd.setSequenceDescriptor(seqDesc);
    }
View Full Code Here

Examples of org.apache.ojb.broker.metadata.JdbcConnectionDescriptor

    public void afterPropertiesSet () throws Exception
    {
        // Try to find JCD
        ConnectionRepository cr = MetadataManager.getInstance().connectionRepository();
        JdbcConnectionDescriptor jcd = cr.getDescriptor(new PBKey(jcdAlias));
        if (jcd == null)
        {
            jcd = new JdbcConnectionDescriptor();
            jcd.setJcdAlias(jcdAlias);
            cr.addDescriptor(jcd);
        }
        if (platform != null && platform.length() == 0)
        {
            platform = null;
        }
        DataSource ds = null;
        JdbcMetadataUtils jdbcMetadataUtils = new JdbcMetadataUtils ();
        if (jndiName != null)
        {
            // using "preconfigured" data source
            if (connectionFactoryClass == null)
            {
                connectionFactoryClass = ConnectionFactoryManagedImpl.class.getName ();
            }
            Context initialContext = new InitialContext();
            ds = (DataSource) initialContext.lookup(jndiName);
            jcd.setDatasourceName(jndiName);
        }
        else
        {
            // have to get data source ourselves
            if (connectionFactoryClass == null)
            {
                connectionFactoryClass = ConnectionFactoryDBCPImpl.class.getName ();
            }
            jcd.setDriver(driverClassName);
            Map conData = jdbcMetadataUtils.parseConnectionUrl(url);
            jcd.setDbms(platform);
            jcd.setProtocol((String)conData.get(JdbcMetadataUtils.PROPERTY_PROTOCOL));
            jcd.setSubProtocol((String)conData.get(JdbcMetadataUtils.PROPERTY_SUBPROTOCOL));
            jcd.setDbAlias((String)conData.get(JdbcMetadataUtils.PROPERTY_DBALIAS));
            jcd.setUserName(username);
            jcd.setPassWord(password);
            // Wrapping the connection factory in a DataSource introduces a bit
            // of redundancy (url is parsed again and platform determined again).
            // But although JdbcMetadataUtils exposes the methods used in
            // fillJCDFromDataSource as public (and these do not require a DataSource)
            // the method itself does more than is made available by the exposed methods.
            // ds = new MinimalDataSource (jcd);
            ds = this;            
        }
        ConnectionPoolDescriptor cpd = jcd.getConnectionPoolDescriptor();
        if (cpd == null)
        {
            cpd = new ConnectionPoolDescriptor();
            jcd.setConnectionPoolDescriptor(cpd);
        }
        Class conFacCls = ClassHelper.getClass(connectionFactoryClass);
        cpd.setConnectionFactory(conFacCls);

        jdbcMetadataUtils.fillJCDFromDataSource(jcd, ds, null, null);
       
        if (platform == null && JdbcMetadataUtils.PLATFORM_ORACLE.equals(jcd.getDbms())) {
            // Postprocess to find Oracle version.
            updateOraclePlatform (jcd, ds);
        }
        // if platform has explicitly been set, the value takes precedence
        if (platform != null) {
            if (!platform.equals(jcd.getDbms())) {
                log.warn ("Automatically derived RDBMS platform \"" + jcd.getDbms()
                          + "\" differs from explicitly set platform \"" + platform + "\"");
            }
            jcd.setDbms(platform);
        } else {
            platform = jcd.getDbms();
        }
       
        // special attributes
        jcd.addAttribute("org.apache.jetspeed.engineScoped",
                         Boolean.toString(jetspeedEngineScoped));
    }
View Full Code Here

Examples of org.apache.ojb.broker.metadata.JdbcConnectionDescriptor

     * <code>META-INF/jboss-secsvc</code>.
     */
    public JetspeedSecurityService()
    {
        // Prepare JCD so that it can be resolved
        JdbcConnectionDescriptor jcd = findJcd();
        if (jcd == null)
        {
            // JCD not found, initialize
            jcd = new JdbcConnectionDescriptor();
            jcd.setJcdAlias(JCD_ALIAS);
            ConnectionPoolDescriptor cpd = new ConnectionPoolDescriptor();
            cpd.setConnectionFactory(ConnectionFactoryManagedImpl.class);
            jcd.setConnectionPoolDescriptor(cpd);
            ConnectionRepository cr = MetadataManager.getInstance().connectionRepository();
            cr.addDescriptor(jcd);
        }
        // Instatiating application
        ctx = new GenericApplicationContext();
View Full Code Here

Examples of org.apache.ojb.broker.metadata.JdbcConnectionDescriptor

     *
     * @param jndiName
     */
    public void setDataSourceJndiName(String jndiName)
    {
        JdbcConnectionDescriptor jcd = findJcd();
        try
        {
            Context initialContext = new InitialContext();
            DataSource ds = (DataSource) initialContext.lookup(jndiName);
            (new JdbcMetadataUtils()).fillJCDFromDataSource(jcd, ds, null, null);
        }
        catch (NamingException e)
        {
            throw (IllegalArgumentException) (new IllegalArgumentException("Data source \"" + jndiName
                    + "\" not found in JNDI: " + e.getMessage())).initCause(e);
        }
        jcd.setDatasourceName(jndiName);
    }
View Full Code Here

Examples of org.apache.ojb.broker.metadata.JdbcConnectionDescriptor

     *
     * @return jndiName
     */
    public String getDataSourceJndiName()
    {
        JdbcConnectionDescriptor jcd = findJcd();
        if (jcd == null)
        {
            return null;
        }
        return jcd.getDatasourceName();
    }
View Full Code Here

Examples of org.apache.ojb.broker.metadata.JdbcConnectionDescriptor

    public void afterPropertiesSet () throws Exception
    {
        // Try to find JCD
        ConnectionRepository cr = MetadataManager.getInstance().connectionRepository();
        JdbcConnectionDescriptor jcd = cr.getDescriptor(new PBKey(jcdAlias));
        if (jcd == null)
        {
            jcd = new JdbcConnectionDescriptor();
            jcd.setJcdAlias(jcdAlias);
            cr.addDescriptor(jcd);
        }
        if (platform != null && platform.length() == 0)
        {
            platform = null;
        }
        DataSource ds = null;
        JdbcMetadataUtils jdbcMetadataUtils = new JdbcMetadataUtils ();
        if (jndiName != null)
        {
            // using "preconfigured" data source
            if (connectionFactoryClass == null)
            {
                connectionFactoryClass = ConnectionFactoryManagedImpl.class.getName ();
            }
            Context initialContext = new InitialContext();
            ds = (DataSource) initialContext.lookup(jndiName);
            jcd.setDatasourceName(jndiName);
        }
        else
        {
            // have to get data source ourselves
            if (connectionFactoryClass == null)
            {
                connectionFactoryClass = ConnectionFactoryDBCPImpl.class.getName ();
            }
            jcd.setDriver(driverClassName);
            Map conData = jdbcMetadataUtils.parseConnectionUrl(url);
            jcd.setDbms(platform);
            jcd.setProtocol((String)conData.get(JdbcMetadataUtils.PROPERTY_PROTOCOL));
            jcd.setSubProtocol((String)conData.get(JdbcMetadataUtils.PROPERTY_SUBPROTOCOL));
            jcd.setDbAlias((String)conData.get(JdbcMetadataUtils.PROPERTY_DBALIAS));
            jcd.setUserName(username);
            jcd.setPassWord(password);
            // Wrapping the connection factory in a DataSource introduces a bit
            // of redundancy (url is parsed again and platform determined again).
            // But although JdbcMetadataUtils exposes the methods used in
            // fillJCDFromDataSource as public (and these do not require a DataSource)
            // the method itself does more than is made available by the exposed methods.
            // ds = new MinimalDataSource (jcd);
            ds = this;            
        }
        ConnectionPoolDescriptor cpd = jcd.getConnectionPoolDescriptor();
        if (cpd == null)
        {
            cpd = new ConnectionPoolDescriptor();
            jcd.setConnectionPoolDescriptor(cpd);
        }
        Class conFacCls = ClassHelper.getClass(connectionFactoryClass);
        cpd.setConnectionFactory(conFacCls);

        jdbcMetadataUtils.fillJCDFromDataSource(jcd, ds, null, null);
       
        if (platform == null && JdbcMetadataUtils.PLATFORM_ORACLE.equals(jcd.getDbms())) {
            // Postprocess to find Oracle version.
            updateOraclePlatform (jcd, ds);
        }
        // if platform has explicitly been set, the value takes precedence
        if (platform != null) {
            if (!platform.equals(jcd.getDbms())) {
                log.warn ("Automatically derived RDBMS platform \"" + jcd.getDbms()
                          + "\" differs from explicitly set platform \"" + platform + "\"");
            }
            jcd.setDbms(platform);
        } else {
            platform = jcd.getDbms();
        }
       
        // special attributes
        jcd.addAttribute("org.apache.jetspeed.engineScoped",
                         Boolean.toString(jetspeedEngineScoped));
    }
View Full Code Here

Examples of org.apache.ojb.broker.metadata.JdbcConnectionDescriptor

   
    public void init()
    throws Exception
    {
        ConnectionRepository cr = MetadataManager.getInstance().connectionRepository();
        JdbcConnectionDescriptor jcd = cr.getDescriptor(new PBKey(jcdAlias));
        if (jcd == null)
        {
            jcd = new JdbcConnectionDescriptor();
            jcd.setJcdAlias(jcdAlias);
            cr.addDescriptor(jcd);
        }
       
        JdbcMetadataUtils jdbcMetadataUtils = new JdbcMetadataUtils ();
        jdbcMetadataUtils.fillJCDFromDataSource(jcd, ds, null, null);
        String platform = jcd.getDbms();
        if (JdbcMetadataUtils.PLATFORM_ORACLE.equals(platform))
        {
            // Postprocess to find Oracle version.
                platform = updateOraclePlatform (jcd, ds, platform);
        }
        // if platform has explicitly been set, the value takes precedence
        if (platform != null)
        {
            if (!platform.equals(jcd.getDbms()))
            {
                log.warn ("Automatically derived RDBMS platform \"" + jcd.getDbms()
                          + "\" differs from explicitly set platform \"" + platform + "\"");
            }
            jcd.setDbms(platform);
        }
        else
        {
            platform = jcd.getDbms();
        }
        System.out.println("##### platform = " + platform);
    }
View Full Code Here

Examples of org.apache.ojb.broker.metadata.JdbcConnectionDescriptor

     * <code>META-INF/jboss-secsvc</code>.
     */
    public JetspeedSecurityService()
    {
        // Prepare JCD so that it can be resolved
        JdbcConnectionDescriptor jcd = findJcd();
        if (jcd == null)
        {
            // JCD not found, initialize
            jcd = new JdbcConnectionDescriptor();
            jcd.setJcdAlias(JCD_ALIAS);
            ConnectionPoolDescriptor cpd = new ConnectionPoolDescriptor();
            cpd.setConnectionFactory(ConnectionFactoryManagedImpl.class);
            jcd.setConnectionPoolDescriptor(cpd);
            ConnectionRepository cr = MetadataManager.getInstance().connectionRepository();
            cr.addDescriptor(jcd);
        }
        // Instatiating application
        ctx = new GenericApplicationContext();
View Full Code Here

Examples of org.apache.ojb.broker.metadata.JdbcConnectionDescriptor

     *
     * @param jndiName
     */
    public void setDataSourceJndiName(String jndiName)
    {
        JdbcConnectionDescriptor jcd = findJcd();
        try
        {
            Context initialContext = new InitialContext();
            DataSource ds = (DataSource) initialContext.lookup(jndiName);
            (new JdbcMetadataUtils()).fillJCDFromDataSource(jcd, ds, null, null);
        }
        catch (NamingException e)
        {
            throw (IllegalArgumentException) (new IllegalArgumentException("Data source \"" + jndiName
                    + "\" not found in JNDI: " + e.getMessage())).initCause(e);
        }
        jcd.setDatasourceName(jndiName);
    }
View Full Code Here

Examples of org.apache.ojb.broker.metadata.JdbcConnectionDescriptor

     *
     * @return jndiName
     */
    public String getDataSourceJndiName()
    {
        JdbcConnectionDescriptor jcd = findJcd();
        if (jcd == null)
        {
            return null;
        }
        return jcd.getDatasourceName();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.