protected void clearAttributes() { velocity.clearAttributes(); }
protected void doWrite(String templateName, Writer outputs) throws ToolException { if (outputs != null) { velocity.doWrite(templateName, outputs); } }
public File parseOutputName(String packageName, String filename) throws ToolException { return parseOutputName(packageName, filename, ".java"); }
public void generateAndCompile(Collection<JavaClass> wrapperClasses, File dir) { VelocityGenerator generator = new VelocityGenerator(false); generator.setBaseDir(dir.toString()); generator.setCommonAttributes(); generator.setAttributes("bean", wrapperClass); File file = generator.parseOutputName(wrapperClass.getPackageName(), wrapperClass.getName()); generatedFiles.add(file); generator.doWrite(TEMPLATE, new FileWriterUtil(file.getParent(), getOutputStreamCreator()) .getWriter(file, (String)getToolContext().get(ToolConstants.CFG_ENCODING))); generator.clearAttributes();
VelocityGenerator generator = new VelocityGenerator(false); generator.setCommonAttributes(); generator.setAttributes("parseMethod", getAdapterMethod(dateType, ".parseDateTime")); generator.setAttributes("printMethod", getAdapterMethod(dateType, ".printDateTime")); generator.setAttributes("datetype", dateType.getName()); return null; generator.setAttributes("schemaFiles", schemaFiles); } else { generator.setAttributes("wsdlName", wsdlName); List<String> ns = getSchemaNamespaces(); if (ns.isEmpty()) { return null; generator.setAttributes("targetNamespaces", ns); generator.doWrite(getTemplate(), new FileWriterUtil(xjb.getParent(), getOutputStreamCreator()) .getWriter(xjb, StandardCharsets.UTF_8.name())); } catch (Exception e) { generator.clearAttributes();
protected void setAttributes(String n, Object value) { velocity.setAttributes(n, value); }
public VelocityGenerator(boolean log) { initVelocity(log); }
private static synchronized void initVelocity(boolean log) throws ToolException { if (initialized) { return; } initialized = true; try { Properties props = new Properties(); String clzName = "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"; props.put("resource.loader", "class"); props.put("class.resource.loader.class", clzName); props.put("runtime.log", getVelocityLogFile("velocity.log")); // if (!log) { // props.put(VelocityEngine.RUNTIME_LOG_INSTANCE, // "org.apache.velocity.runtime.log.NullLogSystem"); // } Velocity.init(props); } catch (Exception e) { Message msg = new Message("FAIL_TO_INITIALIZE_VELOCITY_ENGINE", LOG); LOG.log(Level.SEVERE, msg.toString()); throw new ToolException(msg, e); } }
public void generateAndCompile(Collection<JavaClass> wrapperClasses, File dir) { VelocityGenerator generator = new VelocityGenerator(false); generator.setBaseDir(dir.toString()); generator.setCommonAttributes(); generator.setAttributes("bean", wrapperClass); File file = generator.parseOutputName(wrapperClass.getPackageName(), wrapperClass.getName()); generatedFiles.add(file); generator.doWrite(TEMPLATE, new FileWriterUtil(file.getParent(), getOutputStreamCreator()) .getWriter(file, (String)getToolContext().get(ToolConstants.CFG_ENCODING))); generator.clearAttributes();
VelocityGenerator generator = new VelocityGenerator(false); generator.setCommonAttributes(); generator.setAttributes("parseMethod", getAdapterMethod(dateType, ".parseDateTime")); generator.setAttributes("printMethod", getAdapterMethod(dateType, ".printDateTime")); generator.setAttributes("datetype", dateType.getName()); return null; generator.setAttributes("schemaFiles", schemaFiles); } else { generator.setAttributes("wsdlName", wsdlName); List<String> ns = getSchemaNamespaces(); if (ns.isEmpty()) { return null; generator.setAttributes("targetNamespaces", ns); generator.doWrite(getTemplate(), new FileWriterUtil(xjb.getParent(), getOutputStreamCreator()) .getWriter(xjb, StandardCharsets.UTF_8.name())); } catch (Exception e) { generator.clearAttributes();
protected void setAttributes(String n, Object value) { velocity.setAttributes(n, value); }
public VelocityGenerator(boolean log) { initVelocity(log); }
private static synchronized void initVelocity(boolean log) throws ToolException { if (initialized) { return; } initialized = true; try { Properties props = new Properties(); String clzName = "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"; props.put("resource.loader", "class"); props.put("class.resource.loader.class", clzName); props.put("runtime.log", getVelocityLogFile("velocity.log")); // if (!log) { // props.put(VelocityEngine.RUNTIME_LOG_INSTANCE, // "org.apache.velocity.runtime.log.NullLogSystem"); // } Velocity.init(props); } catch (Exception e) { Message msg = new Message("FAIL_TO_INITIALIZE_VELOCITY_ENGINE", LOG); LOG.log(Level.SEVERE, msg.toString()); throw new ToolException(msg, e); } }
protected void doWrite(String templateName, Writer outputs) throws ToolException { if (outputs != null) { velocity.doWrite(templateName, outputs); } }
public File parseOutputName(String packageName, String filename) throws ToolException { return parseOutputName(packageName, filename, ".java"); }
protected void clearAttributes() { velocity.clearAttributes(); }