开发者

Cross Platform Development Suggestions

Im working on a project in java that will eventually run on linux and windows machines and maybe mac. My program installs/configures开发者_开发技巧 vnc server so I'm looking for suggestions on how I should implement this part of the project. Should I just have a modular design or would it be possible to create a platform independent architecture for this problem?


I think that if VNC configuration is different on different platform you should just create interface and hierarchy of classes that implement it, i.e.

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 {}
}

etc, etc.

You can also create abstract configurator or cofigurator utils where the common logic will be implemented.

Now create factory that instantiates "right" implementation of configurator according to the platform. And you are done.

I believe that on Windows you will need some additional libraries, e.g. those that provide access to registry. But if you need this first check the following link: http://alexradzin.blogspot.com/2011/01/access-windows-registry-with-pure-java.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜