private void configurationUpdated()

in tx-control-services/tx-control-service-xa/src/main/java/org/apache/aries/tx/control/service/xa/impl/Activator.java [97:165]


	private void configurationUpdated(Dictionary<String, ?> config, boolean internal) {
		Map<String,Object> newConfig = toMap(config);
		Runnable action;
		synchronized (this) {
			if(!open) {
				return;
			}
			
			if(internal && configuration != null) {
				// We can ignore the internal call as we've been configured;
				return;
			}
			
			ChangeType change = txControlImpl == null ? RECREATE :
					txControlImpl.changed(newConfig, txControlReg == null);
			switch(change) {
				case NONE :
					action = () -> {};
					break;
				case SERVICE_PROPS:
					ServiceRegistration<TransactionControl> toUpdate = txControlReg;
					TransactionControlImpl implToQuery = txControlImpl;
					action = () -> toUpdate.setProperties(implToQuery.getProperties());
					break;
				case RECREATE :
					ServiceRegistration<TransactionControl> toUnregister = txControlReg;
					TransactionControlImpl toClose = txControlImpl;
					txControlReg = null;
					txControlImpl = null;
					action = () -> {
						
							cleanUp(toUnregister, toClose);
						
							TransactionControlImpl impl = null;
							ServiceRegistration<TransactionControl> newReg = null;
							try {
								impl = new TransactionControlImpl(context, newConfig);
								newReg = context.registerService(TransactionControl.class, 
												impl, impl.getProperties());
							} catch (Exception e) {
								if(newReg != null) {
									safeUnregister(newReg);
								} 
								if (impl != null) {
									impl.close();
								}
							}
							boolean cleanUp = true;
							synchronized (Activator.this) {
								if(configuration == newConfig && open) {
									txControlImpl = impl;
									txControlReg = newReg;
									cleanUp = false;
								}
							}
							
							if(cleanUp) {
								cleanUp(newReg, impl);
							}
						};
					
					break;
				default :
					throw new IllegalArgumentException("An unknown change occurred " + change);
			}
			configuration = newConfig;
		}
		action.run();
	}