1 29 30 package com.caucho.ejb.gen; 31 32 import com.caucho.bytecode.JMethod; 33 import com.caucho.java.JavaWriter; 34 import com.caucho.java.gen.BaseMethod; 35 import com.caucho.util.L10N; 36 37 import java.io.IOException ; 38 39 42 public class CollectionSetter extends BaseMethod { 43 private static final L10N L = new L10N(CollectionSetter.class); 44 45 private JMethod _method; 46 private String _implClassName; 47 48 public CollectionSetter(JMethod method, 49 String implClassName) 50 { 51 super(method); 52 53 _method = method; 54 _implClassName = implClassName; 55 } 56 57 62 public void generateCall(JavaWriter out, String []args) 63 throws IOException 64 { 65 out.println("com.caucho.ejb.xa.TransactionContext xa = _xaManager.beginRequired();"); 66 out.println(); 67 68 out.println("try {"); 69 70 out.println(" Bean ptr = _context._ejb_begin(xa, false, true);"); 71 72 String methodName = _method.getName(); 73 String getterName = "get" + methodName.substring(3); 74 75 out.print(_method.getParameterTypes()[0].getPrintName()); 76 out.println(" var = ptr." + getterName + "();"); 77 out.println("var.clear();"); 78 out.println("var.addAll(" + args[0] + ");"); 79 80 out.println("} catch (RuntimeException e) {"); 81 out.println(" xa.setRollbackOnly(e);"); 82 out.println(" throw e;"); 83 out.println("} finally {"); 84 out.println(" xa.commit();"); 85 out.println("}"); 86 } 87 } 88 | Popular Tags |