use of org.jaffa.soa.services.configdomain.InjectDomainFact in project jaffa-framework by jaffa-projects.
the class SOAEventHandler method injectDomainFacts.
private void injectDomainFacts(UOW uow, ServiceRulesInterceptor interceptor, SOAEventQueueMessage message) throws FrameworkException, ApplicationExceptions {
SoaEventInfo soaEventInfo = ConfigurationService.getInstance().getSoaEventInfo(message.getEventName());
if (soaEventInfo != null) {
for (InjectDomainFact injectDomainFact : soaEventInfo.getInjectDomainFact()) {
Object[] domainKeyValues = new Object[injectDomainFact.getDomainKey().size() + 1];
try {
// Create an array of key-fields to be used for retrieving the domain object
// NOTE: If support for non-String key-fields is needed, the following logic can be further enhanced
// to take the datatype of each parameter into consideration when creating the domainKeyValues array
domainKeyValues[0] = uow;
int counter = 0;
for (String domainKeyName : injectDomainFact.getDomainKey()) {
if (domainKeyName.length() > PREFIX_PARAMS.length() && domainKeyName.startsWith(PREFIX_PARAMS)) {
domainKeyName = domainKeyName.substring(domainKeyName.length());
}
domainKeyValues[++counter] = message.getHeaderParam(domainKeyName) != null ? message.getHeaderParam(domainKeyName).getValue() : null;
}
// Invoke the findByPK method to obtain the domain object
Object domainObject = findDomainObject(injectDomainFact.getDomainClass(), domainKeyValues);
if (domainObject != null)
interceptor.addFact(domainObject);
else {
if (log.isDebugEnabled())
log.debug("Instance of domain class " + injectDomainFact.getDomainClass() + " not found with the arguments " + Arrays.toString(domainKeyValues));
}
} catch (Exception e) {
throw ExceptionHelper.throwAFR(e);
} finally {
domainKeyValues = null;
}
}
}
}
Aggregations