1 23 24 package org.apache.webdav.connector; 25 26 import javax.naming.NamingException ; 27 import javax.naming.Reference ; 28 import javax.resource.NotSupportedException ; 29 import javax.resource.ResourceException ; 30 import javax.resource.cci.Connection ; 31 import javax.resource.cci.ConnectionFactory ; 32 import javax.resource.cci.ConnectionSpec ; 33 import javax.resource.cci.RecordFactory ; 34 import javax.resource.cci.ResourceAdapterMetaData ; 35 import javax.resource.spi.ConnectionManager ; 36 import javax.resource.spi.ManagedConnectionFactory ; 37 38 43 public class WebDAVConnectionFactory implements ConnectionFactory { 44 45 protected Reference reference; 46 protected ConnectionManager cm; 47 protected ManagedConnectionFactory mcf; 48 49 public WebDAVConnectionFactory(ManagedConnectionFactory mcf, ConnectionManager cm) { 50 System.out.println("MCF Init with mcf " + mcf + " cm " + cm); 51 this.mcf = mcf; 52 this.cm = cm; 53 } 54 55 public Connection getConnection() throws ResourceException { 56 throw new NotSupportedException ( 57 "Need a WebDAVConnectionSpec to create a connection. Call getConnection(ConnectionSpec spec) instead!"); 58 } 59 60 public Connection getConnection(ConnectionSpec spec) throws ResourceException { 61 if (!(spec instanceof WebDAVConnectionSpec)) { 62 throw new NotSupportedException ("Need a WebDAVConnectionSpec to create a connection!"); 63 } 64 System.out.println("Getting connection with spec "+spec); 65 return (Connection ) cm.allocateConnection(mcf, (WebDAVConnectionSpec)spec); 66 } 67 68 public RecordFactory getRecordFactory() throws ResourceException { 69 return null; 70 } 71 72 public ResourceAdapterMetaData getMetaData() throws ResourceException { 73 return null; 74 } 75 76 public void setReference(Reference reference) { 77 this.reference = reference; 78 } 79 80 public Reference getReference() throws NamingException { 81 return reference; 82 } 83 84 } 85 | Popular Tags |