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