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 SessionGenerateFromImplVisitor implements MethodType.MethodTypeVisitor, AbstractMethodController.GenerateFromImpl { 35 36 private MethodModel intfMethod; 37 private String destination; 38 private String home; 39 private String component; 40 41 public void getInterfaceMethodFromImpl(MethodType methodType, String home, String component) { 42 this.home = home; 43 this.component = component; 44 methodType.accept(this); 45 } 46 47 public MethodModel getInterfaceMethod() { 48 return intfMethod; 49 } 50 51 public String getDestinationInterface() { 52 return destination; 53 } 54 55 public void visit(BusinessMethodType bmt) { 56 intfMethod = bmt.getMethodElement(); 57 destination = component; 58 } 59 60 public void visit(CreateMethodType cmt) { 61 intfMethod = cmt.getMethodElement(); 62 String origName = intfMethod.getName(); 63 String newName = chopAndUpper(origName,"ejb"); intfMethod = MethodModel.create( 65 newName, 66 home, 67 intfMethod.getBody(), 68 intfMethod.getParameters(), 69 intfMethod.getExceptions(), 70 Collections.singleton(Modifier.PUBLIC) 71 ); 72 destination = home; 73 } 74 75 public void visit(HomeMethodType hmt) { 76 assert false: "session beans do not have home methods"; 77 } 78 79 public void visit(FinderMethodType fmt) { 80 assert false: "session beans do not have finder methods"; 81 } 82 83 private String chopAndUpper(String fullName, String chop) { 84 StringBuffer buffer = new StringBuffer (fullName); 85 buffer.delete(0, chop.length()); 86 buffer.setCharAt(0, Character.toLowerCase(buffer.charAt(0))); 87 return buffer.toString(); 88 } 89 90 } 91 | Popular Tags |