1 29 30 package com.caucho.ejb.gen; 31 32 import com.caucho.bytecode.JClass; 33 import com.caucho.bytecode.JMethod; 34 import com.caucho.ejb.cfg.EjbEntityBean; 35 import com.caucho.java.JavaWriter; 36 import com.caucho.java.gen.BaseMethod; 37 import com.caucho.java.gen.CallChain; 38 import com.caucho.util.L10N; 39 40 import java.io.IOException ; 41 42 45 public class EntityHomeView extends ViewClass { 46 private static L10N L = new L10N(EntityHomeView.class); 47 48 private EjbEntityBean _bean; 49 50 private JClass _remoteClass; 51 private String _prefix; 52 private String _contextClassName; 53 private boolean _isCMP; 54 55 public EntityHomeView(JClass remoteClass, 56 String contextClassName, 57 String prefix, 58 boolean isCMP) 59 { 60 super(prefix, "Entity" + prefix); 61 62 addInterfaceName(remoteClass.getName()); 63 64 _contextClassName = contextClassName; 65 _prefix = prefix; 66 67 setStatic(true); 68 _isCMP = isCMP; 69 } 70 71 74 public void addMethod(BaseMethod method) 75 { 76 addComponent(method); 77 } 78 79 public BaseMethod createCreateMethod(EjbEntityBean bean, 80 JMethod api, 81 JMethod create, 82 JMethod postCreate, 83 String fullClassName) 84 { 85 EntityCreateMethod method; 86 method = new EntityCreateMethod(bean, api, create, 87 postCreate, fullClassName); 88 89 EntityCreateCall call = (EntityCreateCall) method.getCall(); 90 91 call.setCMP(_isCMP); 92 93 return method; 94 } 95 96 99 public CallChain createPoolChain(CallChain call) 100 { 101 return new EntityPoolChain(call, true); 102 } 103 104 public void generate(JavaWriter out) 105 throws IOException 106 { 107 generateGetter(out); 108 109 out.println(); 110 super.generate(out); 111 } 112 113 private void generateGetter(JavaWriter out) 114 throws IOException 115 { 116 if (_prefix.equals("RemoteHome")) { 117 out.println(); 118 out.println("public EJBHome createRemoteHomeView()"); 119 out.println("{"); 120 out.println(" return new RemoteHome(this);"); 121 out.println("}"); 122 out.println(); 123 } 124 else { 125 out.println(); 126 out.println("public EJBLocalHome createLocalHome()"); 127 out.println("{"); 128 out.println(" return new LocalHome(this);"); 129 out.println("}"); 130 out.println(); 131 } 132 } 133 134 protected void generateClassContent(JavaWriter out) 135 throws IOException 136 { 137 out.println("private " + _contextClassName + " _context;"); 138 out.println("private EjbTransactionManager _xaManager;"); 139 out.println(); 140 out.println(_prefix + "(" + _contextClassName + " context)"); 141 out.println("{"); 142 out.println(" super(context.getEntityServer());"); 143 out.println(" _context = context;"); 144 out.println(" _xaManager = _server.getTransactionManager();"); 145 out.println("}"); 146 out.println(); 147 out.println("private " + _contextClassName + " getContext()"); 148 out.println("{"); 149 out.println(" return _context;"); 150 out.println("}"); 151 152 out.println(); 153 out.println("public Handle getHandle()"); 154 out.println("{"); 155 out.println(" return getContext().getHandle();"); 156 out.println("}"); 157 158 out.println(); 159 160 generateComponents(out); 161 } 162 } 163 | Popular Tags |