1 19 package org.netbeans.modules.j2ee.ejbcore.api.methodcontroller; 20 21 import java.util.Collections ; 22 import javax.lang.model.element.Modifier; 23 import org.netbeans.modules.j2ee.common.method.MethodModel; 24 import org.netbeans.modules.j2ee.ejbcore.api.methodcontroller.MethodType.BusinessMethodType; 25 import org.netbeans.modules.j2ee.ejbcore.api.methodcontroller.MethodType.CreateMethodType; 26 import org.netbeans.modules.j2ee.ejbcore.api.methodcontroller.MethodType.FinderMethodType; 27 import org.netbeans.modules.j2ee.ejbcore.api.methodcontroller.MethodType.HomeMethodType; 28 29 34 final class SessionGenerateFromIntfVisitor implements MethodType.MethodTypeVisitor, AbstractMethodController.GenerateFromIntf { 35 36 private MethodModel implMethod; 37 private static final String TODO = "//TODO implement "; 39 public void getInterfaceMethodFromImpl(MethodType methodType) { 40 methodType.accept(this); 41 } 42 43 public MethodModel getImplMethod() { 44 return implMethod; 45 } 46 47 public MethodModel getSecondaryMethod() { 48 return null; 49 } 50 51 public void visit(BusinessMethodType bmt) { 52 implMethod = bmt.getMethodElement(); 53 String body = TODO + implMethod.getName() + EntityGenerateFromIntfVisitor.getReturnStatement(implMethod.getReturnType()); 54 implMethod = MethodModel.create( 55 implMethod.getName(), 56 implMethod.getReturnType(), 57 body, 58 implMethod.getParameters(), 59 implMethod.getExceptions(), 60 Collections.singleton(Modifier.PUBLIC) 61 ); 62 } 63 64 public void visit(CreateMethodType cmt) { 65 implMethod = cmt.getMethodElement(); 66 String origName = implMethod.getName(); 67 String newName = prependAndUpper(origName, "ejb"); String body = TODO + newName; 69 implMethod = MethodModel.create( 70 newName, 71 "void", 72 body, 73 implMethod.getParameters(), 74 implMethod.getExceptions(), 75 Collections.singleton(Modifier.PUBLIC) 76 ); 77 } 78 79 public void visit(HomeMethodType hmt) { 80 assert false: "session beans do not have home methods"; 81 } 82 83 public void visit(FinderMethodType fmt) { 84 assert false: "session beans do not have finder methods"; 85 } 86 87 private String prependAndUpper(String fullName, String prefix) { 88 StringBuffer buffer = new StringBuffer (fullName); 89 buffer.setCharAt(0, Character.toUpperCase(buffer.charAt(0))); 90 return prefix+buffer.toString(); 91 } 92 } 93 | Popular Tags |