freemarker.template.Version Java Examples

The following examples show how to use freemarker.template.Version. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SchemaMaker.java    From raml-module-builder with Apache License 2.0 6 votes vote down vote up
/**
 * @param onTable
 */
public SchemaMaker(String tenant, String module, TenantOperation mode, String previousVersion, String newVersion){
  if(SchemaMaker.cfg == null){
    //do this ONLY ONCE
    SchemaMaker.cfg = new Configuration(new Version(2, 3, 26));
    // Where do we load the templates from:
    cfg.setClassForTemplateLoading(SchemaMaker.class, "/templates/db_scripts");
    cfg.setDefaultEncoding("UTF-8");
    cfg.setLocale(Locale.US);
    cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
  }
  this.tenant = tenant;
  this.module = module;
  this.mode = mode;
  this.previousVersion = previousVersion;
  this.newVersion = newVersion;
  this.rmbVersion = PomReader.INSTANCE.getRmbVersion();
}
 
Example #2
Source File: DTOGenerator.java    From fast-family-master with Apache License 2.0 6 votes vote down vote up
private static void genDTO(Map<String, Object> paramMap,
                           String reousrcePath,
                           GeneratorConfig generatorConfig) {


    Version version = new Version("2.3.27");
    Configuration configuration = new Configuration(version);
    try {
        URL url = ControllerGenerator.class.getClassLoader().getResource(reousrcePath);
        configuration.setDirectoryForTemplateLoading(new File(url.getPath()));
        configuration.setObjectWrapper(new DefaultObjectWrapper(version));
        String filePath = generatorConfig.getSrcBasePath() + "dto//";
        String savePath = filePath + paramMap.get("className") + "DTO.java";
        File dirPath = new File(filePath);
        if (!dirPath.exists()) {
            dirPath.mkdirs();
        }
        try (FileWriter fileWriter = new FileWriter(new File(savePath))) {
            Template template = configuration.getTemplate("dto.ftl");
            template.process(paramMap, fileWriter);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #3
Source File: EmailTemplate.java    From hawkular-alerts with Apache License 2.0 6 votes vote down vote up
public EmailTemplate() {
    ftlCfg = new Configuration(new Version(FREEMARKER_VERSION));
    try {
        // Check if templates are located from disk or if we are loading default ones.
        String templatesDir = System.getenv(EmailPlugin.HAWKULAR_ALERTS_TEMPLATES);
        templatesDir = templatesDir == null ? System.getProperty(EmailPlugin.HAWKULAR_ALERTS_TEMPLATES_PROPERY)
                : templatesDir;
        boolean templatesFromDir = false;
        if (templatesDir != null) {
            File fileDir = new File(templatesDir);
            if (fileDir.exists()) {
                ftlCfg.setDirectoryForTemplateLoading(fileDir);
                templatesFromDir = true;
            }
        }
        if (!templatesFromDir) {
            ftlCfg.setClassForTemplateLoading(this.getClass(), "/");
        }
        ftlTemplatePlain = ftlCfg.getTemplate(DEFAULT_TEMPLATE_PLAIN, DEFAULT_LOCALE);
        ftlTemplateHtml = ftlCfg.getTemplate(DEFAULT_TEMPLATE_HTML, DEFAULT_LOCALE);
    } catch (IOException e) {
        log.debug(e.getMessage(), e);
        throw new RuntimeException("Cannot initialize templates on email plugin: " + e.getMessage());
    }
}
 
Example #4
Source File: MapperGenerator.java    From fast-family-master with Apache License 2.0 6 votes vote down vote up
private static void genMapperXml(Map<String, Object> params, String className, String resourcePath,
                                 GeneratorConfig generatorConfig) {

    Version version = new Version("2.3.27");
    Configuration configuration = new Configuration(version);
    try {
        URL url = MapperGenerator.class.getClassLoader().getResource(resourcePath);
        configuration.setDirectoryForTemplateLoading(new File(url.getPath()));
        configuration.setObjectWrapper(new DefaultObjectWrapper(version));
        String filePath = generatorConfig.getSrcBasePath() + "mapper//";
        String savePath = filePath + className + "Mapper.xml";
        File dirPath = new File(filePath);
        if (!dirPath.exists()) {
            dirPath.mkdirs();
        }
        try (FileWriter out = new FileWriter(new File(savePath))) {
            Template template = configuration.getTemplate("mapper_xml.ftl");
            template.process(params, out);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

}
 
Example #5
Source File: FreemarkerTemplateUtils.java    From collect-earth with MIT License 6 votes vote down vote up
public static boolean applyTemplate(File sourceTemplate, File destinationFile, Map<?, ?> data) throws IOException, TemplateException{
	boolean success = false;

	// Console output
	try ( BufferedWriter fw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(destinationFile), Charset.forName("UTF-8"))) ) {

		// Process the template file using the data in the "data" Map
		final Configuration cfg = new Configuration( new Version("2.3.23"));
		cfg.setDirectoryForTemplateLoading(sourceTemplate.getParentFile());

		// Load template from source folder
		final Template template = cfg.getTemplate(sourceTemplate.getName());

		template.process(data, fw);
		success = true;
	}catch (Exception e) {
		logger.error("Error reading FreeMarker template", e);
	} 
	return success;

}
 
Example #6
Source File: LocalFeedTaskProcessor.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected Configuration getFreemarkerConfiguration(RepoCtx ctx)
{
    if (useRemoteCallbacks)
    {
        // as per 3.0, 3.1
        return super.getFreemarkerConfiguration(ctx);
    } 
    else
    {
        Configuration cfg = new Configuration();
        cfg.setObjectWrapper(new DefaultObjectWrapper());

        cfg.setTemplateLoader(new ClassPathRepoTemplateLoader(nodeService, contentService, defaultEncoding));

        // TODO review i18n
        cfg.setLocalizedLookup(false);
        cfg.setIncompatibleImprovements(new Version(2, 3, 20));
        cfg.setNewBuiltinClassResolver(TemplateClassResolver.SAFER_RESOLVER);

        return cfg;
    }
}
 
Example #7
Source File: SpringController.java    From tutorials with MIT License 5 votes vote down vote up
@RequestMapping(value = "/commons", method = RequestMethod.GET)
public String showCommonsPage(Model model) {
    model.addAttribute("statuses", Arrays.asList("200 OK", "404 Not Found", "500 Internal Server Error"));
    model.addAttribute("lastChar", new LastCharMethod());
    model.addAttribute("random", new Random());
    model.addAttribute("statics", new DefaultObjectWrapperBuilder(new Version("2.3.28")).build().getStaticModels());
    return "commons";
}
 
Example #8
Source File: FacetManager.java    From raml-module-builder with Apache License 2.0 5 votes vote down vote up
/**
 * indicate the table name to query + facet on
 * @param onTable
 */
public FacetManager(String onTable){
  this.table = onTable;
  if(FacetManager.cfg == null){
    //do this ONLY ONCE
    FacetManager.cfg = new Configuration(new Version(2, 3, 26));
    // Where do we load the templates from:
    cfg.setClassForTemplateLoading(FacetManager.class, "/templates/facets");
    cfg.setDefaultEncoding("UTF-8");
    cfg.setLocale(Locale.US);
    cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
  }
}
 
Example #9
Source File: EntityGenerator.java    From fast-family-master with Apache License 2.0 5 votes vote down vote up
public static void generatorSingleEntity(String tableName, String className,
                                         String classComment, GeneratorConfig generatorConfig) {
    TableInfo tableInfo = AnalysisDB.getTableInfoByName(tableName, generatorConfig);
    Map<String, Object> paramMap = new HashMap<>();

    paramMap.put("className", className);
    paramMap.put("tableInfo", tableInfo);
    paramMap.put("sysTime", new Date());
    paramMap.put("classComment", classComment);
    paramMap.put("packageName", generatorConfig.getPackageName());


    Version version = new Version("2.3.27");
    Configuration configuration = new Configuration(version);
    try {
        configuration.setObjectWrapper(new DefaultObjectWrapper(version));
        configuration.setDirectoryForTemplateLoading(new File(EntityGenerator.class.getClassLoader()
                .getResource("ftl").getPath()));
        String savePath = PackageDirUtils.getPackageEntityDir(generatorConfig.getSrcBasePath());
        String filePath = generatorConfig.getSrcBasePath() + "entity//";
        savePath = filePath + className + ".java";
        File dirPath = new File(filePath);
        if (!dirPath.exists()) {
            dirPath.mkdirs();
        }
        try (FileWriter fileWriter = new FileWriter(savePath)) {
            Template temporal = configuration.getTemplate("entity.ftl");
            temporal.process(paramMap, fileWriter);
        }
        System.out.println("************" + savePath + "************");
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #10
Source File: ServiceGenerator.java    From fast-family-master with Apache License 2.0 5 votes vote down vote up
private static void genServiceImpl(String className,
                                   String classComment,
                                   String resourcePath,
                                   GeneratorConfig generatorConfig) {
    Map<String, Object> paramMap = new HashMap<>();

    paramMap.put("className", className);
    paramMap.put("classComment", classComment);
    paramMap.put("sysTime", new Date());
    paramMap.put("packageName", generatorConfig.getPackageName());

    Version version = new Version("2.3.27");
    Configuration configuration = new Configuration(version);
    try {
        URL url = ServiceGenerator.class.getClassLoader().getResource(resourcePath);
        configuration.setDirectoryForTemplateLoading(new File(url.getPath()));
        configuration.setObjectWrapper(new DefaultObjectWrapper(version));
        String filePath = generatorConfig.getSrcBasePath() + "service//impl//";
        String savePath = filePath + className + "ServiceImpl.java";
        File dirPath = new File(filePath);
        if (!dirPath.exists()) {
            dirPath.mkdirs();
        }
        try (FileWriter fileWriter = new FileWriter(new File(savePath))) {
            Template template = configuration.getTemplate("service_impl.ftl");
            template.process(paramMap, fileWriter);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #11
Source File: ServiceGenerator.java    From fast-family-master with Apache License 2.0 5 votes vote down vote up
private static void genServiceInterface(String className,
                                        String classComment,
                                        String resourcePath,
                                        GeneratorConfig generatorConfig) {
    Map<String, Object> paramMap = new HashMap<>();
    paramMap.put("className", className);
    paramMap.put("classComment", classComment);
    paramMap.put("sysTime", new Date());
    paramMap.put("packageName", generatorConfig.getPackageName());

    Version version = new Version("2.3.27");
    Configuration configuration = new Configuration(version);
    try {
        URL url = ServiceGenerator.class.getClassLoader().getResource(resourcePath);
        configuration.setDirectoryForTemplateLoading(new File(url.getPath()));
        configuration.setObjectWrapper(new DefaultObjectWrapper(version));
        String filePath = generatorConfig.getSrcBasePath() + "service//";
        String savePath = filePath + className + "Service.java";
        File dirPath = new File(filePath);
        if (!dirPath.exists()) {
            dirPath.mkdirs();
        }
        try (FileWriter fileWriter = new FileWriter(new File(savePath))) {
            Template template = configuration.getTemplate("service.ftl");
            template.process(paramMap, fileWriter);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #12
Source File: MapperGenerator.java    From fast-family-master with Apache License 2.0 5 votes vote down vote up
private static void genMapper(String className,
                              String classComment,
                              String resourcePath,
                              GeneratorConfig generatorConfig) {
    Map<String, Object> paramMap = new HashMap<>();
    paramMap.put("className", className);
    paramMap.put("classComment", classComment);
    paramMap.put("sysTime", new Date());
    paramMap.put("packageName", generatorConfig.getPackageName());
    ;

    Version version = new Version("2.3.27");
    Configuration configuration = new Configuration(version);
    try {
        URL url = MapperGenerator.class.getClassLoader().getResource(resourcePath);
        configuration.setDirectoryForTemplateLoading(new File(url.getPath()));
        configuration.setObjectWrapper(new DefaultObjectWrapper(version));
        String filePath = generatorConfig.getSrcBasePath() + "mapper//";
        String savePath = filePath + className + "Mapper.java";
        File dirPath = new File(filePath);
        if (!dirPath.exists()) {
            dirPath.mkdirs();
        }
        try (FileWriter out = new FileWriter(new File(savePath))) {
            Template template = configuration.getTemplate("mapper.ftl");
            template.process(paramMap, out);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #13
Source File: DashboardMain.java    From cloud-opensource-java with Apache License 2.0 5 votes vote down vote up
@VisibleForTesting
static Configuration configureFreemarker() {
  Configuration configuration = new Configuration(new Version("2.3.28"));
  configuration.setDefaultEncoding("UTF-8");
  configuration.setClassForTemplateLoading(DashboardMain.class, "/");
  return configuration;
}
 
Example #14
Source File: ControllerGenerator.java    From fast-family-master with Apache License 2.0 5 votes vote down vote up
private static void genController(String className,
                                  String classComment,
                                  String urlStr,
                                  String resourcePath,
                                  GeneratorConfig generatorConfig) {
    Map<String, Object> paramMap = new HashMap<>();
    paramMap.put("className", className);
    paramMap.put("classComment", classComment);
    paramMap.put("sysTime", new Date());
    paramMap.put("packageName", generatorConfig.getPackageName());
    paramMap.put("url", urlStr);
    Version version = new Version("2.3.27");
    Configuration configuration = new Configuration(version);
    try {
        URL url = ControllerGenerator.class.getClassLoader().getResource(resourcePath);
        configuration.setDirectoryForTemplateLoading(new File(url.getPath()));
        configuration.setObjectWrapper(new DefaultObjectWrapper(version));
        String filePath = generatorConfig.getSrcBasePath() + "controller//";
        String savePath = filePath + className + "Controller.java";
        File dirPath = new File(filePath);
        if (!dirPath.exists()) {
            dirPath.mkdirs();
        }
        try (FileWriter fileWriter = new FileWriter(new File(savePath))) {
            Template template = configuration.getTemplate("/controller.ftl");
            template.process(paramMap, fileWriter);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #15
Source File: FreeMarkerProcessor.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * FreeMarker configuration for loading the specified template directly from a String
 * 
 * @param path      Pseudo Path to the template
 * @param template  Template content
 * 
 * @return FreeMarker configuration
 */
protected Configuration getStringConfig(String path, String template)
{
    Configuration config = new Configuration();
    
    // setup template cache
    config.setCacheStorage(new MruCacheStorage(2, 0));
    
    // use our custom loader to load a template directly from a String
    StringTemplateLoader stringTemplateLoader = new StringTemplateLoader();
    stringTemplateLoader.putTemplate(path, template);
    config.setTemplateLoader(stringTemplateLoader);
    
    // use our custom object wrapper that can deal with QNameMap objects directly
    config.setObjectWrapper(qnameObjectWrapper);
    
    // rethrow any exception so we can deal with them
    config.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
    
    // set default template encoding
    if (defaultEncoding != null)
    {
        config.setDefaultEncoding(defaultEncoding);
    }
    config.setIncompatibleImprovements(new Version(2, 3, 20));
    config.setNewBuiltinClassResolver(TemplateClassResolver.SAFER_RESOLVER);
    
    return config;
}
 
Example #16
Source File: FreeMarkerService.java    From freemarker-online-tester with Apache License 2.0 5 votes vote down vote up
private FreeMarkerService(Builder bulder) {
     maxOutputLength = bulder.getMaxOutputLength();
     maxThreads = bulder.getMaxThreads();
     maxQueueLength = bulder.getMaxQueueLength();
     maxTemplateExecutionTime = bulder.getMaxTemplateExecutionTime();

     int actualMaxQueueLength = maxQueueLength != null
             ? maxQueueLength
             : Math.max(
                     MIN_DEFAULT_MAX_QUEUE_LENGTH,
                     (int) (MAX_DEFAULT_MAX_QUEUE_LENGTH_MILLISECONDS / maxTemplateExecutionTime));
     ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
             maxThreads, maxThreads,
             THREAD_KEEP_ALIVE_TIME, TimeUnit.MILLISECONDS,
             new BlockingArrayQueue<Runnable>(actualMaxQueueLength));
     threadPoolExecutor.allowCoreThreadTimeOut(true);
     templateExecutor = threadPoolExecutor;

     // Avoid ERROR log for using the actual current version. This application is special in that regard.
     Version latestVersion = new Version(Configuration.getVersion().toString());

     freeMarkerConfig = new Configuration(latestVersion);
     freeMarkerConfig.setNewBuiltinClassResolver(TemplateClassResolver.ALLOWS_NOTHING_RESOLVER);
     freeMarkerConfig.setObjectWrapper(new SimpleObjectWrapperWithXmlSupport(latestVersion));
     freeMarkerConfig.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
     freeMarkerConfig.setLogTemplateExceptions(false);
     freeMarkerConfig.setAttemptExceptionReporter(new AttemptExceptionReporter() {
@Override
public void report(TemplateException te, Environment env) {
	// Suppress it
}
     });
     freeMarkerConfig.setLocale(AllowedSettingValues.DEFAULT_LOCALE);
     freeMarkerConfig.setTimeZone(AllowedSettingValues.DEFAULT_TIME_ZONE);
     freeMarkerConfig.setOutputFormat(AllowedSettingValues.DEFAULT_OUTPUT_FORMAT);
     freeMarkerConfig.setOutputEncoding("UTF-8");
 }
 
Example #17
Source File: FeedTaskProcessor.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected Configuration getFreemarkerConfiguration(RepoCtx ctx)
{
    Configuration cfg = new Configuration();
    cfg.setObjectWrapper(new DefaultObjectWrapper());

    // custom template loader
    cfg.setTemplateLoader(new TemplateWebScriptLoader(ctx.getRepoEndPoint(), ctx.getTicket()));

    // TODO review i18n
    cfg.setLocalizedLookup(false);
    cfg.setIncompatibleImprovements(new Version(2, 3, 20));
    cfg.setNewBuiltinClassResolver(TemplateClassResolver.SAFER_RESOLVER);

    return cfg;
}
 
Example #18
Source File: FreeMarkerUtil.java    From game-server with MIT License 5 votes vote down vote up
public static Template getTemplate(Class<?> clazz,String name,String ftlPath) {
	try {
		// 通过Freemaker的Configuration读取相应的ftl
		Configuration cfg = new Configuration(new Version(2, 3, 23));
		// 设定去哪里读取相应的ftl模板文件
		cfg.setClassForTemplateLoading(FreeMarkerUtil.class, ftlPath);
		// 在模板文件目录中找到名称为name的文件
		Template temp = cfg.getTemplate(name);
		return temp;
	} catch (IOException e) {
		e.printStackTrace();
	}
	return null;
}
 
Example #19
Source File: ScipioFtlWrappers.java    From scipio-erp with Apache License 2.0 5 votes vote down vote up
public static ScipioBasicBeansWrapperImpl create(Version incompatibleImprovements, Boolean simpleMapWrapper) {
    ScipioBasicBeansWrapperImpl wrapper = new ScipioBasicBeansWrapperImpl(incompatibleImprovements, systemWrapperFactories);
    if (simpleMapWrapper != null) {
        wrapper.setSimpleMapWrapper(simpleMapWrapper);
    }
    return wrapper;
}
 
Example #20
Source File: StaticPageUtil.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
public static String renderHTMLContent(Component... components) throws Exception {

        ObjectMapper mapper = new ObjectMapper();
        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
        mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
        mapper.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true);
        mapper.enable(SerializationFeature.INDENT_OUTPUT);

        Configuration cfg = new Configuration(new Version(2, 3, 23));

        // Where do we load the templates from:
        cfg.setClassForTemplateLoading(StaticPageUtil.class, "");

        // Some other recommended settings:
        cfg.setIncompatibleImprovements(new Version(2, 3, 23));
        cfg.setDefaultEncoding("UTF-8");
        cfg.setLocale(Locale.US);
        cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);

        ClassPathResource cpr = new ClassPathResource("assets/dl4j-ui.js");
        String scriptContents = IOUtils.toString(cpr.getInputStream(), "UTF-8");

        Map<String, Object> pageElements = new HashMap<>();
        List<ComponentObject> list = new ArrayList<>();
        int i = 0;
        for (Component c : components) {
            list.add(new ComponentObject(String.valueOf(i), mapper.writeValueAsString(c)));
            i++;
        }
        pageElements.put("components", list);
        pageElements.put("scriptcontent", scriptContents);


        Template template = cfg.getTemplate("staticpage.ftl");
        Writer stringWriter = new StringWriter();
        template.process(pageElements, stringWriter);

        return stringWriter.toString();
    }
 
Example #21
Source File: TrainModule.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
/**
 * TrainModule
 */
public TrainModule() {
    String maxChartPointsProp = System.getProperty(DL4JSystemProperties.CHART_MAX_POINTS_PROPERTY);
    int value = DEFAULT_MAX_CHART_POINTS;
    if (maxChartPointsProp != null) {
        try {
            value = Integer.parseInt(maxChartPointsProp);
        } catch (NumberFormatException e) {
            log.warn("Invalid system property: {} = {}", DL4JSystemProperties.CHART_MAX_POINTS_PROPERTY, maxChartPointsProp);
        }
    }
    if (value >= 10) {
        maxChartPoints = value;
    } else {
        maxChartPoints = DEFAULT_MAX_CHART_POINTS;
    }

    configuration = new Configuration(new Version(2, 3, 23));
    configuration.setDefaultEncoding("UTF-8");
    configuration.setLocale(Locale.US);
    configuration.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);

    configuration.setClassForTemplateLoading(TrainModule.class, "");
    try {
        File dir = Resources.asFile("templates/TrainingOverview.html.ftl").getParentFile();
        configuration.setDirectoryForTemplateLoading(dir);
    } catch (Throwable t) {
        throw new RuntimeException(t);
    }
}
 
Example #22
Source File: ScipioFtlWrappers.java    From scipio-erp with Apache License 2.0 5 votes vote down vote up
public static ScipioBasicDefaultObjectWrapperImpl create(Version incompatibleImprovements,
        Boolean simpleMapWrapper, Boolean useAdaptersForContainers) {
    ScipioBasicDefaultObjectWrapperImpl wrapper = new ScipioBasicDefaultObjectWrapperImpl(incompatibleImprovements, systemWrapperFactories);
    if (simpleMapWrapper != null) {
        wrapper.setSimpleMapWrapper(simpleMapWrapper);
    }
    if (useAdaptersForContainers != null) {
        wrapper.setUseAdaptersForContainers(useAdaptersForContainers);
    }
    return wrapper;
}
 
Example #23
Source File: ExportUtilities.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Returns an ObjectWrapper of sufficiently high version for pcgen
 */
public static ObjectWrapper getObjectWrapper()
{
	DefaultObjectWrapperBuilder defaultObjectWrapperBuilder = new DefaultObjectWrapperBuilder(
			new Version("2.3.28"));
	return defaultObjectWrapperBuilder.build();
}
 
Example #24
Source File: ScipioFtlWrappers.java    From scipio-erp with Apache License 2.0 5 votes vote down vote up
public static ScipioExtendedBeansWrapperImpl create(Version incompatibleImprovements, String encodeLang, Boolean simpleMapWrapper) {
    ScipioExtendedBeansWrapperImpl wrapper = new ScipioExtendedBeansWrapperImpl(incompatibleImprovements, systemWrapperFactories, encodeLang);
    if (simpleMapWrapper != null) {
        wrapper.setSimpleMapWrapper(simpleMapWrapper);
    }
    return wrapper;
}
 
Example #25
Source File: OALRuntime.java    From skywalking with Apache License 2.0 5 votes vote down vote up
public OALRuntime(OALDefine define) {
    oalDefine = define;
    classPool = ClassPool.getDefault();
    configuration = new Configuration(new Version("2.3.28"));
    configuration.setEncoding(Locale.ENGLISH, CLASS_FILE_CHARSET);
    configuration.setClassLoaderForTemplateLoading(OALRuntime.class.getClassLoader(), "/code-templates");
    allDispatcherContext = new AllDispatcherContext();
    metricsClasses = new ArrayList<>();
    dispatcherClasses = new ArrayList<>();
    openEngineDebug = StringUtil.isNotEmpty(System.getenv("SW_OAL_ENGINE_DEBUG"));
}
 
Example #26
Source File: ScipioFtlWrappers.java    From scipio-erp with Apache License 2.0 5 votes vote down vote up
public static ScipioExtendedDefaultObjectWrapperImpl create(Version incompatibleImprovements, String encodeLang,
        Boolean simpleMapWrapper, Boolean useAdaptersForContainers) {
    ScipioExtendedDefaultObjectWrapperImpl wrapper = new ScipioExtendedDefaultObjectWrapperImpl(incompatibleImprovements, systemWrapperFactories, encodeLang);
    if (simpleMapWrapper != null) {
        wrapper.setSimpleMapWrapper(simpleMapWrapper);
    }
    if (useAdaptersForContainers != null) {
        wrapper.setUseAdaptersForContainers(useAdaptersForContainers);
    }
    return wrapper;
}
 
Example #27
Source File: Templates.java    From live-chat-engine with Apache License 2.0 5 votes vote down vote up
public Templates(String dirPath) throws IOException {
	this.dirPath = dirPath;
	
	cfg = new Configuration();
	cfg.setLocalizedLookup(false);
       cfg.setDirectoryForTemplateLoading(new File(this.dirPath));
       cfg.setObjectWrapper(new DefaultObjectWrapper());
       cfg.setDefaultEncoding("UTF-8");
       cfg.setTemplateExceptionHandler(TemplateExceptionHandler.HTML_DEBUG_HANDLER);
       cfg.setIncompatibleImprovements(new Version(2, 3, 20));
}
 
Example #28
Source File: ExportUtilities.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Returns an ObjectWrapper of sufficiently high version for pcgen
 */
public static ObjectWrapper getObjectWrapper()
{
	DefaultObjectWrapperBuilder defaultObjectWrapperBuilder = new DefaultObjectWrapperBuilder(
			new Version("2.3.28"));
	return defaultObjectWrapperBuilder.build();
}
 
Example #29
Source File: AbstractHalProcessor.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public AbstractHalProcessor() {

        Version version = new Version(2, 3, 22);
        config = new Configuration(version);
        config.setDefaultEncoding("UTF-8");
        config.setClassForTemplateLoading(getClass(), "templates");
        config.setObjectWrapper(new DefaultObjectWrapperBuilder(version).build());
    }
 
Example #30
Source File: ExtendedWrapper.java    From scipio-erp with Apache License 2.0 4 votes vote down vote up
private ExtendedWrapper(Version version, String lang) {
    super(version);
    this.lang = lang;
    this.encoder = UtilCodec.getEncoder(lang);
}