* boolean, String)
*/
protected Message instantiateMessageInASpecificPackage(String theName,
String theVersion, boolean isExplicit, String packageName)
throws HL7Exception {
Message result = null;
try {
Class<? extends Message> messageClass = myFactory
.getMessageClassInASpecificPackage(theName, theVersion,
isExplicit, packageName);
if (messageClass == null) {
throw new ClassNotFoundException(
"Can't find message class in current package list: "
+ theName);
}
log.debug("Instantiating msg of class {}", messageClass.getName());
Constructor<? extends Message> constructor = messageClass
.getConstructor(new Class[] { ModelClassFactory.class });
result = (Message) constructor
.newInstance(new Object[] { myFactory });
} catch (Exception e) {
throw new HL7Exception("Couldn't create Message object of type "
+ theName, HL7Exception.UNSUPPORTED_MESSAGE_TYPE, e);
}
result.setValidationContext(myContext);
return result;
}