}
@Override
public Result execute(UIExecutionContext context) throws Exception
{
JavaMethodResource resource = method.getValue();
Method<?, ?> m = resource.getUnderlyingResourceObject();
Annotation<?> annotation;
if (m.hasAnnotation(TransactionAttribute.class))
{
annotation = m.getAnnotation(TransactionAttribute.class);
}
else
{
if (m instanceof MethodSource)
{
annotation = ((MethodSource<?>) m).addAnnotation(TransactionAttribute.class);
}
else
{
throw new IllegalStateException("Cannot add an annotation on a binary class");
}
}
if (annotation instanceof AnnotationSource)
{
((AnnotationSource<?>) annotation).setEnumValue(type.getValue());
}
JavaType<?> source = m.getOrigin();
Resource<?> parent = resource.getParent();
if (parent instanceof JavaResource && source instanceof JavaSource)
{
((JavaResource) parent).setContents((JavaSource<?>) source);
}