You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Serge Knystautas <se...@lokitech.com> on 2001/10/17 05:00:36 UTC

JdbcDataSource

In James, we use Excalibur/Cornerstone to define Excalibur-style
datasources... is there a way to expose these same datasources as J2EE style
datasource?

Said in code... assume the datasource gets configured in the conf file is
called "maildb".  Now we get the Connection this way...

DataSourceSelector datasources =
(DataSourceSelector)componentManager.lookup( DataSourceSelector.ROLE );
DataSourceComponent datasource =
(DataSourceComponent)datasources.select("maildb");
Connection conn = datasource.getConnection();


I'd like to be able to do...

Context env = (Context) new InitialContext().lookup("java:comp/env");
DataSource source = (DataSource) env.lookup("jdbc/maildb");
Connection conn = source.getConnection();

I don't really know how the Context or InitialContext approach works, but it
doesn't seem like it would be that difficult.

Serge Knystautas
Loki Technologies - Unstoppable Websites
http://www.lokitech.com/


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


Re: JdbcDataSource

Posted by Berin Loritsch <bl...@apache.org>.
Serge Knystautas wrote:
> 
> ----- Original Message -----
> From: "Peter Donald" <do...@apache.org>
> > It is not really supported at this stage. It would not be too hard to
> add -
> > especially as there is already a JNDI framework in excalibur. But I am not
> > sure that there is a benefit in using an industrial strength naming api
> when
> > a thin layer will suffice.
> 
> I'm not looking for industrial strength... I just think developers would be
> more comfortable using the JNDI API/approach that's used in webservers and
> EJB servers.  This is specifically for mailet and matcher developers, not
> general James development.  This is part of trying to make James and mailets
> feel like a friendly/approachable development platform.

It is doable.  The DataSourceComponent interface purposely did not implement
the javax.jdbc.DataSource because it was going to be used in environments where
that was not available.

You would write a DataSource that wraps calls to DataSourceComponent, or wraps
the JdbcConnectionPool, and go from there.

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


Re: JdbcDataSource

Posted by Peter Donald <do...@apache.org>.
On Wed, 17 Oct 2001 21:32, Serge Knystautas wrote:
> I'm not looking for industrial strength... I just think developers would be
> more comfortable using the JNDI API/approach that's used in webservers and
> EJB servers.  This is specifically for mailet and matcher developers, not
> general James development.  This is part of trying to make James and
> mailets feel like a friendly/approachable development platform.

Okay - in that case you will have to do something like the following.

Create an InitialContextFactory (similar to MemeoryInitialContext factory in 
excalibur) that creates a MemoryContext (from excalibur) and binds it to a 
static variable. You will then have to change a system property to specify 
this factory (forget what it actually is). You will then have to extract all 
needed services from Avalons CM and stuff them into JNDI under approriate 
names.

After that you *should* be good to go ;)

-- 
Cheers,

Pete

---------------------------------------------
 We shall not cease from exploration, and the 
  end of all our exploring will be to arrive 
 where we started and know the place for the 
        first time -- T.S. Eliot
---------------------------------------------

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


Re: JdbcDataSource

Posted by Serge Knystautas <se...@lokitech.com>.
----- Original Message -----
From: "Peter Donald" <do...@apache.org>
> It is not really supported at this stage. It would not be too hard to
add -
> especially as there is already a JNDI framework in excalibur. But I am not
> sure that there is a benefit in using an industrial strength naming api
when
> a thin layer will suffice.

I'm not looking for industrial strength... I just think developers would be
more comfortable using the JNDI API/approach that's used in webservers and
EJB servers.  This is specifically for mailet and matcher developers, not
general James development.  This is part of trying to make James and mailets
feel like a friendly/approachable development platform.

Serge Knystautas
Loki Technologies - Unstoppable Websites
http://www.lokitech.com/


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


Re: JdbcDataSource

Posted by Peter Donald <do...@apache.org>.
On Wed, 17 Oct 2001 13:00, Serge Knystautas wrote:
> In James, we use Excalibur/Cornerstone to define Excalibur-style
> datasources... is there a way to expose these same datasources as J2EE
> style datasource?
>
> Said in code... assume the datasource gets configured in the conf file is
> called "maildb".  Now we get the Connection this way...
>
> DataSourceSelector datasources =
> (DataSourceSelector)componentManager.lookup( DataSourceSelector.ROLE );
> DataSourceComponent datasource =
> (DataSourceComponent)datasources.select("maildb");
> Connection conn = datasource.getConnection();
>
>
> I'd like to be able to do...
>
> Context env = (Context) new InitialContext().lookup("java:comp/env");
> DataSource source = (DataSource) env.lookup("jdbc/maildb");
> Connection conn = source.getConnection();
>
> I don't really know how the Context or InitialContext approach works, but
> it doesn't seem like it would be that difficult.

It is not really supported at this stage. It would not be too hard to add - 
especially as there is already a JNDI framework in excalibur. But I am not 
sure that there is a benefit in using an industrial strength naming api when 
a thin layer will suffice.

-- 
Cheers,

Pete

*------------------------------------------------------*
| "Common sense is the collection of prejudices        |
|  acquired by age 18. " -Albert Einstein              |
*------------------------------------------------------*

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