(Cluster cluster)
| 350 | |
| 351 | |
| 352 | @Override |
| 353 | public void setCluster(Cluster cluster) { |
| 354 | |
| 355 | Cluster oldCluster; |
| 356 | Lock writeLock = clusterLock.writeLock(); |
| 357 | writeLock.lock(); |
| 358 | try { |
| 359 | // Change components if necessary |
| 360 | oldCluster = this.cluster; |
| 361 | if (oldCluster == cluster) { |
| 362 | return; |
| 363 | } |
| 364 | this.cluster = cluster; |
| 365 | // Start the new component if necessary |
| 366 | if (cluster != null) { |
| 367 | cluster.setContainer(this); |
| 368 | } |
| 369 | } finally { |
| 370 | writeLock.unlock(); |
| 371 | } |
| 372 | |
| 373 | // Stop the old component if necessary |
| 374 | if (getState().isAvailable() && (oldCluster instanceof Lifecycle)) { |
| 375 | try { |
| 376 | ((Lifecycle) oldCluster).stop(); |
| 377 | } catch (LifecycleException e) { |
| 378 | log.error(sm.getString("containerBase.cluster.stop"), e); |
| 379 | } |
| 380 | } |
| 381 | |
| 382 | if (getState().isAvailable() && (cluster instanceof Lifecycle)) { |
| 383 | try { |
| 384 | ((Lifecycle) cluster).start(); |
| 385 | } catch (LifecycleException e) { |
| 386 | log.error(sm.getString("containerBase.cluster.start"), e); |
| 387 | } |
| 388 | } |
| 389 | |
| 390 | // Report this property change to interested listeners |
| 391 | support.firePropertyChange("cluster", oldCluster, cluster); |
| 392 | } |
| 393 | |
| 394 | |
| 395 | @Override |
nothing calls this directly
no test coverage detected