final JavaSymbolName methodName, final String methodDelegateName) {
// Method definition to find or build
final JavaType[] parameterTypes = {};
// Locate user-defined method
final MethodMetadata userMethod = getGovernorMethod(methodName,
parameterTypes);
if (userMethod != null) {
return new MethodMetadataBuilder(userMethod);
}
// Create the method
final List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>();
final InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
// Address non-injected entity manager field
final MethodMetadata entityManagerMethod = getEntityManagerMethod();
Validate.notNull(entityManagerMethod,
"Entity manager method should not have returned null");
// Use the getEntityManager() method to acquire an entity manager (the
// method will throw an exception if it cannot be acquired)
final String entityManagerFieldName = getEntityManagerField()
.getFieldName().getSymbolName();
bodyBuilder.appendFormalLine("if (this." + entityManagerFieldName
+ " == null) this." + entityManagerFieldName + " = "
+ entityManagerMethod.getMethodName().getSymbolName() + "();");
JavaType returnType = JavaType.VOID_PRIMITIVE;
if ("flush".equals(methodDelegateName)) {
addTransactionalAnnotation(annotations);
bodyBuilder.appendFormalLine("this." + entityManagerFieldName