1 23 24 package com.sun.enterprise.resource; 25 26 import javax.transaction.xa.XAResource ; 27 import javax.resource.spi.*; 28 import javax.resource.ResourceException ; 29 import javax.security.auth.Subject ; 30 import java.util.logging.*; 31 32 import com.sun.enterprise.deployment.ConnectorDescriptor; 33 import com.sun.enterprise.PoolManager; 34 35 38 public class LocalTxConnectorAllocator extends AbstractConnectorAllocator { 39 40 41 public LocalTxConnectorAllocator(PoolManager poolMgr, 42 ManagedConnectionFactory mcf, 43 ResourceSpec spec, 44 Subject subject, 45 ConnectionRequestInfo reqInfo, 46 ClientSecurityInfo info, 47 ConnectorDescriptor desc) { 48 super(poolMgr, mcf, spec, subject, reqInfo, info, desc); 49 } 50 51 52 public ResourceHandle createResource() 53 throws PoolingException 54 { 55 try { 56 ManagedConnection mc = 57 mcf.createManagedConnection(subject, reqInfo); 58 59 ResourceHandle resource = 60 new ResourceHandle(mc, spec, this, info); 61 ConnectionEventListener l = 62 new LocalTxConnectionEventListener(resource); 63 mc.addConnectionEventListener(l); 64 resource.setListener(l); 65 66 XAResource xares = 67 new ConnectorXAResource(resource, spec, this, info); 68 resource.fillInResourceObjects(null, xares); 69 70 return resource; 71 } catch (ResourceException ex) { 72 _logger.log(Level.WARNING,"poolmgr.create_resource_error",ex.getMessage()); 73 _logger.log(Level.FINE,"Resource Exception while creating resource",ex); 74 75 if (ex.getLinkedException() != null) { 76 _logger.log(Level.WARNING,"poolmgr.create_resource_error",ex.getLinkedException().getMessage()); 77 } 78 throw new PoolingException(ex); 79 } 80 } 81 82 public void fillInResourceObjects(ResourceHandle resource) 83 throws PoolingException 84 { 85 try { 86 ManagedConnection mc = (ManagedConnection) resource.getResource(); 87 88 Object con = mc.getConnection(subject, reqInfo); 89 90 ConnectorXAResource xares = (ConnectorXAResource) resource.getXAResource(); 91 xares.setUserHandle(con); 92 resource.fillInResourceObjects(con, xares); 93 } catch (ResourceException ex) { 94 throw new PoolingException(ex); 95 } 96 } 97 98 public void destroyResource(ResourceHandle resource) 99 throws PoolingException { 100 try { 101 ManagedConnection mc = (ManagedConnection) resource.getResource(); 102 ConnectorXAResource.freeListener(mc); 103 mc.destroy(); 104 if (_logger.isLoggable( Level.FINEST ) ) { 105 _logger.finest( "destroyResource for LocalTxConnectorAllocator done"); 106 } 107 108 } catch (Exception ex) { 109 _logger.log(Level.WARNING, ex.getMessage()); 110 throw new PoolingException(ex); 111 } 112 } 113 114 115 public boolean shareableWithinComponent() { 116 return true; 119 } 120 121 } 122 | Popular Tags |