Class returnType = m.getReturnType();
public MethodFab addMethod(int modifiers, MethodSignature ms, String body) { if (_methods.get(ms) != null) throw new ApplicationRuntimeException(EnhanceMessages.duplicateMethodInClass(ms, this)); if (body.indexOf("isWrapperFor") > 0 || body.indexOf("unwrap") > 0) return new MethodFabImpl(null, ms, null, "{ throw new UnsupportedOperationException(\"Method not implemented\"); }"); CtClass ctReturnType = convertClass(ms.getReturnType()); CtClass[] ctParameters = convertClasses(ms.getParameterTypes()); CtClass[] ctExceptions = convertClasses(ms.getExceptionTypes()); CtMethod method = new CtMethod(ctReturnType, ms.getName(), ctParameters, getCtClass()); try { method.setModifiers(modifiers); method.setBody(body); method.setExceptionTypes(ctExceptions); getCtClass().addMethod(method); } catch (Exception ex) { throw new ApplicationRuntimeException(EnhanceMessages.unableToAddMethod(ms, getCtClass(), ex), ex); } // Return a MethodFab so the caller can add catches. MethodFab result = new MethodFabImpl(getSource(), ms, method, body); _methods.put(ms, result); return result; }
public MethodFab addMethod(int modifiers, MethodSignature ms, String body) { if (_methods.get(ms) != null) throw new ApplicationRuntimeException(EnhanceMessages.duplicateMethodInClass(ms, this)); if (body.indexOf("isWrapperFor") > 0 || body.indexOf("unwrap") > 0) return new MethodFabImpl(null, ms, null, "{ throw new UnsupportedOperationException(\"Method not implemented\"); }"); CtClass ctReturnType = convertClass(ms.getReturnType()); CtClass[] ctParameters = convertClasses(ms.getParameterTypes()); CtClass[] ctExceptions = convertClasses(ms.getExceptionTypes()); CtMethod method = new CtMethod(ctReturnType, ms.getName(), ctParameters, getCtClass()); try { method.setModifiers(modifiers); method.setBody(body); method.setExceptionTypes(ctExceptions); getCtClass().addMethod(method); } catch (Exception ex) { throw new ApplicationRuntimeException(EnhanceMessages.unableToAddMethod(ms, getCtClass(), ex), ex); } // Return a MethodFab so the caller can add catches. MethodFab result = new MethodFabImpl(getSource(), ms, method, body); _methods.put(ms, result); return result; }
public void addMethod(MethodSignature ms) { CtClass ctReturnType = convertClass(ms.getReturnType()); CtClass[] ctParameters = convertClasses(ms.getParameterTypes()); CtClass[] ctExceptions = convertClasses(ms.getExceptionTypes()); CtMethod method = new CtMethod(ctReturnType, ms.getName(), ctParameters, getCtClass()); try { method.setModifiers(Modifier.PUBLIC | Modifier.ABSTRACT); method.setExceptionTypes(ctExceptions); getCtClass().addMethod(method); } catch (Exception ex) { throw new ApplicationRuntimeException(ServiceMessages.unableToAddMethod( ms, getCtClass(), ex), ex); } _methods.add(ms); }
public void addMethod(MethodSignature ms) { CtClass ctReturnType = convertClass(ms.getReturnType()); CtClass[] ctParameters = convertClasses(ms.getParameterTypes()); CtClass[] ctExceptions = convertClasses(ms.getExceptionTypes()); CtMethod method = new CtMethod(ctReturnType, ms.getName(), ctParameters, getCtClass()); try { method.setModifiers(Modifier.PUBLIC | Modifier.ABSTRACT); method.setExceptionTypes(ctExceptions); getCtClass().addMethod(method); } catch (Exception ex) { throw new ApplicationRuntimeException(EnhanceMessages.unableToAddMethod( ms, getCtClass(), ex), ex); } _methods.add(ms); }
public void addMethod(MethodSignature ms) { CtClass ctReturnType = convertClass(ms.getReturnType()); CtClass[] ctParameters = convertClasses(ms.getParameterTypes()); CtClass[] ctExceptions = convertClasses(ms.getExceptionTypes()); CtMethod method = new CtMethod(ctReturnType, ms.getName(), ctParameters, getCtClass()); try { method.setModifiers(Modifier.PUBLIC | Modifier.ABSTRACT); method.setExceptionTypes(ctExceptions); getCtClass().addMethod(method); } catch (Exception ex) { throw new ApplicationRuntimeException(EnhanceMessages.unableToAddMethod( ms, getCtClass(), ex), ex); } _methods.add(ms); }
public MethodFab addMethod(int modifiers, MethodSignature ms, String body) { if (_methods.get(ms) != null) throw new ApplicationRuntimeException(ServiceMessages.duplicateMethodInClass(ms, this)); CtClass ctReturnType = convertClass(ms.getReturnType()); CtClass[] ctParameters = convertClasses(ms.getParameterTypes()); CtClass[] ctExceptions = convertClasses(ms.getExceptionTypes()); CtMethod method = new CtMethod(ctReturnType, ms.getName(), ctParameters, getCtClass()); try { method.setModifiers(modifiers); method.setBody(body); method.setExceptionTypes(ctExceptions); getCtClass().addMethod(method); } catch (Exception ex) { throw new ApplicationRuntimeException(ServiceMessages.unableToAddMethod( ms, getCtClass(), ex), ex); } // Return a MethodFab so the caller can add catches. MethodFab result = new MethodFabImpl(getSource(), ms, method, body); _methods.put(ms, result); return result; }
protected void addServiceMethodImplementation(ClassFab classFab, MethodSignature sig) Class returnType = sig.getReturnType(); String methodName = sig.getName();