我正在用java做一个项目,这个项目最终会在linux和windows机器上运行,也许还会在mac上运行。我的程序安装/配置vnc服务器,因此我正在寻找有关如何实现项目这一部分的建议。我应该只有一个模块化的设计,或者有可能为这个问题创建一个独立于平台的架构吗?
发布于 2011-08-17 20:57:52
我认为如果VNC配置在不同的平台上是不同的,你应该只创建实现它的接口和类的层次结构,即
public interface VncConfigurator {
public void configure(Configuration cofiguration) throws ConfigurationException;
}
public class WindowsVncConfigurator implements VncConfgurator {
public void configure(Configuration cofiguration) throws ConfigurationException {}
}
public class LinuxVncConfigurator implements VncConfgurator {
public void configure(Configuration cofiguration) throws ConfigurationException {}
}
等等。
您还可以创建将实现公共逻辑的抽象配置器或协同配置器实用程序。
现在创建工厂,根据平台实例化配置器的“正确”实现。你就完了。
我相信在Windows上你将需要一些额外的库,例如那些提供注册表访问的库。但是如果你需要这个,首先检查下面的链接:http://alexradzin.blogspot.com/2011/01/access-windows-registry-with-pure-java.html
https://stackoverflow.com/questions/7093037
复制相似问题