<i id='j91QR'><tr id='j91QR'><dt id='j91QR'><q id='j91QR'><span id='j91QR'><b id='j91QR'><form id='j91QR'><ins id='j91QR'></ins><ul id='j91QR'></ul><sub id='j91QR'></sub></form><legend id='j91QR'></legend><bdo id='j91QR'><pre id='j91QR'><center id='j91QR'></center></pre></bdo></b><th id='j91QR'></th></span></q></dt></tr></i><div id='j91QR'><tfoot id='j91QR'></tfoot><dl id='j91QR'><fieldset id='j91QR'></fieldset></dl></div>
      <bdo id='j91QR'></bdo><ul id='j91QR'></ul>

    <small id='j91QR'></small><noframes id='j91QR'>

        <tfoot id='j91QR'></tfoot><legend id='j91QR'><style id='j91QR'><dir id='j91QR'><q id='j91QR'></q></dir></style></legend>

        使用 Java 构建插件系统的最佳方法

        Best way to build a Plugin system with Java(使用 Java 构建插件系统的最佳方法)

            <tbody id='y1Y6w'></tbody>

            <tfoot id='y1Y6w'></tfoot>
          1. <small id='y1Y6w'></small><noframes id='y1Y6w'>

            <i id='y1Y6w'><tr id='y1Y6w'><dt id='y1Y6w'><q id='y1Y6w'><span id='y1Y6w'><b id='y1Y6w'><form id='y1Y6w'><ins id='y1Y6w'></ins><ul id='y1Y6w'></ul><sub id='y1Y6w'></sub></form><legend id='y1Y6w'></legend><bdo id='y1Y6w'><pre id='y1Y6w'><center id='y1Y6w'></center></pre></bdo></b><th id='y1Y6w'></th></span></q></dt></tr></i><div id='y1Y6w'><tfoot id='y1Y6w'></tfoot><dl id='y1Y6w'><fieldset id='y1Y6w'></fieldset></dl></div>

              <legend id='y1Y6w'><style id='y1Y6w'><dir id='y1Y6w'><q id='y1Y6w'></q></dir></style></legend>
                <bdo id='y1Y6w'></bdo><ul id='y1Y6w'></ul>

                1. 本文介绍了使用 Java 构建插件系统的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  您将如何为您的 Java 应用程序实现插件系统?

                  How would you implement a Plugin-system for your Java application?

                  是否有可能拥有一个易于使用(对于开发人员)的系统,它可以实现以下目标:

                  Is it possible to have an easy to use (for the developer) system which achieves the following:

                  • 用户将他们的插件放入应用的子目录中
                  • 插件可以提供配置屏幕
                  • 如果您使用框架,许可证是否与商业开发兼容?

                  推荐答案

                  首先你需要一个所有插件都需要实现的接口,例如

                  First you need an interface that all plugins need to implement, e.g.

                  public interface Plugin {
                      public void load(PluginConfiguration pluginConfiguration);
                      public void run();
                      public void unload();
                      public JComponent getConfigurationPage();
                  }
                  

                  插件作者应该将他们的插件捆绑到 JAR 文件中.您的应用程序打开 JAR 文件,然后可以使用 JAR 清单中的属性或 JAR 文件中所有文件的列表来查找实现插件接口的类.实例化那个类,插件就可以使用了.

                  Plugin authors should then bundle their plugins into JAR files. Your applications opens the JAR file and could then use an attribute from JAR manifest or the list of all files in the JAR file to find the class that implements your Plugin interface. Instantiate that class, the plugin is ready to go.

                  当然,您可能还想实现某种沙盒,以限制插件能做什么和不能做什么.我创建了一个小型 测试应用程序(和 blogged about it) 由两个插件组成,其中一个被拒绝访问本地资源.

                  Of course you may also want to implement some kind of sandboxing so that the plugin is restricted in what it can and can not do. I have created a small test application (and blogged about it) that consists of two plugins, one of which is denied access to local resources.

                  这篇关于使用 Java 构建插件系统的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Java Bytecode Manipulation Library Suggestions(Java 字节码操作库建议)
                  Java CLI UI-design: frameworks or libraries?(Java CLI UI 设计:框架还是库?)
                  About the use of Beans.xml configuration file in Spring Framework application(关于Spring Framework应用中Beans.xml配置文件的使用)
                  What is the difference between Spring, Struts, Hibernate, JavaServer Faces, Tapestry?(Spring、Struts、Hibernate、JavaServer Faces、Tapestry 有什么区别?)
                  Are there any android application framework like spring?(有没有像spring这样的android应用程序框架?)
                  Java Swing based game framework. Any advice?(基于 Java Swing 的游戏框架.有什么建议吗?)
                2. <legend id='5Vx5X'><style id='5Vx5X'><dir id='5Vx5X'><q id='5Vx5X'></q></dir></style></legend>
                    <bdo id='5Vx5X'></bdo><ul id='5Vx5X'></ul>

                      <small id='5Vx5X'></small><noframes id='5Vx5X'>

                        <i id='5Vx5X'><tr id='5Vx5X'><dt id='5Vx5X'><q id='5Vx5X'><span id='5Vx5X'><b id='5Vx5X'><form id='5Vx5X'><ins id='5Vx5X'></ins><ul id='5Vx5X'></ul><sub id='5Vx5X'></sub></form><legend id='5Vx5X'></legend><bdo id='5Vx5X'><pre id='5Vx5X'><center id='5Vx5X'></center></pre></bdo></b><th id='5Vx5X'></th></span></q></dt></tr></i><div id='5Vx5X'><tfoot id='5Vx5X'></tfoot><dl id='5Vx5X'><fieldset id='5Vx5X'></fieldset></dl></div>
                          <tbody id='5Vx5X'></tbody>
                          • <tfoot id='5Vx5X'></tfoot>