com.ibm.portal.outbound.config.impl
Class DefaultPolicyRulesMatcher

java.lang.Object
  extended by com.ibm.portal.outbound.config.impl.DefaultPolicyRulesMatcher
All Implemented Interfaces:
PatternMatcher<PolicyRule>

public class DefaultPolicyRulesMatcher
extends java.lang.Object
implements PatternMatcher<PolicyRule>

This utility class is used by the collector AdministrableLocator#collectAllMatching()to create an ordered list of policy rules that match with a given URL. The matcher receives a URL (in String representation), which should be used to compare against PolicyRule candidates.

The following code excerpt asks for the best matching policy rule in the default mapping of the global configuration:

List matchingPolicies = new ArrayList;
javax.naming.Context ctx = new javax.naming.InitialContext();
OutboundConnectionModelHome home = (OutboundConnectionModelHome) ctx.lookup("portal:service/model/OutboundConnectionModel");
OutboundConnectionModel model = home.getOutboundConnectionModelProvider().getOutboundConnectionModel();
OutboundConnectionProfile prf = model.getProfileLocator().findGlobalProfile();
PolicyMapping map = model.getPolicyMappingLocator(prf).GetDefaultMapping();

model.getPolicyRuleLocator(map).collectAllMatching(new DefaultPolicyRulesMatcher("http://my.server.org/some_path/test.html"), matchingPolicies);

if (matchingPolicies.size() == 0) {
} else {
System.out.println("The best-matching policy is "+matchingPolicies.get(0));
if (matchingPolicies.size() > 1) {
System.out.println("The second-best-matching policy is "+matchingPolicies.get(1));
}
}

Since:
8.5.0
See Also:
PatternMatcher, AdministrableLocator

Constructor Summary
DefaultPolicyRulesMatcher(java.lang.String url)
          Instantiate a policy rules matcher for a given URL.
 
Method Summary
protected  int getMatchCount(java.lang.String wildcardExpression, java.lang.String candidate)
           
 int getMatchValue(PolicyRule compareWith)
          Compare a policy rule against the url that has been defined in the constructor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultPolicyRulesMatcher

public DefaultPolicyRulesMatcher(java.lang.String url)
Instantiate a policy rules matcher for a given URL. This matcher can be used to collect all connection policies that apply on this rule, and sort them according to their siginificance.

Parameters:
url - A string that denotes the URL for which
Method Detail

getMatchValue

public int getMatchValue(PolicyRule compareWith)
Compare a policy rule against the url that has been defined in the constructor. The method returns a match counter that denotes the gravity of the match.

Specified by:
getMatchValue in interface PatternMatcher<PolicyRule>
Parameters:
compareWith - A policy rule
Returns:
int a match counter 0 means no match, a value greater than 0 means that the policy rule matches with the url.

getMatchCount

protected int getMatchCount(java.lang.String wildcardExpression,
                            java.lang.String candidate)