Creating a JAsCo Combination Strategy

JAsCo combination strategies are used to specify complex interactions between sets of instantiated hooks and act as a kind of filter mechanism. For more information about the concepts and syntax of JAsCo combination strategies, we refer to the JAsCo language reference. The JAsCo combination strategy wizard helps the user to implement JAsCo combination strategies.

Create a new package called strategies. Add a new combination strategy called ExcludeStrategy by going to FileNewJAsCo Combination Strategy.

Specify the number of hooks the strategy should take as input. In the case of ExcludeStrategy, two hooks are taken as input. Press the finish button. The body of the combination strategy is automatically generated. Only the logic itself needs to be implemented.

Modify the text in the editor so that it reflects the code specified below, and save it. In this case, the strategy will remove hook1 if hook0 is also applicable.

package strategies;

import jasco.runtime.connector.CombinationStrategy;
import jasco.runtime.connector.HookList;

public class ExcludeStrategy implements CombinationStrategy {
	
	Object hook0;
	Object hook1;
	
	public ExcludeStrategy(Object inputHook0, Object inputHook1) {
		hook0 = inputHook0;
		hook1 = inputHook1;
	}
	
	public HookList validateCombinations(HookList list) {
		if (list.contains(hook0)) {
			list.remove(hook1);
		}
		return list;
	}
}

Your Eclipse environment should now look like the one in the following image.

Combination strategies are deployed in step three of the JAsCo connector wizard. Check the box to indicate that you want to add a combination strategy to the connector. Select the strategy itself and add one or more corresponding hooks in the right order of input. When the connector is generated, the combination strategy is automatically added. At runtime, the combination strategies are automatically activated.