KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openejb > core > ConnectorReference


1 package org.openejb.core;
2
3 import javax.naming.NamingException JavaDoc;
4 import javax.resource.spi.ConnectionManager JavaDoc;
5 import javax.resource.spi.ManagedConnectionFactory JavaDoc;
6
7 import org.openejb.core.ivm.naming.Reference;
8 /*
9   This reference object is used for wrappering ManagedConnectionFactory objects that
10   manufacture resource specific connection factories. When the getObject( ) method is
11   invoked the factory is created and passed back as the return value.
12   
13   In addition, dynamic resolution and special conditions can be encapsulated
14   in the implementation object.
15   
16 */

17 public class ConnectorReference implements Reference{
18     private ConnectionManager JavaDoc conMngr;
19     private ManagedConnectionFactory JavaDoc mngedConFactory;
20     
21     public ConnectorReference(ConnectionManager JavaDoc cm, ManagedConnectionFactory JavaDoc mcf){
22         conMngr = cm;
23         mngedConFactory = mcf;
24     }
25     public Object JavaDoc getObject( ) throws NamingException JavaDoc{
26         try{
27         return mngedConFactory.createConnectionFactory(conMngr);
28         }catch(javax.resource.ResourceException JavaDoc re){
29             throw new javax.naming.NamingException JavaDoc("Could not create ConnectionFactory from "+mngedConFactory.getClass());
30         }
31         
32     }
33 }
Popular Tags