You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by we...@apache.org on 2004/05/11 20:38:54 UTC

cvs commit: jakarta-jetspeed-2/components/rdbms/src/java/org/apache/jetspeed/components/datasource BoundDBCPDatasourceComponent.java

weaver      2004/05/11 11:38:54

  Modified:    components/rdbms/src/java/org/apache/jetspeed/components/datasource
                        Tag: NANOCONTAINER_DEPLOYER
                        BoundDBCPDatasourceComponent.java
  Log:
  binds jndi to Thread
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.1.2.1   +83 -78    jakarta-jetspeed-2/components/rdbms/src/java/org/apache/jetspeed/components/datasource/BoundDBCPDatasourceComponent.java
  
  Index: BoundDBCPDatasourceComponent.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/components/rdbms/src/java/org/apache/jetspeed/components/datasource/BoundDBCPDatasourceComponent.java,v
  retrieving revision 1.1
  retrieving revision 1.1.2.1
  diff -u -r1.1 -r1.1.2.1
  --- BoundDBCPDatasourceComponent.java	27 Feb 2004 19:35:02 -0000	1.1
  +++ BoundDBCPDatasourceComponent.java	11 May 2004 18:38:54 -0000	1.1.2.1
  @@ -1,78 +1,83 @@
  -/*
  - * Created on Feb 27, 2004
  - *
  - * To change the template for this generated file go to
  - * Window - Preferences - Java - Code Generation - Code and Comments
  - */
  -package org.apache.jetspeed.components.datasource;
  -
  -import javax.naming.NamingException;
  -
  -import org.apache.jetspeed.components.jndi.JNDIComponent;
  -
  -
  -/**
  - * @author Sweaver
  - *
  - * To change the template for this generated type comment go to
  - * Window - Preferences - Java - Code Generation - Code and Comments
  - */
  -public class BoundDBCPDatasourceComponent extends DBCPDatasourceComponent
  -{
  -    private JNDIComponent jndi;
  -    private String bindName;
  -
  -    
  -    /**
  -     * 
  -     * @param user
  -     * @param password
  -     * @param driverName
  -     * @param connectURI
  -     * @param maxActive
  -     * @param maxWait
  -     * @param whenExhausted
  -     * @param autoCommit
  -     * @param bindName JNDI name to bind this <code>javax.sql.DataSource</code>
  -     * created by this class to.
  -     * @param jndi JNDIComponent we will use to bind.
  -     */
  -    public BoundDBCPDatasourceComponent(String user, String password, String driverName, String connectURI,
  -            int maxActive, int maxWait, byte whenExhausted, boolean autoCommit, String bindName, JNDIComponent jndi)
  -    {
  -        super(user, password, driverName, connectURI, maxActive, maxWait, whenExhausted, autoCommit);
  -        if(jndi == null)
  -        {
  -            throw new IllegalArgumentException("jndi argument cannot be null for BoundDBCPDatasourceComponent");
  -        }
  -        
  -        if(bindName == null)
  -        {
  -            throw new IllegalArgumentException("bindName argument cannot be null for BoundDBCPDatasourceComponent");
  -        }
  -        
  -        this.jndi = jndi;
  -        this.bindName = bindName;
  -
  -    }
  -    /**
  -     * Same as {@link DBCPDatasourceComponent#start()}
  -     * but also binds these <code>javax.sql.DataSource</code>
  -     * created to the <code>bindName</code>.
  -     * 
  -     * @see org.picocontainer.Startable#start()
  -     */
  -    public void start()
  -    {        
  -        super.start();
  -        try
  -        {
  -            jndi.bindObject("comp/env/jdbc/"+bindName, getDatasource());
  -        }
  -        catch (NamingException e)
  -        {
  -            new IllegalStateException("Naming exception "+e.toString());
  -        }
  -    }
  -
  -}
  +/*
  + * Created on Feb 27, 2004
  + *
  + * To change the template for this generated file go to
  + * Window - Preferences - Java - Code Generation - Code and Comments
  + */
  +package org.apache.jetspeed.components.datasource;
  +
  +import javax.naming.NamingException;
  +
  +import org.apache.jetspeed.components.jndi.JNDIComponent;
  +
  +
  +/**
  + * @author Sweaver
  + *
  + * To change the template for this generated type comment go to
  + * Window - Preferences - Java - Code Generation - Code and Comments
  + */
  +public class BoundDBCPDatasourceComponent extends DBCPDatasourceComponent
  +{
  +    private JNDIComponent jndi;
  +    private String bindName;
  +
  +    
  +    /**
  +     * 
  +     * @param user
  +     * @param password
  +     * @param driverName
  +     * @param connectURI
  +     * @param maxActive
  +     * @param maxWait
  +     * @param whenExhausted
  +     * @param autoCommit
  +     * @param bindName JNDI name to bind this <code>javax.sql.DataSource</code>
  +     * created by this class to.
  +     * @param jndi JNDIComponent we will use to bind.
  +     */
  +    public BoundDBCPDatasourceComponent(String user, String password, String driverName, String connectURI,
  +            int maxActive, int maxWait, byte whenExhausted, boolean autoCommit, String bindName, JNDIComponent jndi)
  +    {
  +        super(user, password, driverName, connectURI, maxActive, maxWait, whenExhausted, autoCommit);
  +        if(jndi == null)
  +        {
  +            throw new IllegalArgumentException("jndi argument cannot be null for BoundDBCPDatasourceComponent");
  +        }
  +        
  +        if(bindName == null)
  +        {
  +            throw new IllegalArgumentException("bindName argument cannot be null for BoundDBCPDatasourceComponent");
  +        }
  +        
  +        this.jndi = jndi;
  +        this.bindName = bindName;
  +
  +    }
  +    /**
  +     * Same as {@link DBCPDatasourceComponent#start()}
  +     * but also binds these <code>javax.sql.DataSource</code>
  +     * created to the <code>bindName</code>.
  +     * 
  +     * @see org.picocontainer.Startable#start()
  +     */
  +    public void start()
  +    {        
  +        super.start();
  +        try
  +        {
  +            //  jndi.bindToCurrentThread();
  +            jndi.bindObject("comp/env/jdbc/"+bindName, getDatasource());
  +            jndi.bindToCurrentThread();
  +            System.out.println("BoundDBCPDatasource was started.");
  +            
  +        }
  +        catch (NamingException e)
  +        {
  +            e.printStackTrace();
  +            new IllegalStateException("Naming exception "+e.toString());
  +        }
  +    }
  +
  +}
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org