快速业务通道

Eclipse RCP技术和OSGi规范在客户端及服务器端的应用 - 编程入门网

作者 佚名技术 来源 NET编程 浏览 发布时间 2012-06-17
RE Business服务器通 过基于CORE Business Eclipse RCP客户端来显示已输入的数据报表。设计CORE Business Server过程中,对于重用相同逻辑和客户端已有的诸如Hibernate和Jasper Reports组件的需 求越发明显。显而易见的需求重用的解决方案是将服务器端的Java类重新打包为jar文件,并 将此jar文件包含在WAR文件中。在这个解决方案中,随着Java类结构的改变,原本复杂的构 建脚本也需要不断的修正。实际采用的解决方案非常简单,就是让Tomcat变地对“插件 敏感”。

Eclipse IDE帮助系统使用了Tomcat的内嵌版本, 这为RPC Software公司设计其需求功能 提供了起点。基于这点,Servlet.jar文件被移到他们自己开发的插件里。这样,其他被创建 的依赖servlet API的插件就可以使用它。已有的Tomcat插件在修改后使用Eclipse JDT编译 器,并非标准的Java编译器。因此CORE Business只需捆绑JRE而不是JDK。最后,用来加载包 含JSP页面的插件的类装载器,改进后被用来加载必要的系统插件,例如 org.eclipse.core.runtime。

package org.eclipse.help.internal.appserver; public class PluginClassLoaderWrapper extends URLClassLoader { ... /** * This is a workaround for the jsp compiler that needs to know the * classpath. */ public URL[] getURLs() { Set urls = getPluginClasspath(_plugin); return (URL[]) urls.toArray(new URL[urls.size()]); } private Set getPluginClasspath(String pluginId) { // Collect set of plug-ins Set plugins = new HashSet(); addPluginWithPrereqs(pluginId, plugins); // Collect URLs for each plug-in Set urls = new HashSet(); for (Iterator it = plugins.iterator(); it.hasNext();) {    String id = (String) it.next();    try {      Bundle b = Platform.getBundle(id);      if (b != null) {      // declared classpath      String headers = (String) b.getHeaders().get (Constants.BUNDLE_CLASSPATH);      ManifestElement[] paths =ManifestElement.parseHeader (Constants.BUNDLE_CLASSPATH, headers);      if (paths != null) {        for (int i = 0; i < paths.length; i++) {        String path = paths[i].getValue();        addBundlePath(urls, b, path);        }      } else {          // RPC custom code:        try {   String bundleJarPath = b.getLocation();          if (bundleJarPath.equals(Constants.SYSTEM_BUNDLE_LOCATION)) {            SystemBundle systemBundle = (SystemBundle) b;            bundleJarPath = ((SystemBundleData) systemBundle.getBundleData()).getBundleFile().getBaseFile().toURL().getPath ();            bundleJarPath =bundleJarPath.substring (bundleJarPath.lastIndexOf("plugins/"));          } else if(bundleJarPath.startsWith("initial@reference:file:")) {            bundleJarPath =b.getLocation().replaceFirst ("initial@reference:file:", "");          } else {            bundleJarPath =b.getLocation().replaceFirst("update@", "");          }          if (bundleJarPath.endsWith("/")) {            bundleJarPath = bundleJarPath.substring(0, bundleJarPath.lastIndexOf("/"));  

凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

分享到: 更多

Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号