是否有任何Java库可以在http.conf之类的unix配置文件上运行 [英] Is there any Java Library to operate on unix config files like http.conf

查看:109
本文介绍了是否有任何Java库可以在http.conf之类的unix配置文件上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有非常好的Perl库(例如 Apache :: Admin :: Config )对httpd.conf等传统的unix配置文件进行操作。有人知道是否有好的Java库来执行类似的任务吗?

There are very good Perl libraries (e.g. Apache::Admin::Config) to operate on traditional unix config files like httpd.conf. Anyone know if there is good Java libraries to do the similar task?

我知道有一个名为 Augeas 。有没有人以前用过它?

I know there is a c library called Augeas with Java binding. Has anyone used that before?

谢谢!

推荐答案

我工作过(以编程方式,对于一个项目而言)有许多来自许多* nix项目的配置文件,如Apache,Squid,smtpd,ldap,PAM等等。我已经意识到有一种不常见的格式(语法)而是每个project定义了他自己的ad-hoc格式并实现了它自己的自定义解析器。没有通用的规范。

I worked (programatically, for a project) with a lot of config files from many *nix projects like Apache's, Squid's, smtpd's, ldap's, PAM's etc. etc. I have come to realise there is deffinetly NOT a common format (grammar) but instead each project defines his own ad-hoc format and implements it's own custom parser. No common specification.

所以* nix上的aproach项目配置文件不是使用解析器库而是编写自己的解析器。

So the aproach on *nix projects config files si not "use the parser library" but rather "write your own parser".

然而有些项目试图坚持一些有点标准。最常见的amog theese是 .ini文件格式(源自OS / 2和Windows)或 GConf文件格式,您可以随时找到可用解析器。

There are however projects that try to stick to some sort of standard. Most common amog theese is the .ini file format (originated on OS/2 and windows) or GConf file format, for theese you may find readily available parsers.

Apache(读取a-patch-e,如许多补丁中所做的)是在自由格式类中。它以 var值格式开始,然后,在经过大量修补之后,添加了一个用于指定配置变量的范围和上下文的warty-xmlish语法。

Apache (read a-patch-e, as in made from many patches) is in the free-form class. It started with a var value format then, after a lot of "patching", added a warty-xmlish grammar for specifing scope and context of config vars.


  • 如果您只是调整部分配置文件,可能最好的方法是扫描文件,查找所需的配置变量,然后在本地使用该文件。

  • 如果您需要配置整个文件,最好根据C语言创建一个Java解析器。

这篇关于是否有任何Java库可以在http.conf之类的unix配置文件上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆