package com.mooo.aimmac23.hub.proxy;

import java.util.Map;

import org.openqa.grid.internal.utils.CapabilityMatcher;

public class ReliableCapabilityMatcher implements CapabilityMatcher {
	
	private CapabilityMatcher innerMatcher;
	private ReliabilityAwareProxy proxy;

	public ReliableCapabilityMatcher(ReliabilityAwareProxy proxy, CapabilityMatcher innerMatcher) {
		this.proxy = proxy;
		this.innerMatcher = innerMatcher;
	}
	
	@Override
	public boolean matches(Map<String, Object> currentCapability,
			Map<String, Object> requestedCapability) {
		
		// to allow the node to be tested - we're calling enough internal
		// methods to ensure that we're calling this on the correct node
		if(requestedCapability.containsKey("proxyId")) {
			return innerMatcher.matches(currentCapability, requestedCapability);
		}
		
		// check to see if we're allowed to use that config
		if(!proxy.isCapabilityWorking(currentCapability)) {
			return false;
		}
		
		// otherwise, match on the capabilities
		return innerMatcher.matches(currentCapability, requestedCapability);
	}
}

@@ -52,16 +52,49 @@
 til.Map;
+%0Aimport java.util.logging.Logger;
 %0A%0Aimport
@@ -217,16 +217,108 @@
 her %7B%0A%09%0A
+%09private static Logger log = Logger.getLogger(ReliableCapabilityMatcher.class.getName());%0A%09%0A
 %09private
@@ -1041,24 +1041,111 @@
 ability)) %7B%0A
+%09%09%09log.info(%22Node capability broken - not matching capability: %22 + currentCapability);%0A
 %09%09%09return fa

Add some helpful logging