1 28 29 package com.caucho.jca.cfg; 30 31 import com.caucho.config.ConfigException; 32 import com.caucho.log.Log; 33 import com.caucho.util.L10N; 34 35 import java.util.ArrayList ; 36 import java.util.logging.Logger ; 37 38 41 public class ResourceAdapterConfig extends ObjectConfig { 42 private static final L10N L = new L10N(ResourceAdapterConfig.class); 43 private static final Logger log = Log.open(ResourceAdapterConfig.class); 44 45 private Class _adapterClass; 46 47 private ArrayList <ConnectionDefinition> _outboundConnections = 48 new ArrayList <ConnectionDefinition>(); 49 50 private ArrayList <MessageListenerConfig> _inboundConnections = 51 new ArrayList <MessageListenerConfig>(); 52 53 private ArrayList <AdminObjectConfig> _resources = 54 new ArrayList <AdminObjectConfig>(); 55 56 private ConnectionDefinition _connectionDefinition; 57 58 private String _transactionSupport; 59 60 public ResourceAdapterConfig() 61 { 62 } 63 64 67 public void setResourceadapterClass(Class cl) 68 throws ConfigException 69 { 70 _adapterClass = cl; 71 72 setType(cl); 73 } 74 75 78 public Class getResourceadapterClass() 79 { 80 return _adapterClass; 81 } 82 83 86 public void addAdminobject(AdminObjectConfig adminObject) 87 { 88 _resources.add(adminObject); 89 } 90 91 94 public void setManagedconnectionfactoryClass(Class cl) 95 throws ConfigException 96 { 97 getConnectionDefinition().setManagedconnectionfactoryClass(cl); 98 } 99 100 103 public void setConnectionfactoryInterface(String cl) 104 { 105 } 106 107 110 public void setConnectionfactoryImplClass(String cl) 111 { 112 } 113 114 117 public void setConnectionInterface(String cl) 118 { 119 } 120 121 124 public void setConnectionImplClass(String cl) 125 { 126 } 127 128 131 private ConnectionDefinition getConnectionDefinition() 132 throws ConfigException 133 { 134 if (_connectionDefinition == null) { 135 _connectionDefinition = new ConnectionDefinition(); 136 _outboundConnections.add(_connectionDefinition); 137 } 138 139 return _connectionDefinition; 140 } 141 142 145 void addConnectionDefinition(ConnectionDefinition conn) 146 throws ConfigException 147 { 148 if (getConnectionDefinition(conn.getConnectionFactoryInterface().getName()) != null) 149 throw new ConfigException(L.l("'{0}' is a duplicate connection-definition. The <connectionfactory-interface> must be unique.", 150 conn.getConnectionFactoryInterface().getName())); 151 152 _outboundConnections.add(conn); 153 } 154 155 158 public ConnectionDefinition getConnectionDefinition(String type) 159 { 160 if (type == null && _outboundConnections.size() == 1) 161 return _outboundConnections.get(0); 162 else if (type == null) 163 return null; 164 165 for (int i = 0; i < _outboundConnections.size(); i++) { 166 ConnectionDefinition cfg = _outboundConnections.get(i); 167 168 Class cl = cfg.getConnectionFactoryInterface(); 169 170 if (cl != null && cl.getName().equals(type)) 171 return cfg; 172 } 173 174 return null; 175 } 176 177 180 void addMessageListener(MessageListenerConfig cfg) 181 throws ConfigException 182 { 183 if (getMessageListener(cfg.getMessageListenerType().getName()) != null) 184 throw new ConfigException(L.l("'{0}' is a duplicate messagelistener-type. The <messagelistener-type> must be unique.", 185 cfg.getMessageListenerType().getName())); 186 187 _inboundConnections.add(cfg); 188 } 189 190 193 public MessageListenerConfig getMessageListener(String type) 194 { 195 if (type == null && _inboundConnections.size() == 1) 196 return _inboundConnections.get(0); 197 else if (type == null) 198 return null; 199 200 for (int i = 0; i < _inboundConnections.size(); i++) { 201 MessageListenerConfig cfg = _inboundConnections.get(i); 202 203 Class cl = cfg.getMessageListenerType(); 204 205 if (cl != null && cl.getName().equals(type)) 206 return cfg; 207 } 208 209 return null; 210 } 211 212 215 void addResource(AdminObjectConfig cfg) 216 { 217 _resources.add(cfg); 218 } 219 220 223 public AdminObjectConfig getAdminObject(String type) 224 { 225 for (int i = 0; i < _resources.size(); i++) { 226 AdminObjectConfig cfg = _resources.get(i); 227 228 Class cl = cfg.getAdminObjectClass(); 229 230 if (cl != null && cl.getName().equals(type)) 231 return cfg; 232 233 cl = cfg.getAdminObjectInterface(); 234 235 if (cl != null && cl.getName().equals(type)) 236 return cfg; 237 } 238 239 return null; 240 } 241 242 245 public void setTransactionSupport(String xa) 246 { 247 _transactionSupport = xa; 248 } 249 250 253 public String getTransactionSupport() 254 { 255 return _transactionSupport; 256 } 257 258 261 public void setReauthenticationSupport(boolean support) 262 { 263 } 264 265 268 public AuthenticationMechanism createAuthenticationMechanism() 269 { 270 return new AuthenticationMechanism(); 271 } 272 273 276 public SecurityPermission createSecurityPermission() 277 { 278 return new SecurityPermission(); 279 } 280 281 284 public OutboundResourceAdapterConfig createOutboundResourceadapter() 285 throws ConfigException 286 { 287 return new OutboundResourceAdapterConfig(this); 288 } 289 290 293 public InboundResourceAdapterConfig createInboundResourceadapter() 294 throws ConfigException 295 { 296 return new InboundResourceAdapterConfig(this); 297 } 298 299 public static class AuthenticationMechanism { 300 public void setDescription(String description) 301 { 302 } 303 304 public void setAuthenticationMechanismType(String type) 305 { 306 } 307 308 public void setCredentialInterface(String type) 309 { 310 } 311 } 312 313 public static class SecurityPermission { 314 public void setDescription(String description) 315 { 316 } 317 318 public void setSecurityPermissionSpec(String spec) 319 { 320 } 321 } 322 } 323 | Popular Tags |