use of com.webcohesion.enunciate.util.freemarker.ClientPackageForMethod in project enunciate by stoicflame.
the class CSharpXMLClientModule method generateSources.
private File generateSources(Map<String, String> packageToNamespaceConversions) {
File srcDir = getSourceDir();
srcDir.mkdirs();
Map<String, Object> model = new HashMap<String, Object>();
ClientPackageForMethod namespaceFor = new ClientPackageForMethod(packageToNamespaceConversions, this.context);
Collection<WsdlInfo> wsdls = new ArrayList<WsdlInfo>();
if (this.jaxwsModule != null) {
wsdls = this.jaxwsModule.getJaxwsContext().getWsdls().values();
}
model.put("wsdls", wsdls);
EnunciateJaxbContext jaxbContext = this.jaxbModule.getJaxbContext();
model.put("schemas", jaxbContext.getSchemas().values());
model.put("baseUri", this.enunciate.getConfiguration().getApplicationRoot());
model.put("generatedCodeLicense", this.enunciate.getConfiguration().readGeneratedCodeLicenseFile());
model.put("namespaceFor", namespaceFor);
model.put("findRootElement", new FindRootElementMethod(jaxbContext));
model.put("requestDocumentQName", new RequestDocumentQNameMethod());
model.put("responseDocumentQName", new ResponseDocumentQNameMethod());
ClientClassnameForMethod classnameFor = new ClientClassnameForMethod(packageToNamespaceConversions, jaxbContext);
model.put("classnameFor", classnameFor);
model.put("listsAsArraysClassnameFor", new ListsAsArraysClientClassnameForMethod(packageToNamespaceConversions, jaxbContext));
model.put("simpleNameFor", new SimpleNameFor(classnameFor));
model.put("csFileName", getSourceFileName());
model.put("accessorOverridesAnother", new AccessorOverridesAnotherMethod());
model.put("file", new FileDirective(srcDir, this.enunciate.getLogger()));
Set<String> facetIncludes = new TreeSet<String>(this.enunciate.getConfiguration().getFacetIncludes());
facetIncludes.addAll(getFacetIncludes());
Set<String> facetExcludes = new TreeSet<String>(this.enunciate.getConfiguration().getFacetExcludes());
facetExcludes.addAll(getFacetExcludes());
FacetFilter facetFilter = new FacetFilter(facetIncludes, facetExcludes);
model.put("isFacetExcluded", new IsFacetExcludedMethod(facetFilter));
if (!isUpToDateWithSources(srcDir)) {
debug("Generating the C# client classes...");
URL apiTemplate = isSingleFilePerClass() ? getTemplateURL("api-multiple-files.fmt") : getTemplateURL("api.fmt");
try {
processTemplate(apiTemplate, model);
} catch (IOException e) {
throw new EnunciateException(e);
} catch (TemplateException e) {
throw new EnunciateException(e);
}
} else {
info("Skipping C# code generation because everything appears up-to-date.");
}
this.context.setProperty(LIRBARY_DESCRIPTION_PROPERTY, readLibraryDescription(model));
return srcDir;
}
use of com.webcohesion.enunciate.util.freemarker.ClientPackageForMethod in project enunciate by stoicflame.
the class GWTJSONOverlayModule method generateClientSources.
protected File generateClientSources() {
File sourceDir = getSourceDir();
sourceDir.mkdirs();
Map<String, Object> model = new HashMap<String, Object>();
Map<String, String> conversions = getClientPackageConversions();
EnunciateJacksonContext jacksonContext = this.jacksonModule != null ? this.jacksonModule.getJacksonContext() : null;
EnunciateJackson1Context jackson1Context = this.jackson1Module != null ? this.jackson1Module.getJacksonContext() : null;
MergedJsonContext jsonContext = new MergedJsonContext(jacksonContext, jackson1Context);
ClientClassnameForMethod classnameFor = new ClientClassnameForMethod(conversions, jsonContext);
model.put("packageFor", new ClientPackageForMethod(conversions, this.context));
model.put("classnameFor", classnameFor);
model.put("simpleNameFor", new SimpleNameForMethod(classnameFor, jsonContext));
model.put("isAccessorOfTypeLong", new IsAccessorOfTypeLongMethod());
model.put("file", new FileDirective(sourceDir, this.enunciate.getLogger()));
model.put("generatedCodeLicense", this.enunciate.getConfiguration().readGeneratedCodeLicenseFile());
Set<String> facetIncludes = new TreeSet<String>(this.enunciate.getConfiguration().getFacetIncludes());
facetIncludes.addAll(getFacetIncludes());
Set<String> facetExcludes = new TreeSet<String>(this.enunciate.getConfiguration().getFacetExcludes());
facetExcludes.addAll(getFacetExcludes());
FacetFilter facetFilter = new FacetFilter(facetIncludes, facetExcludes);
model.put("isFacetExcluded", new IsFacetExcludedMethod(facetFilter));
AntPatternMatcher matcher = new AntPatternMatcher();
matcher.setPathSeparator(".");
boolean upToDate = isUpToDateWithSources(sourceDir);
if (!upToDate) {
try {
debug("Generating the GWT JSON Overlay...");
if (jacksonContext != null) {
for (TypeDefinition typeDefinition : jacksonContext.getTypeDefinitions()) {
if (!typeDefinition.isSimple() && facetFilter.accept(typeDefinition)) {
model.put("type", typeDefinition);
URL template = typeDefinition.isEnum() ? getTemplateURL("gwt-enum-type.fmt") : getTemplateURL("gwt-type.fmt");
processTemplate(template, model);
}
}
}
if (jackson1Context != null) {
for (com.webcohesion.enunciate.modules.jackson1.model.TypeDefinition typeDefinition : jackson1Context.getTypeDefinitions()) {
if (!typeDefinition.isSimple() && facetFilter.accept(typeDefinition)) {
model.put("type", typeDefinition);
URL template = typeDefinition.isEnum() ? getTemplateURL("gwt-enum-type.fmt") : getTemplateURL("gwt-type.fmt");
processTemplate(template, model);
}
}
}
} catch (IOException e) {
throw new EnunciateException(e);
} catch (TemplateException e) {
throw new EnunciateException(e);
}
} else {
info("Skipping generation of GWT JSON Overlay as everything appears up-to-date...");
}
context.setProperty(LIRBARY_DESCRIPTION_PROPERTY, readLibraryDescription(model));
return sourceDir;
}
Aggregations