1 23 24 package org.objectweb.perseus.connector.ra.fos; 25 26 import org.objectweb.perseus.connector.manager.standalone.SaManager; 27 import org.objectweb.perseus.fos.api.FosLoggerFactory; 28 import org.objectweb.util.monolog.api.BasicLevel; 29 import org.objectweb.util.monolog.api.Level; 30 import org.objectweb.util.monolog.api.Logger; 31 32 import javax.naming.NamingException ; 33 import javax.naming.Reference ; 34 import javax.resource.NotSupportedException ; 35 import javax.resource.ResourceException ; 36 import javax.resource.cci.Connection ; 37 import javax.resource.cci.ConnectionFactory ; 38 import javax.resource.cci.ConnectionSpec ; 39 import javax.resource.cci.RecordFactory ; 40 import javax.resource.cci.ResourceAdapterMetaData ; 41 import javax.resource.spi.ConnectionManager ; 42 import javax.resource.spi.ConnectionRequestInfo ; 43 import javax.resource.spi.ManagedConnectionFactory ; 44 import javax.security.auth.Subject ; 45 46 49 public class FosConnectionFactory 50 implements ConnectionFactory , ResourceAdapterMetaData { 51 54 private Logger logger; 55 58 private Logger entityLogger; 59 62 private final static String FOSADAPTERVERSION = "1.01"; 63 66 private final static String FOSADAPTERVENDORNAME = "The ObjectWeb Consortium"; 67 70 private final static String FOSADAPTERNAME = "File Object Store (FOS) Adapter"; 71 74 private final static String FOSADAPTERSHORTDESCRIPTION = "It provides a storage subsystem for storing data objects into files.\nThe approach assumes that each data object is stored within a different file.\nIt supports transactions (atomic I/Os through logging/recovery) as well as XA."; 75 78 private final static String FOSSPECVERSION = "1.01"; 79 80 83 private Reference jndiReference = null; 84 87 private ConnectionManager connectionManager = null; 88 91 private FosManagedConnectionFactory managedConnectionFactory; 92 93 101 FosConnectionFactory(FosManagedConnectionFactory fmcf, ConnectionManager cm) 102 throws ResourceException { 103 logger = fmcf.getLogger(FosLoggerFactory.CONNECTION, true); 104 entityLogger = fmcf.getLogger(FosLoggerFactory.CONNECTION, false); 105 if (FosLoggerFactory.DEBUG) 106 logger.log(BasicLevel.DEBUG, 107 "Constructs a new FosConnectionFactory."); 108 if (cm == null) { 109 if (FosLoggerFactory.DEBUG) 110 logger.log(BasicLevel.DEBUG, 111 "Constructs a default ConnectionManager."); 112 connectionManager = new SaManager(); 113 ((SaManager) connectionManager).setManagedConnectionFactory(fmcf); 114 } else { 115 connectionManager = cm; 116 } 117 managedConnectionFactory = fmcf; 118 } 119 120 124 FosConnectionImpl createConnection() throws ResourceException { 125 if (FosLoggerFactory.DEBUG) 126 logger.log(BasicLevel.DEBUG, "Creates a new FosConnectionImpl."); 127 return new FosConnectionImpl(entityLogger, this); 128 } 129 130 132 136 public Connection getConnection() throws ResourceException { 137 return (Connection ) connectionManager.allocateConnection( 138 managedConnectionFactory, 139 (ConnectionRequestInfo ) null); 140 } 141 142 147 public Connection getConnection(ConnectionSpec spec) throws ResourceException { 148 return (Connection ) connectionManager.allocateConnection( 149 managedConnectionFactory, 150 (ConnectionRequestInfo ) null); 151 } 152 153 157 public void setReference(Reference reference) { 158 jndiReference = reference; 159 } 160 161 165 public Reference getReference() throws NamingException { 166 return jndiReference; 167 } 168 169 172 public RecordFactory getRecordFactory() throws ResourceException { 173 throw new NotSupportedException ("FOS: no support for record."); 174 } 175 176 179 public ResourceAdapterMetaData getMetaData() throws ResourceException { 180 return this; 181 } 182 183 185 189 public String getAdapterVersion() { 190 return FOSADAPTERVERSION; 191 } 192 193 197 public String getAdapterVendorName() { 198 return FOSADAPTERVENDORNAME; 199 } 200 201 205 public String getAdapterName() { 206 return FOSADAPTERNAME; 207 } 208 209 213 public String getAdapterShortDescription() { 214 return FOSADAPTERSHORTDESCRIPTION; 215 } 216 217 221 public String getSpecVersion() { 222 return FOSSPECVERSION; 223 } 224 225 228 public String [] getInteractionSpecsSupported() { 229 return new String [0]; 230 } 231 232 235 public boolean supportsExecuteWithInputAndOutputRecord() { 236 return false; 237 } 238 239 242 public boolean supportsExecuteWithInputRecordOnly() { 243 return false; 244 } 245 246 249 public boolean supportsLocalTransactionDemarcation() { 250 return true; 251 } 252 } | Popular Tags |