1 29 30 package com.caucho.jms.jca; 31 32 import com.caucho.config.ConfigException; 33 import com.caucho.log.Log; 34 import com.caucho.util.L10N; 35 36 import javax.resource.ResourceException ; 37 import javax.resource.spi.ConnectionManager ; 38 import javax.resource.spi.ConnectionRequestInfo ; 39 import javax.resource.spi.ManagedConnection ; 40 import javax.resource.spi.ManagedConnectionFactory ; 41 import javax.resource.spi.ResourceAdapter ; 42 import javax.security.auth.Subject ; 43 import java.io.PrintWriter ; 44 import java.util.Iterator ; 45 import java.util.Set ; 46 import java.util.logging.Logger ; 47 48 51 public class MessageSenderManager implements ManagedConnectionFactory { 52 protected static final Logger log = Log.open(MessageSenderManager.class); 53 private static final L10N L = new L10N(MessageSenderManager.class); 54 55 private ResourceAdapterImpl _ra; 56 57 public MessageSenderManager() 58 { 59 } 60 61 public ResourceAdapter getResourceAdapter() 62 { 63 return _ra; 64 } 65 66 public void setResourceAdapter(ResourceAdapter adapter) 67 throws ResourceException 68 { 69 if (! (adapter instanceof ResourceAdapterImpl)) 70 throw new ResourceException (L.l("'{0}' is not a valid resource-adapter for MessageSenderManager.", 71 adapter.getClass().getName())); 72 73 _ra = (ResourceAdapterImpl) adapter; 74 } 75 76 public void init() 77 throws ConfigException 78 { 79 if (_ra == null) 80 throw new ConfigException(L.l("MessageSenderManager must be configured with a resource adapter")); 81 } 82 83 86 public Object createConnectionFactory(ConnectionManager connManager) 87 throws ResourceException 88 { 89 return new MessageSenderImpl(this, connManager); 90 } 91 92 96 public Object createConnectionFactory() 97 throws ResourceException 98 { 99 throw new UnsupportedOperationException (); 100 } 101 102 105 public ManagedConnection 106 createManagedConnection(Subject subject, 107 ConnectionRequestInfo requestInfo) 108 throws ResourceException 109 { 110 ResourceAdapterImpl ra = _ra; 111 112 return new ManagedSessionImpl(ra.getConnectionFactory(), 113 ra.getDestination()); 114 } 115 116 119 public ManagedConnection 120 matchManagedConnections(Set connSet, 121 Subject subject, 122 ConnectionRequestInfo requestInfo) 123 throws ResourceException 124 { 125 Iterator <ManagedSessionImpl> iter = (Iterator <ManagedSessionImpl>) connSet.iterator(); 126 127 if (iter.hasNext()) { 128 ManagedSessionImpl mConn; 129 mConn = (ManagedSessionImpl) iter.next(); 130 131 return mConn; 132 } 133 134 return null; 135 } 136 137 140 public PrintWriter getLogWriter() 141 { 142 return null; 143 } 144 145 148 public void setLogWriter(PrintWriter log) 149 { 150 } 151 } 152 153 | Popular Tags |