Thanks!!! It definitely helps.  :-)

David Jencks wrote:
This won't quite work. There's no guarantee that a JCA 1.5 adapter with a ResourceAdapter is going to have any outbound connectors at all, nor will this pick up any jca 1.0 adapters without a ResourceAdapter.

What you want is to use ConnectionFactorySource as the interface in your query.

ConnectionFactorySource isn't the connection factory itself, you have to call the oddly named method $getResource(). This could be a datasource, a jms ConnectionFactory, or just about anything else, so you have to test the results to see if its something you want.


Kernel kernel = KernelRegistry.getSingleKernel();
Collection cfss = kernel.listGBeans(new AbstractNameQuery(ConnectionFactorySource.class.getName()));
Collection datasources = new ArrayList();
for (Iterator i = cfss.iterator(); i.hasNext(); ) {
Object cf = kernel.invoke((AbstractName)i.next(), "$getResource", new Object[] {}, new String[]{}); //this might not be the right signature for the invoke method-- this is from memory
if (cf instanceof DataSource) {
datasources.add(cf);
}
}

Hope this helps
david jencks



On Sep 19, 2006, at 10:51 PM, Lasantha Ranaweera wrote:

Hi Aaron,

I want to test the existing db connections in the Geronimo with the help of a web application. Following code helped me to list the resource adapters in the server. Now my problem is how to identify which are the db connection adapters and convert them in to javax.sql.DataSource.

Kernel kernel = KernelRegistry.getSingleKernel();
Set list = kernel.listGBeans(new AbstractNameQuery(ResourceAdapter.class.getName()));
for(Iterator iterator = list.iterator();iterator.hasNext();){
AbstractName name = (AbstractName)iterator.next();
ResourceAdapter ra = (ResourceAdapter)(kernel.getProxyManager().createProxy(name, ResourceAdapter.class));
//How to indentify is this ra is DataSource or not
}

Any help would be appreciated. If this is can be done better way than this please let me know too.
Thanks,
Lasantha Ranaweera

Aaron Mulder wrote:
In Geronimo 1.1, you can use a gbean-ref to map the J2EEServer into
the web application's JNDI space. From the J2EEServer, you can
navigate to a list of resource adapters (J2EE Connectors), and I think
there's a way to check which connection factory interface they
implement (you'd want javax.sql.DataSource). There's probably a
method in KernelManagementHelper that more or less does that (given a
server get database connection pools) if you want something to refer
to.

Please write back if you need help with the details.

Thanks,
Aaron

On 9/18/06, Lasantha Ranaweera <[EMAIL PROTECTED]> wrote:
Hi All,

I want get the list of database connections deployed in the Geronimo
from a web application. Any help would be appreciated.

Thanks,
Lasantha Ranaweera






Reply via email to