1 23 24 package com.sun.enterprise.connectors; 25 26 import com.sun.enterprise.deployment.EnvironmentProperty; 27 import java.io.Serializable ; 28 import java.util.Set ; 29 import java.util.Vector ; 30 import java.util.HashSet ; 31 import java.util.Iterator ; 32 import java.util.logging.Logger ; 33 import com.sun.logging.LogDomains; 34 import com.sun.enterprise.connectors.util.ConnectionPoolReconfigHelper.ReconfigAction; 35 36 42 43 public class ConnectorDescriptorInfo implements Serializable { 44 45 protected String rarName_; 46 protected String resourceAdapterClass_; 47 protected String connectionDefinitionName_; 48 protected String managedConnectionFactoryClass_; 49 protected String connectionFactoryClass_; 50 protected String connectionFactoryInterface_; 51 protected String connectionClass_; 52 protected String connectionInterface_; 53 protected Set mcfConfigProperties_; 54 protected Set resourceAdapterConfigProperties_; 55 56 private static Logger _logger = LogDomains.getLogger(LogDomains.RSR_LOGGER); 57 58 61 62 public ConnectorDescriptorInfo() { 63 64 mcfConfigProperties_ = new HashSet (); 65 resourceAdapterConfigProperties_ = new HashSet (); 66 } 67 68 72 73 public ConnectorDescriptorInfo doClone() { 74 75 ConnectorDescriptorInfo cdi = new ConnectorDescriptorInfo(); 76 cdi.setMCFConfigProperties(mcfConfigProperties_); 77 cdi.setResourceAdapterConfigProperties( 78 resourceAdapterConfigProperties_); 79 cdi.setRarName(rarName_); 80 cdi.setResourceAdapterClassName(resourceAdapterClass_); 81 cdi.setConnectionDefinitionName(connectionDefinitionName_); 82 cdi.setManagedConnectionFactoryClass(managedConnectionFactoryClass_); 83 cdi.setConnectionFactoryClass(connectionFactoryClass_); 84 cdi.setConnectionFactoryInterface(connectionFactoryInterface_); 85 cdi.setConnectionClass(connectionClass_); 86 cdi.setConnectionInterface(connectionInterface_); 87 return cdi; 88 } 89 90 95 96 public ConnectorDescriptorInfo( 97 EnvironmentProperty[] mcfConfigProperties, 98 EnvironmentProperty[] resourceAdapterConfigProperties) 99 { 100 mcfConfigProperties_ = new HashSet (); 101 resourceAdapterConfigProperties_ = new HashSet (); 102 if(mcfConfigProperties != null) { 103 for(int i=0; i<mcfConfigProperties.length; ++i) { 104 mcfConfigProperties_.add(mcfConfigProperties[i]); 105 } 106 } 107 if(resourceAdapterConfigProperties != null) { 108 for(int i=0; i<mcfConfigProperties.length; ++i) { 109 resourceAdapterConfigProperties_.add(mcfConfigProperties[i]); 110 } 111 } 112 } 113 114 118 119 public void addMCFConfigProperty(EnvironmentProperty configProperty) { 120 if(configProperty != null) { 121 mcfConfigProperties_.add(configProperty); 122 } 123 } 124 125 129 130 public void removeMCFConfigProperty(EnvironmentProperty configProperty) { 131 if(configProperty != null) { 132 mcfConfigProperties_.remove(configProperty); 133 } 134 } 135 136 140 141 public void setMCFConfigProperties(Set configProperties) { 142 mcfConfigProperties_ = configProperties; 143 } 144 145 149 150 public void setMCFConfigProperties(EnvironmentProperty[] configProperties) { 151 if(configProperties != null) { 152 for(int i=0; i<configProperties.length; ++i) { 153 mcfConfigProperties_.add(configProperties[i]); 154 } 155 } 156 } 157 158 162 163 public Set getMCFConfigProperties() { 164 return mcfConfigProperties_; 165 } 166 167 171 172 public void addResourceAdapterConfigProperty( 173 EnvironmentProperty configProperty) 174 { 175 if(configProperty != null) { 176 resourceAdapterConfigProperties_.add(configProperty); 177 } 178 } 179 180 184 185 public void removeResourceAdapterConfigProperty( 186 EnvironmentProperty configProperty) 187 { 188 if(configProperty != null) { 189 resourceAdapterConfigProperties_.remove(configProperty); 190 } 191 } 192 193 197 198 public void setResourceAdapterConfigProperties(Set configProperties) { 199 resourceAdapterConfigProperties_ = configProperties; 200 } 201 202 206 207 public void setResourceAdapterConfigProperties( 208 EnvironmentProperty[] configProperties) 209 { 210 if(configProperties != null) { 211 for(int i=0; i<configProperties.length; ++i) { 212 resourceAdapterConfigProperties_.add(configProperties[i]); 213 } 214 } 215 } 216 217 221 222 public Set getResourceAdapterConfigProperties() { 223 return resourceAdapterConfigProperties_; 224 } 225 226 230 231 public String getRarName() { 232 return rarName_; 233 } 234 235 238 239 public void setRarName(String rarName) { 240 rarName_ = rarName; 241 } 242 243 247 248 public String getResourceAdapterClassName() { 249 return resourceAdapterClass_; 250 } 251 252 255 256 public void setResourceAdapterClassName(String resourceAdapterClass) { 257 resourceAdapterClass_ = resourceAdapterClass; 258 } 259 260 264 265 public String getConnectionDefinitionName() { 266 return connectionDefinitionName_; 267 } 268 269 272 273 public void setConnectionDefinitionName(String connectionDefinitionName) { 274 connectionDefinitionName_ = connectionDefinitionName; 275 } 276 277 281 282 public String getManagedConnectionFactoryClass() { 283 return managedConnectionFactoryClass_; 284 } 285 286 289 290 public void setManagedConnectionFactoryClass( 291 String managedConnectionFactoryClass) 292 { 293 managedConnectionFactoryClass_ = managedConnectionFactoryClass; 294 } 295 296 300 301 public String getConnectionFactoryClass() { 302 return connectionFactoryClass_; 303 } 304 305 308 309 public void setConnectionFactoryClass(String connectionFactoryClass) { 310 connectionFactoryClass_ = connectionFactoryClass; 311 } 312 313 317 318 public String getConnectionFactoryInterface() { 319 return connectionFactoryInterface_; 320 } 321 322 325 326 public void setConnectionFactoryInterface( 327 String connectionFactoryInterface) 328 { 329 connectionFactoryInterface_ = connectionFactoryInterface; 330 } 331 332 336 337 public String getConnectionClass() { 338 return connectionClass_; 339 } 340 341 344 345 public void setConnectionClass(String connectionClass) { 346 connectionClass_ = connectionClass; 347 } 348 349 353 354 public String getConnectionInterface() { 355 return connectionInterface_; 356 } 357 358 361 362 public void setConnectionInterface(String connectionInterface) { 363 connectionInterface_ = connectionInterface; 364 } 365 366 375 376 public ReconfigAction compareMCFConfigProperties( ConnectorDescriptorInfo cdi) { 377 return compareMCFConfigProperties( cdi, new HashSet () ); 378 } 379 380 390 391 public ReconfigAction compareMCFConfigProperties( 392 ConnectorDescriptorInfo cdi, Set excluded ) 393 { 394 Set mcfConfigProps = cdi.getMCFConfigProperties(); 395 396 if (mcfConfigProps.size() != mcfConfigProperties_.size() ) { 397 return ReconfigAction.RECREATE_POOL; 400 } 401 402 boolean same = false; 403 Iterator iter = mcfConfigProps.iterator(); 404 405 while( iter.hasNext() ) { 406 EnvironmentProperty prop = (EnvironmentProperty)iter.next(); 407 if (excluded.contains( prop.getName()) ) { 409 continue; 411 } 412 413 Iterator iter2 = mcfConfigProperties_.iterator(); 414 while( iter2.hasNext() ) { 415 if(isEnvPropEqual(prop,(EnvironmentProperty)iter2.next())){ 416 same = true; 418 break; 420 } 421 } 422 if (! same ) { 423 return ReconfigAction.RECREATE_POOL; 426 } 427 same = false; 428 } 429 430 return ReconfigAction.NO_OP; 431 } 432 433 437 438 private boolean isEnvPropEqual( EnvironmentProperty e1, 439 EnvironmentProperty e2 ) 440 { 441 if (e1 != null && e2 != null && 442 e1.getName() != null && e2.getName() != null && 443 e1.getName().equals( e2.getName())) { 444 if (e1.getValue() != null && e2.getValue() != null && 445 e1.getValue().equals( e2.getValue() ) ) { 446 return true; 447 } 448 } 449 453 454 return false; 455 } 456 } 457 | Popular Tags |