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.java.JavaWriter; 35 import com.caucho.java.gen.BaseMethod; 36 import com.caucho.java.gen.CallChain; 37 import com.caucho.util.L10N; 38 39 import java.io.IOException ; 40 41 44 public class SessionHomeView extends ViewClass { 45 private static L10N L = new L10N(SessionHomeView.class); 46 47 private JClass _remoteClass; 48 private String _prefix; 49 private String _contextClassName; 50 private boolean _isStateless; 51 52 public SessionHomeView(JClass remoteClass, 53 String contextClassName, 54 String prefix, 55 boolean isStateless) 56 { 57 super(prefix, isStateless ? "StatelessHome" : "SessionHome"); 58 59 addInterfaceName(remoteClass.getName()); 60 61 _contextClassName = contextClassName; 62 _prefix = prefix; 63 _isStateless = isStateless; 64 65 setStatic(true); 66 } 67 68 71 public void addMethod(BaseMethod method) 72 { 73 addComponent(method); 74 } 75 76 79 public BaseMethod createCreateMethod(JMethod apiMethod, 80 JMethod implMethod, 81 String fullClassName, 82 String prefix) 83 { 84 if (_isStateless) 85 return new StatelessCreateMethod(apiMethod, 86 fullClassName, 87 prefix); 88 else 89 return new SessionCreateMethod(apiMethod, 90 implMethod, 91 fullClassName, 92 prefix); 93 } 94 95 98 public CallChain createPoolChain(CallChain call) 99 { 100 return call; 101 } 102 103 public void generate(JavaWriter out) 104 throws IOException 105 { 106 generateGetter(out); 107 108 out.println(); 109 super.generate(out); 110 } 111 112 private void generateGetter(JavaWriter out) 113 throws IOException 114 { 115 if (_prefix.equals("RemoteHome")) { 116 out.println(); 117 out.println("public EJBHome createRemoteHomeView()"); 118 out.println("{"); 119 out.println(" return new RemoteHome(this);"); 120 out.println("}"); 121 out.println(); 122 } 123 else { 124 out.println(); 125 out.println("public EJBLocalHome createLocalHome()"); 126 out.println("{"); 127 out.println(" return new LocalHome(this);"); 128 out.println("}"); 129 out.println(); 130 } 131 } 132 133 protected void generateClassContent(JavaWriter out) 134 throws IOException 135 { 136 out.println("private " + _contextClassName + " _context;"); 137 out.println("private EjbTransactionManager _xaManager;"); 138 out.println(); 139 out.println(_prefix + "(" + _contextClassName + " context)"); 140 out.println("{"); 141 if (_isStateless) 142 out.println(" super(context.getStatelessServer());"); 143 else 144 out.println(" super(context.getSessionServer());"); 145 146 out.println(" _context = context;"); 147 out.println(" _xaManager = _server.getTransactionManager();"); 148 out.println("}"); 149 out.println(); 150 out.println("public AbstractContext getContext()"); 151 out.println("{"); 152 out.println(" return _context;"); 153 out.println("}"); 154 155 out.println(); 156 157 generateComponents(out); 158 } 159 } 160 | Popular Tags |