{
Criteria c = new Criteria();
c.addEqualTo("principalName", principal.getName());
c.addEqualTo("locatorName", locatorName);
PrincipalRule pr = (PrincipalRule) getPersistenceBrokerTemplate().getObjectByQuery(
QueryFactory.newQuery(principalRuleClass, c));
if (pr == null)
{
pr = new PrincipalRuleImpl(); // TODO: factory
pr.setPrincipalName(principal.getName());
pr.setLocatorName(locatorName);
pr.setProfilingRule(rule);
}
pr.setProfilingRule(rule);
getPersistenceBrokerTemplate().store(pr);
principalRules.put(makePrincipalRuleKey(principal.getName(), locatorName), pr);
}