@Override public void doFreemarkerGenerate() throws IOException, TemplateException { if (!isUpToDate()) { EnunciateFreemarkerModel model = getModel(); // generate the rpc request/response beans. for (WsdlInfo wsdlInfo : model.getNamespacesToWSDLs().values()) { for (EndpointInterface ei : wsdlInfo.getEndpointInterfaces()) { for (WebMethod webMethod : ei.getWebMethods()) { for (WebMessage webMessage : webMethod.getMessages()) { if (webMessage instanceof RPCInputMessage) { model.put("message", webMessage); processTemplate(getRPCRequestBeanTemplateURL(), model); } else if (webMessage instanceof RPCOutputMessage) { model.put("message", webMessage); processTemplate(getRPCResponseBeanTemplateURL(), model); } } } } } model.put("xfireBeansImport", getXfireBeansImport()); model.put("docsDir", enunciate.getProperty("docs.webapp.dir")); processTemplate(getXfireServletTemplateURL(), model); processTemplate(getParameterNamesTemplateURL(), model); } else { info("Skipping generation of XFire support classes as everything appears up-to-date...."); } getEnunciate() .addArtifact(new FileArtifact(getName(), "xfire-server.src.dir", getGenerateDir())); getEnunciate().addAdditionalSourceRoot(getGenerateDir()); }
private static void buildHandler(String moduleUrl, Class<?> clazz) { for (Method m : clazz.getDeclaredMethods()) { WebMethod wm = m.getAnnotation(WebMethod.class); if (wm != null) { Handler handler = new Handler(clazz, m.getName()); if (StringUtils.isNotEmpty(wm.name())) { handlers.put(moduleUrl + "/" + wm.name(), handler); } else { handlers.put(moduleUrl + "/" + m.getName(), handler); } } } }
private void initMethods() { Class clazz = getClass(); for (Method method : clazz.getMethods()) { if (!Modifier.isPublic(method.getModifiers())) continue; WebMethod ann = method.getAnnotation(WebMethod.class); if (ann == null) continue; String url = ann.value(); if (invokers.containsKey(url)) throw new WebException("Repetitive url '%s'", url); for (Class pt : method.getParameterTypes()) { if (!pt.isAssignableFrom(HttpServletRequest.class) && !pt.equals(HttpServletResponse.class) && !pt.equals(QueryParams.class)) throw new WebException("Invalid parameter type '%s'", pt.getName()); } invokers.put(url, new Invoker(this, method)); } }
protected void addReferencedTypeDefinitions( WebMethod webMethod, LinkedList<Element> contextStack) { contextStack.push(webMethod); try { WebResult result = webMethod.getWebResult(); this.jaxbModule .getJaxbContext() .addReferencedTypeDefinitions( result.isAdapted() ? result.getAdapterType() : result.getType(), contextStack); for (WebParam webParam : webMethod.getWebParameters()) { this.jaxbModule .getJaxbContext() .addReferencedTypeDefinitions( webParam.isAdapted() ? webParam.getAdapterType() : webParam.getType(), contextStack); } for (WebFault webFault : webMethod.getWebFaults()) { addReferencedTypeDefinitions(webFault, contextStack); } } finally { contextStack.pop(); } }