@Override public void initModel(EnunciateFreemarkerModel model) { super.initModel(model); if (!isDisabled()) { if (!amfRtFound) { warn("WARNING! The AMF module is enabled, but the Enunciate AMF runtime libraries were found on the Enunciate classpath. " + "Application startup will fail unless the Enunciate AMF runtime libraries are on the classpath."); } } }
@Override public void init(Enunciate enunciate) throws EnunciateException { super.init(enunciate); if (!enunciate.isModuleEnabled("jaxws")) { throw new EnunciateException("The XFire module requires an enabled JAXWS module."); } }
/** * Processes the specified template with the given model. * * @param templateURL The template URL. * @param model The root model. * @param out The output stream to process to. */ public void processTemplate(URL templateURL, Object model, PrintStream out) throws IOException, TemplateException { debug("Processing template %s.", templateURL); Configuration configuration = getConfiguration(); configuration.setDefaultEncoding("UTF-8"); Template template = configuration.getTemplate(templateURL.toString()); processTemplate(template, model, out); }
/** * Gets the model for processing. * * @return The model for processing. */ public EnunciateFreemarkerModel getModel() { EnunciateFreemarkerModel model = getModelInternal(); if (model == null) { throw new IllegalStateException("A model must be established."); } model.setObjectWrapper(getObjectWrapper()); model.setFileOutputDirectory(getGenerateDir()); return model; }
/** * Gets the model for processing. * * @return The model for processing. */ public EnunciateFreemarkerModel getModel() throws IOException { EnunciateFreemarkerModel model = (EnunciateFreemarkerModel) FreemarkerModel.get(); if (model == null) { throw new IOException("A model must be established."); } model.setObjectWrapper(getObjectWrapper()); model.setFileOutputDirectory(getGenerateDir()); return model; }
@Override public boolean isDisabled() { if (super.isDisabled()) { return true; } else if (getModelInternal() != null && getModelInternal().getRESTEndpoints().isEmpty()) { debug("REST module is disabled because there are no REST endpoints."); return true; } return false; }
@Override public void init(Enunciate enunciate) throws EnunciateException { super.init(enunciate); if (!super.isDisabled()) { //if we're explicitly disabled, we can ignore this... if (isDisableCompile()) { info("C# compilation is disabled, but the source code will still be generated.");
/** * Processes the template. Declared final because we don't ever want to do more than process * the template so it can be safe to call the processTemplate() method directly (e.g. in the * {@link org.codehaus.enunciate.apt.EnunciateAnnotationProcessor}). */ @Override protected final void doGenerate() throws EnunciateException, IOException { try { doFreemarkerGenerate(); } catch (TemplateException e) { throw new EnunciateException(e); } }
@Override public boolean isDisabled() { if (super.isDisabled()) { return true; } else if (getModelInternal() != null && getModelInternal().getNamespacesToWSDLs().isEmpty() && getModelInternal().getNamespacesToSchemas().isEmpty()) { debug("Java client module is disabled because there are no endpoint interfaces, nor any root schema types."); return true; } return false; }
/** * Processes the template. Declared final because we don't ever want to do more than process * the template so it can be safe to call the processTemplate() method directly (e.g. in the * {@link org.codehaus.enunciate.apt.EnunciateAnnotationProcessor}). */ @Override protected final void doGenerate() throws EnunciateException, IOException { try { doFreemarkerGenerate(); } catch (TemplateException e) { throw new EnunciateException(e); } }
@Override public boolean isDisabled() { if (super.isDisabled()) { return true; } else if (getModelInternal() != null && getModelInternal().getNamespacesToWSDLs().isEmpty() && getModelInternal().getRootResources().isEmpty()) { debug("JAX-WS module is disabled because there are no endpoint interfaces."); return true; } return false; } }
@Override public void initModel(EnunciateFreemarkerModel model) { super.initModel(model); if (!isDisabled()) { if (!gwtRtFound && !isGenerateJsonOverlays()) { info("GWT runtime wasn't found on the classpath. If you're doing GWT-RPC, you're going to fail at runtime."); } } }
@Override public void init(Enunciate enunciate) throws EnunciateException { super.init(enunciate); //some application components might want to reference their documentation, so we'll put a reference to the configured docs dir. enunciate.setProperty("docs.webapp.dir", getDocsDir()); if (getJavadocTagHandling() == null) { JavaDocTagHandlerFactory.setTagHandler(new DocumentationJavaDocTagHandler()); } else if (!"OFF".equalsIgnoreCase(getJavadocTagHandling())) { try { JavaDocTagHandlerFactory.setTagHandler((JavaDocTagHandler) Class.forName(getJavadocTagHandling()).newInstance()); } catch (Throwable e) { throw new EnunciateException(e); } } }
/** * Processes the specified template with the given model. * * @param templateURL The template URL. * @param model The root model. * @param out The output stream to process to. */ public void processTemplate(URL templateURL, Object model, PrintStream out) throws IOException, TemplateException { debug("Processing template %s.", templateURL); Configuration configuration = getConfiguration(); configuration.setDefaultEncoding("UTF-8"); Template template = configuration.getTemplate(templateURL.toString()); processTemplate(template, model, out); }
@Override public boolean isDisabled() { if (super.isDisabled()) { return true; } else if (getModelInternal() != null && getModelInternal().getNamespacesToWSDLs().isEmpty() && getModelInternal().getNamespacesToSchemas().isEmpty()) { debug("C# module is disabled because there are no endpoint interfaces, nor any XML types."); return true; } return false; } }
@Override public void initModel(EnunciateFreemarkerModel model) { super.initModel(model); warn("The Enunciate REST module has been deprecated in favor of JAX-RS, and will soon be removed from the core Enunciate build. It would be wise for you to move to the JAX-RS model."); if (!isDisabled()) { Map<RESTNoun, Set<String>> nouns2contentTypes = model.getNounsToContentTypes(); Map<String, String> contentTypes2Ids = model.getContentTypesToIds(); contentTypes2Ids.put("application/json", "json"); //it's assumed we've got some json provider on the classpath... for (Map.Entry<RESTNoun, List<RESTMethod>> nounMethodEntry : model.getNounsToRESTMethods().entrySet()) { Map<String, Set<String>> subcontexts = new HashMap<String, Set<String>>(); RESTNoun restNoun = nounMethodEntry.getKey(); subcontexts.put(null, new TreeSet<String>(Arrays.asList(getRestSubcontext()))); for (String contentType : nouns2contentTypes.get(restNoun)) { String contentTypeId = contentTypes2Ids.get(contentType); if (contentTypeId != null) { subcontexts.put(contentType, new TreeSet<String>(Arrays.asList("/" + contentTypeId))); } } for (RESTMethod restMethod : nounMethodEntry.getValue()) { restMethod.putMetaData("defaultSubcontext", getRestSubcontext()); restMethod.putMetaData("subcontexts", subcontexts); } } } }
@Override public void init(Enunciate enunciate) throws EnunciateException { super.init(enunciate); if (rpcModuleName == null) { throw new EnunciateException("You must specify a \"gwtModuleName\" for the GWT module."); } if (rpcModuleNamespace == null) { throw new EnunciateException("You must specify a \"gwtModuleName\" for the GWT module."); } if (gwtApps.size() > 0) { if (this.gwtHome == null) { throw new EnunciateException("To compile a GWT app you must specify the GWT home directory, either in configuration, by setting the GWT_HOME environment variable, or setting the 'gwt.home' system property."); } for (GWTApp gwtApp : gwtApps) { String srcPath = gwtApp.getSrcDir(); if (srcPath == null) { throw new EnunciateException("A source directory for the GWT app " + ("".equals(gwtApp.getName()) ? "" : "'" + gwtApp.getName() + "' ") + "must be supplied with the 'srcDir' attribute."); } File srcDir = enunciate.resolvePath(srcPath); if (!srcDir.exists()) { throw new EnunciateException("Source directory '" + srcDir.getAbsolutePath() + "' doesn't exist for the GWT app" + ("".equals(gwtApp.getName()) ? "." : " '" + gwtApp.getName() + "'.")); } } } }
@Override public boolean isDisabled() { if (super.isDisabled()) { return true; } else if (getModelInternal() != null && getModelInternal().getNamespacesToWSDLs().isEmpty() && getModelInternal().getNamespacesToSchemas().isEmpty()) { debug("AMF module is disabled because there are no endpoint interfaces nor any schema objects."); return true; } return false; }
@Override public void initModel(EnunciateFreemarkerModel model) { super.initModel(model); if (!isDisabled()) { for (SchemaInfo schemaInfo : model.getNamespacesToSchemas().values()) { for (TypeDefinition typeDefinition : schemaInfo.getTypeDefinitions()) { String pckg = typeDefinition.getPackage().getQualifiedName(); if (!this.packageToModuleConversions.containsKey(pckg)) { this.packageToModuleConversions.put(pckg, packageToModule(pckg)); } } } } }
@Override public void init(Enunciate enunciate) throws EnunciateException { super.init(enunciate); if (!isDisabled()) { if (this.flexHome == null && (isSwcDownloadable() || !flexApps.isEmpty())) { throw new EnunciateException("To compile a flex app you must specify the Flex SDK home directory, either in configuration, by setting the FLEX_HOME environment variable, or setting the 'flex.home' system property."); } for (FlexApp flexApp : flexApps) { if (flexApp.getName() == null) { throw new EnunciateException("A flex app must have a name."); } String srcPath = flexApp.getSrcDir(); if (srcPath == null) { throw new EnunciateException("A source directory for the flex app '" + flexApp.getName() + "' must be supplied with the 'srcDir' attribute."); } File srcDir = enunciate.resolvePath(srcPath); if (!srcDir.exists()) { throw new EnunciateException("Source directory for the flex app '" + flexApp.getName() + "' doesn't exist."); } } } }