1 16 17 package org.springframework.jca.cci.connection; 18 19 import javax.naming.NamingException ; 20 import javax.naming.Reference ; 21 import javax.resource.ResourceException ; 22 import javax.resource.cci.Connection ; 23 import javax.resource.cci.ConnectionFactory ; 24 import javax.resource.cci.ConnectionSpec ; 25 import javax.resource.cci.RecordFactory ; 26 import javax.resource.cci.ResourceAdapterMetaData ; 27 28 import org.springframework.beans.factory.InitializingBean; 29 30 42 public class DelegatingConnectionFactory implements ConnectionFactory , InitializingBean { 43 44 private ConnectionFactory targetConnectionFactory; 45 46 47 50 public void setTargetConnectionFactory(ConnectionFactory targetConnectionFactory) { 51 this.targetConnectionFactory = targetConnectionFactory; 52 } 53 54 57 public ConnectionFactory getTargetConnectionFactory() { 58 return this.targetConnectionFactory; 59 } 60 61 62 public void afterPropertiesSet() { 63 if (getTargetConnectionFactory() == null) { 64 throw new IllegalArgumentException ("Property 'targetConnectionFactory' is required"); 65 } 66 } 67 68 69 public Connection getConnection() throws ResourceException { 70 return getTargetConnectionFactory().getConnection(); 71 } 72 73 public Connection getConnection(ConnectionSpec connectionSpec) throws ResourceException { 74 return getTargetConnectionFactory().getConnection(connectionSpec); 75 } 76 77 public RecordFactory getRecordFactory() throws ResourceException { 78 return getTargetConnectionFactory().getRecordFactory(); 79 } 80 81 public ResourceAdapterMetaData getMetaData() throws ResourceException { 82 return getTargetConnectionFactory().getMetaData(); 83 } 84 85 public Reference getReference() throws NamingException { 86 return getTargetConnectionFactory().getReference(); 87 } 88 89 public void setReference(Reference reference) { 90 getTargetConnectionFactory().setReference(reference); 91 } 92 93 } 94 | Popular Tags |